def test_replace_machine_right_data(self): online_determinator.insert_machine('pony', pony_dict_1, 'id') online_determinator.replace_machine('pony', pony_dict_2, pony_dict_1) if select('id', 'pony', pony_dict_2) is not None: contain = True else: contain = False self.assertEqual(contain, True) delete('pony', pony_dict_2)
def test_replace_machine_wrong_key_value(self): id = online_determinator.insert_machine('pony', pony_dict_1, 'id') online_determinator.replace_machine('pony', pony_dict_2, pony_dict_wrong_value) self.assertEqual(id, select('id', 'pony', pony_dict_1 )) delete('pony', pony_dict_1)
def test_replace_machine_wrong_new_data_column(self): online_determinator.insert_machine('pony', pony_dict_1, 'id') with self.assertRaises(Exception) as context: online_determinator.replace_machine('pony', pony_dict_wrong, pony_dict_1) self.assertTrue("Unknown column 'second_name' in 'field list'" in str(context.exception)) delete('pony', pony_dict_1)
def test_replace_machine_wrong_key_column(self): online_determinator.insert_machine('pony', pony_dict_1, 'id') with self.assertRaises(Exception) as context: online_determinator.replace_machine('pony', pony_dict_2, pony_dict_wrong) self.assertTrue("Unknown column 'second_name' in 'where clause'" in str(context.exception)) delete('pony', pony_dict_1)
def test_replace_machine_wrong_tabe(self): online_determinator.insert_machine('pony', pony_dict_1, 'id') with self.assertRaises(Exception) as context: online_determinator.replace_machine('not_pony', pony_dict_2, pony_dict_1) self.assertTrue("Table 'pony_color_db.not_pony' doesn't exist" in str(context.exception)) delete('pony', pony_dict_1)