def test_export_data_in_pg(self): print("\nINFO: Validate Export Data in PG...") restore_schema('test_export_data') db_pg = get_pg_conn('test_export_data') base_config = BaseConfiguration() base_config.custom_model_directories = testdata_path(MODELS_PATH) base_config.custom_model_directories_enabled = True configuration = ExportConfiguration() configuration.base_configuration = base_config configuration.dbhost = 'postgres' configuration.dbusr = '******' configuration.dbpwd = 'clave_ladm_col' configuration.database = 'ladm_col' configuration.dbschema = 'test_export_data' configuration.delete_data = True configuration.ilimodels = ';'.join([self.ladmcol_models.model(LADMNames.LADM_COL_MODEL_KEY).full_name(), self.ladmcol_models.model(LADMNames.SNR_DATA_SUPPLIES_MODEL_KEY).full_name(), self.ladmcol_models.model(LADMNames.SUPPLIES_MODEL_KEY).full_name(), self.ladmcol_models.model(LADMNames.SUPPLIES_INTEGRATION_MODEL_KEY).full_name(), self.ladmcol_models.model(LADMNames.SURVEY_MODEL_KEY).full_name()]) exporter = iliexporter.Exporter() exporter.tool = DbIliMode.ili2pg exporter.configuration = configuration exporter.configuration.xtffile = os.path.join(tempfile.mkdtemp(), 'test_export_data.xtf') self.assertEqual(exporter.run(), iliexporter.Exporter.SUCCESS) self.check_export_xtf(exporter.configuration.xtffile) db_pg.conn.close()
def test_export_data_in_mssql(self): print("\nINFO: Validate Export Data in MS SQL Server...") schema = 'test_export_data' reset_db_mssql(schema) restore_schema_mssql(schema) db_conn = get_mssql_conn(schema) base_config = BaseConfiguration() base_config.custom_model_directories = testdata_path(MODELS_PATH) base_config.custom_model_directories_enabled = True model_list = [ self.ladmcol_models.model( LADMNames.LADM_COL_MODEL_KEY).full_name(), self.ladmcol_models.model( LADMNames.SNR_DATA_SUPPLIES_MODEL_KEY).full_name(), self.ladmcol_models.model( LADMNames.SUPPLIES_MODEL_KEY).full_name(), self.ladmcol_models.model( LADMNames.SUPPLIES_INTEGRATION_MODEL_KEY).full_name(), self.ladmcol_models.model(LADMNames.SURVEY_MODEL_KEY).full_name() ] configuration = ExportConfiguration() configuration.base_configuration = base_config configuration.dbhost = 'mssql' configuration.dbusr = '******' configuration.dbpwd = '<YourStrong!Passw0rd>' configuration.dbport = '1433' configuration.database = schema # use schema because delete schemas in mssql is difficult configuration.dbschema = schema configuration.db_odbc_driver = 'ODBC Driver 17 for SQL Server' configuration.delete_data = True configuration.ilimodels = ';'.join(model_list) exporter = iliexporter.Exporter() exporter.tool = DbIliMode.ili2mssql exporter.configuration = configuration exporter.configuration.xtffile = os.path.join(tempfile.mkdtemp(), 'test_export_data.xtf') # exporter.stderr.connect(self.on_stderr) self.assertEqual(exporter.run(), iliexporter.Exporter.SUCCESS) self.check_export_xtf(exporter.configuration.xtffile) db_conn.conn.close()