def test_delete_object(self): db = DBConnection("../data_base/test_base.db") self.assertTrue(db.get_object_count() == 0) db.insert_object(1, "1") self.assertTrue(db.get_object_count() == 1) self.assertTrue(db.get_object_name(1) == "1") db.delete_object(1) self.assertTrue(db.get_object_count() == 0) db.clear()
def test_insert_object(self): db = DBConnection("../data_base/test_base.db") db.clear() self.assertRaises(DBConnection("RANDOM_BASE")) self.assertTrue(db.get_object_count() == 0) db.insert_object(1, "1") self.assertTrue(db.get_object_count() == 1) self.assertTrue(db.get_object_name(1) == "1") db.clear() self.assertTrue(db.get_object_count() == 0)
def test_get_object_list(self): db = DBConnection("../data_base/test_base.db") self.assertTrue(db.get_object_count() == 0) db.insert_object(1, "1") db.insert_object(2, "2") db.insert_object(3, "3") db.insert_object(4, "4") db.insert_object(5, "5") db.insert_object(6, "6") self.assertTrue(db.get_object_count() == 6) test_list = db.get_object_list() self.assertTrue(test_list[0][1] == "1") self.assertTrue(test_list[1][1] == "2") self.assertTrue(test_list[2][1] == "3") self.assertTrue(test_list[3][1] == "4") self.assertTrue(test_list[4][1] == "5") self.assertTrue(test_list[5][1] == "6") db.clear() self.assertTrue(db.get_object_count() == 0)