def test_create_db_history_table(self): """ test if pandas dataframe can be translated in a database table. """ spec = {'name': "table2", 'schema': "HISTORY", 'type': "history"} connection = self._get_engine() c = FileInspector( cfg_path=get_inipath(), file=os.path.join(FILEPATH, (f"{FileInspectorCsvTest.testfile['name']}." f"{FileInspectorCsvTest.testfile['type']}")), seperator="|", type="csv", con=connection) c._add_scd2_attributes() c.create_db_table(table_name=spec['name'], if_exists="replace", type=spec['type']) insp = inspect(connection) tables = insp.get_table_names() self.assertIn(spec['name'], tables)
def test_add_scd2_attributes(self): """ test if scd2 attributes can be add to the dataframe """ c = FileInspector( cfg_path=get_inipath(), file=os.path.join(FILEPATH, (f"{FileInspectorCsvTest.testfile['name']}." f"{FileInspectorCsvTest.testfile['type']}")), seperator="|", type="csv", ) cols = [ "UPDATED_AT", "VALID_FROM_DATE", "VALID_TO_DATE", ] c._add_scd2_attributes() dtype_key_list = c._his_data.dtypes.to_dict().keys() for col in cols: self.assertIn(col, dtype_key_list)