def test_all_lambda_constants(self): self.assertEqual(len(Constants.LOAD_TYPES()), 2) self.assertEqual(Constants.LOAD_TYPES(), [ Constants.LOAD_TYPE_ASSESSMENT, Constants.LOAD_TYPE_STUDENT_REGISTRATION ]) self.assertEqual(len(Constants.ASSESSMENT_TYPES()), 3) self.assertEqual(Constants.ASSESSMENT_TYPES(), [ Constants.ASSESSMENT_TYPE_SUMMATIVE, Constants.ASSESSMENT_TYPE_INTERIM_COMPREHENSIVE, Constants.ASSESSMENT_TYPE_INTERIM_ASSESSMENT_BLOCKS ]) self.assertEqual( Constants.UDL2_STAGING_TABLE(Constants.LOAD_TYPE_ASSESSMENT), Constants.STG_ASMT_OUT_TABLE) self.assertEqual( Constants.UDL2_STAGING_TABLE( Constants.LOAD_TYPE_STUDENT_REGISTRATION), Constants.STG_SR_TABLE) self.assertEqual( Constants.UDL2_INTEGRATION_TABLE(Constants.LOAD_TYPE_ASSESSMENT), Constants.INT_ASMT_OUT_TABLE) self.assertEqual( Constants.UDL2_INTEGRATION_TABLE( Constants.LOAD_TYPE_STUDENT_REGISTRATION), Constants.INT_SR_TABLE) self.assertEqual( Constants.UDL2_JSON_INTEGRATION_TABLE( Constants.LOAD_TYPE_ASSESSMENT), Constants.INT_ASMT_TABLE) self.assertEqual( Constants.UDL2_JSON_INTEGRATION_TABLE( Constants.LOAD_TYPE_STUDENT_REGISTRATION), Constants.INT_SR_META_TABLE) self.assertEqual( Constants.UDL2_REF_MAPPING_TABLE(Constants.LOAD_TYPE_ASSESSMENT), Constants.ASMT_REF_TABLE) self.assertEqual( Constants.UDL2_REF_MAPPING_TABLE( Constants.LOAD_TYPE_STUDENT_REGISTRATION), Constants.SR_REF_TABLE) self.assertEqual(Constants.TENANT_SEQUENCE_NAME('cat'), Constants.SEQUENCE_NAME + '_' + 'cat') self.assertEqual(Constants.TENANT_SEQUENCE_NAME(''), None) self.assertEqual(Constants.TENANT_SEQUENCE_NAME(None), None)
def get_content_validator_conf(guid_batch, load_type): udl_db_conn = udl2_conf.get(Constants.UDL2_DB_CONN) conf = { mk.SOURCE_DB_SCHEMA: udl_db_conn.get(Constants.DB_SCHEMA), mk.ASMT_TABLE: Constants.UDL2_JSON_INTEGRATION_TABLE(load_type), mk.ASMT_OUTCOME_TABLE: Constants.UDL2_STAGING_TABLE(load_type), mk.GUID_BATCH: guid_batch, mk.LOAD_TYPE: load_type } return conf
def test_load_stage_to_int_student_registration(self): guid_batch = str(uuid4()) load_type = Constants.LOAD_TYPE_STUDENT_REGISTRATION conf = self.generate_conf_for_moving_from_stg_to_int(guid_batch, load_type) self.udl2_conf['guid_batch'] = guid_batch self.load_file_to_stage(os.path.join('student_registration_data', 'test_stu_reg_without_headers.csv'), os.path.join('student_registration_data', 'test_stu_reg_header.csv'), load_type, Constants.UDL2_STAGING_TABLE(load_type), guid_batch) move_data_from_staging_to_integration(conf) postloading_total = self.postloading_count(Constants.UDL2_INTEGRATION_TABLE(load_type)) self.assertEqual(10, postloading_total)
def generate_conf_for_loading(file_to_load, start_seq, load_type, header_file_path, guid_batch, tenant_name): csv_table = extract_file_name(file_to_load) conf = { mk.FILE_TO_LOAD: file_to_load, mk.ROW_START: start_seq, mk.HEADERS: header_file_path, mk.CSV_SCHEMA: udl2_conf['udl2_db_conn']['db_schema'], mk.CSV_TABLE: csv_table, mk.FDW_SERVER: Constants.UDL2_FDW_SERVER, mk.TARGET_DB_SCHEMA: udl2_conf['udl2_db_conn']['db_schema'], mk.TARGET_DB_TABLE: Constants.UDL2_STAGING_TABLE(load_type), mk.APPLY_RULES: True, mk.REF_TABLE: Constants.UDL2_REF_MAPPING_TABLE(load_type), mk.CSV_LZ_TABLE: Constants.UDL2_CSV_LZ_TABLE, mk.GUID_BATCH: guid_batch, mk.TENANT_NAME: tenant_name } return conf
def generate_conf_for_moving_from_stg_to_int(self, guid_batch, load_type): db_params_tuple = get_db_connection_params(self.udl2_conf['udl2_db_conn']['url']) conf = { mk.GUID_BATCH: guid_batch, # source database setting mk.SOURCE_DB_DRIVER: db_params_tuple[0], mk.SOURCE_DB_USER: db_params_tuple[1], mk.SOURCE_DB_PASSWORD: db_params_tuple[2], mk.SOURCE_DB_HOST: db_params_tuple[3], mk.SOURCE_DB_PORT: db_params_tuple[4], mk.SOURCE_DB_NAME: db_params_tuple[5], mk.SOURCE_DB_SCHEMA: self.udl2_conf['udl2_db_conn']['db_schema'], mk.SOURCE_DB_TABLE: Constants.UDL2_STAGING_TABLE(load_type), # target database setting mk.TARGET_DB_SCHEMA: self.udl2_conf['udl2_db_conn']['db_schema'], mk.TARGET_DB_TABLE: Constants.UDL2_INTEGRATION_TABLE(load_type), mk.REF_TABLE: Constants.UDL2_REF_MAPPING_TABLE(load_type), mk.ERROR_DB_SCHEMA: self.udl2_conf['udl2_db_conn']['db_schema'], mk.ERR_LIST_TABLE: Constants.UDL2_ERR_LIST_TABLE } return conf