def test_schema_existing(self): self.pipe.register_domain(_domain_rob) self.pipeline.run() sql = """SELECT exists(select schema_name FROM information_schema.schemata WHERE schema_name = 'dv')""" result = execute_sql(sql) schema_present = result[0][0] self.assertTrue(schema_present, msg='bestaat nog niet!')
def test_max_runid_selected(self): self.pipeline.run() sql = 'SELECT max(runid) as max_runid from sys.runs' result = execute_sql(sql) dec = max(result)[0] self.assertEqual( dec, Decimal(str(self.pipeline.runid)), 'max(result)[0] en self.pipeline.runid zijn niet hetzelfde!')
def test03_domain_new_attribute_added(self): self.pipe.register_domain(_domain_rob_unittest) self.pipeline.run() sql = """SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_CATALOG = 'pyelt_unittests' AND TABLE_SCHEMA = 'dv' AND TABLE_NAME = 'zorgverlener_sat_personalia'""" result = execute_sql(sql) result = result[0][0] self.assertEqual( result, 15, 'Ik verwachte 15 kolommen; is domain_rob_unittest misschien recent veranderd?' )
def test06_update_dv_field_null_to_value(self): sql = """select a.straat from pyelt_unittests.dv.adres_sat a inner join pyelt_unittests.dv.zorgverlener_adres_link za on a._id = za.fk_adres_hub inner join pyelt_unittests.dv.zorgverlener_hub z on za.fk_zorgverlener_hub = z._id where z.bk = '448' and za.type = 'bezoek' and a._active = True""" result = execute_sql(sql) result = result[0][0] self.assertEqual( result, 'Dalstraat', 'ik verwachte dat deze waarde van Null naar Daalstraat aangepast was' )
def test07_update_dv_field_value_to_null(self): # print("test07_update_dv_field_value_to_null:") sql = """select a._active from pyelt_unittests.dv.adres_sat a inner join pyelt_unittests.dv.zorgverlener_adres_link za on a._id = za.fk_adres_hub inner join pyelt_unittests.dv.zorgverlener_hub z on za.fk_zorgverlener_hub = z._id where z.bk = '567' and za.type = 'bezoek' and a.straat = 'Beaufort'""" result = execute_sql(sql) result = result[0][0] print(result) self.assertFalse( 'Ik verwachte dat deze waarde False zou zijn (de gezochte straatnaam verwijst naar niet langer geldende adresgegevens voor dit bezoekadres; in sor tabel als lege velden)' )
def test05_update_dv_field(self): # unittest voor waarde naar waarde # result = get_field_value_from_dv_table('landcode','zorgverlener','contactgegevens','455',['_active = True', """type = 'mobiel'"""]) sql = """select a.land from pyelt_unittests.dv.adres_sat a inner join pyelt_unittests.dv.zorgverlener_adres_link za on a._id = za.fk_adres_hub inner join pyelt_unittests.dv.zorgverlener_hub z on za.fk_zorgverlener_hub = z._id where z.bk = '455' and za.type = 'bezoek' and a._active = True""" result = execute_sql(sql) result = result[0][0] self.assertEqual( result, 'Australia', 'ik verwachte dat deze waarde van Nederland naar Australia aangepast was' )
def get_field_value_from_dv_table(fieldname, entity_name, sat_name, bk, sql_conditions_list): if sat_name != '': sat_name2 = '_{}'.format(sat_name) else: sat_name2 = '' if sql_conditions_list == []: sql_condition = '' else: sql_condition = '' for i in sql_conditions_list: sql_condition = sql_condition + ' AND s.{}'.format(i) sql = """select s.{1} from {0}{2}_sat{3} s inner join {0}{2}_hub h on s._id = h._id where h.bk = '{4}'{5}""".format('pyelt_unittests.dv.', fieldname, entity_name, sat_name2, bk, sql_condition) result = execute_sql(sql) return result
def get_row_count(unittest, table_name, count): test_sql = "SELECT * FROM " + table_name result = execute_sql(test_sql) unittest.assertEqual(len(result), count, table_name)
def get_field_value_from_table(fieldname, table_name, sql_condition): sql = """select {0} from {1} where {2}""".format(fieldname, table_name, sql_condition) result = execute_sql(sql) return result