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()
def update_configuration(self): """ Get the configuration that is updated with the user configuration changes on the dialog. :return: Configuration """ configuration = ExportConfiguration() if self.type_combo_box.currentData() == 'pg': # PostgreSQL specific options configuration.dbhost = self.db.dict_conn_params["host"] configuration.dbport = self.db.dict_conn_params["port"] configuration.dbusr = self.db.dict_conn_params["username"] configuration.database = self.db.dict_conn_params["database"] configuration.dbschema = self.get_checked_schema() configuration.dbpwd = self.db.dict_conn_params["password"] elif self.type_combo_box.currentData() == 'gpkg': configuration.dbfile = self.db.dict_conn_params["dbfile"] configuration.xtffile = self.xtf_file_line_edit.text().strip() java_path = get_java_path_from_qgis_model_baker() if java_path: self.base_configuration.java_path = java_path # Check custom model directories if QSettings().value( 'Asistente-LADM_COL/models/custom_model_directories_is_checked', type=bool): if self.custom_model_directories is None: self.base_configuration.custom_model_directories_enabled = False else: self.base_configuration.custom_model_directories = self.custom_model_directories self.base_configuration.custom_model_directories_enabled = True configuration.base_configuration = self.base_configuration if self.get_ili_models(): configuration.iliexportmodels = ';'.join(self.get_ili_models()) configuration.ilimodels = ';'.join(self.get_ili_models()) return configuration