How to use test_write_config method in molecule

Best Python code snippet using molecule_python

test_config.py

Source:test_config.py Github

copy

Full Screen

...36 assert config.read_config(section='DATASOURCE', option='bucketname') == 'nlr-data', "Failure in {}".format(37 inspect.stack()[0][3])38 logger.info(" Successfully completed {} {}".format(39 self.__class__.__name__, inspect.stack()[0][3]))40 def test_write_config(self):41 logger.info(" Started {} {}".format(42 self.__class__.__name__, inspect.stack()[0][3]))43 config = Config()44 config.write_config('WRITE', 'test1', 'value1')45 config.write_config('WRITE', 'test2', 'value2')46 value = config.read_config('WRITE', 'test1')47 assert value == 'value1', "Failure in {} local data metadata {}".format(48 inspect.stack()[0][3])49 logger.info(" Successfully completed {} {}".format(50 self.__class__.__name__, inspect.stack()[0][3]))51 def test_write_configs(self):52 logger.info(" Started {} {}".format(53 self.__class__.__name__, inspect.stack()[0][3]))54 section = 'WRITE_CONFIGS'55 options = ["option_{}".format(i) for i in range(5)]56 values = ["value_{}".format(i) for i in range(5)]57 config = Config()58 config.write_configs(section, options, values)59 for i in range(len(options)):60 assert config.read_config(section, options[i]) == values[i], "Failure in {} local data metadata {}".format(61 inspect.stack()[0][3])62 config.remove_section(section)63 logger.info(" Successfully completed {} {}".format(64 self.__class__.__name__, inspect.stack()[0][3]))65 def test_remove_option(self):66 logger.info(" Started {} {}".format(67 self.__class__.__name__, inspect.stack()[0][3]))68 config = Config()69 config.remove_option('WRITE', 'test2')70 with pytest.raises(KeyError):71 assert config.read_config('WHITE', 'test2'), "Failure in {}".format(72 inspect.stack()[0][3])73 logger.info(" Successfully completed {} {}".format(74 self.__class__.__name__, inspect.stack()[0][3]))75 def test_remove_section(self):76 logger.info(" Started {} {}".format(77 self.__class__.__name__, inspect.stack()[0][3]))78 config = Config()79 config.remove_section('WRITE')80 with pytest.raises(KeyError):81 assert config.read_config('WHITE', 'test2'), "Failure in {}".format(82 inspect.stack()[0][3])83 logger.info(" Successfully completed {} {}".format(84 self.__class__.__name__, inspect.stack()[0][3]))85 def test_write_options(self):86 logger.info(" Started {} {}".format(87 self.__class__.__name__, inspect.stack()[0][3]))88 options = []89 for i in range(5):90 option = {}91 k = 'key_' + str(i)92 v = 'value_' + str(i)93 option[k] = v94 options.append(option)95 config = Config()96 config.write_options('OPTIONS', options)97 for option in options:98 for k, v in option.items():99 assert config.read_config('OPTIONS', k) == v, "Failure in {}".format(100 inspect.stack()[0][3])101 logger.info(" Successfully completed {} {}".format(102 self.__class__.__name__, inspect.stack()[0][3]))103 def test_read_section(self):104 config = Config()105 options = config.read_section('OPTIONS')106 keys = list(options.keys())107 values = list(options.values())108 for i in range(len(keys)):109 assert keys[i] == 'key_' + str(i), "Failure in {}".format(110 inspect.stack()[0][3])111 assert values[i] == 'value_' + str(i), "Failure in {}".format(112 inspect.stack()[0][3])113 logger.info(" Successfully completed {} {}".format(114 self.__class__.__name__, inspect.stack()[0][3]))115 def test_read_section_as_df(self):116 config = Config()117 df = config.read_section('OPTIONS', as_df=True)118 assert isinstance(df, pd.DataFrame), "Failure in {}".format(119 inspect.stack()[0][3])120 logger.info(" Successfully completed {} {}".format(121 self.__class__.__name__, inspect.stack()[0][3]))122 def test_print_section(self):123 logger.info(" Started {} {}".format(124 self.__class__.__name__, inspect.stack()[0][3]))125 config = Config()126 config.print_section('OPTIONS')127 logger.info(" Successfully completed {} {}".format(128 self.__class__.__name__, inspect.stack()[0][3]))129 def test_teardown(self):130 logger.info(" Started {} {}".format(131 self.__class__.__name__, inspect.stack()[0][3]))132 config = Config()133 config.remove_section('OPTIONS')134 with pytest.raises(KeyError):135 assert config.read_section('OPTIONS'), "Failure in {}".format(136 inspect.stack()[0][3])137 logger.info(" Successfully completed {} {}".format(138 self.__class__.__name__, inspect.stack()[0][3]))139if __name__ == "__main__":140 t = ConfigTests()141 t.test_read_config()142 t.test_write_config()143 t.test_write_configs()144 t.test_remove_option()145 t.test_remove_section()146 t.test_write_options()147 t.test_print_section()148 t.test_read_section()149 t.test_read_section_as_df()150 t.test_teardown()...

Full Screen

Full Screen

test_templates.py

Source:test_templates.py Github

copy

Full Screen

...16# %%% User-Defined17from reportio.templates import ReportTemplate, write_config181920def test_write_config(self):21 pass222324class test_ReportTemplate(ReportTemplate):25 # %%% Functions26 # %%%% Private27 def __init__(self,28 report_name: str = 'test',29 log_location: str = os.path.join(30 os.path.dirname(__file__), 'simple_log.txt'),31 config_location: str = os.path.join(32 os.path.dirname(__file__), 'simple_config.txt'),33 connection_dictionary: Dict[str, object] = {},34 client: dd.Client = None,35 optional_function: callable = None) -> None:36 super().__init__(report_name,37 log_location,38 config_location,39 connection_dictionary,40 client,41 optional_function)4243 # %%%% Public44 def run(self):45 self.file = self.get_data('test_data',46 "SELECT * FROM CATEGORY",47 'sqlite')[0]48 self.export_data(self.file, self.config['REPORT']['export_to'])4950 def test_get_connection(self,51 database_name: str = 'test',52 connection_string: str = os.path.join(53 os.path.dirname(os.path.dirname(54 os.path.dirname(__file__))),55 'sample.db'),56 connection_type: str = 'sqlite') -> None:57 self.connection = super().get_connection(58 database_name,59 connection_string,60 connection_type)61 assert isinstance(self.connection, sqlite3.Connection)6263 def test_get_writer(self,64 report_location: str = os.path.join(65 os.path.dirname(__file__), 'test.xlsx')) -> None:66 self.writer = super().get_writer(report_location)67 assert isinstance(self.writer, pd.ExcelWriter)6869 def test_get_data(self,70 data_name: str = 'test',71 sql: str = "SELECT * FROM CATEGORY",72 connection_object: object = None):73 if not hasattr(self, 'connection'):74 self.test_get_connection()75 connection_object = self.connection76 self.data = super().get_data(77 data_name, sql, connection_object=connection_object)[0]78 assert isinstance(self.data, pd.DataFrame)7980 def test_get_temp_file(self,81 file_name: str,82 data: pd.DataFrame,83 folder_location: str) -> None:84 self.file = super().get_temp_file(file_name, data, folder_location)85 assert isinstance(self.file, tempfile.TemporaryFile)8687 def test_export_data(self,88 file: object = None,89 report_location: str = '',90 sheet: str = '',91 excel_writer: str = ''):92 file = self.file93 self.location = super().export_data(94 file, report_location, sheet, excel_writer)95 assert isinstance(self.loction, str)9697 def test_run(self):98 self.run()99 assert True100101 def test_backup_data(self):102 super().backup_data()103 temp_files: List[str] = [file for file in104 os.listdir(self.temp_files_location)105 if file.split('.')[-1] == 'gz']106 backup_files: List[str] = [file for file in107 os.listdir(self.backup_folder_location)108 if file.split('.')[-1] == 'gz']109 assert temp_files == backup_files110111 def test_attempt_resume(self):112 backed_up_files: List[str] = super().attempt_resume()113 backup_files: List[str] = [file for file in114 os.listdir(self.backup_folder_location)115 if file.split('.')[-1] == 'gz']116 assert backed_up_files == backup_files117118 def test_delete_data_backup(self):119 super().delete_data_backup()120 backup_files: List[str] = [file for file in121 os.listdir(self.backup_folder_location)122 if file.split('.')[-1] == 'gz']123 assert len(backup_files) == 0124125126# %% Functions127def test_write_config(self):128 write_config() ...

Full Screen

Full Screen

test_servers.py

Source:test_servers.py Github

copy

Full Screen

1from pathlib import Path2from pdfstream.callbacks.config import Config3from pkg_resources import resource_filename4CONFIG_FILE = Path(resource_filename("pdfstream", "data/config_files/simulation.ini"))5def test_write_config(local_dir: Path):6 config_file = local_dir.joinpath("config.ini")7 config = Config()8 with config_file.open("w") as f:9 config.write(f)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful