示例#1
0
    def test_delete(self):
        dao = CityDAO()

        # Creating Info
        city = City(1, 'Santiago', 'CHL', 'Santiago', 10_000_000)
        save_city = dao.create(city)

        # Success Delete
        deleted_city = dao.delete(save_city)
        retrived_city = dao.retrive(deleted_city)
        self.assertEqual(retrived_city, None)

        # Failed Delete
        # No info
        # Bad Input
        with self.assertRaises(ValueError):
            dao.update(1)
示例#2
0
    def test_update(self):
        dao = CityDAO()

        # Success Update
        city = City(1, 'Santiago', 'CHL', 'Santiago', 10_000_000)
        save_city = dao.create(city)
        save_city.population += 1_000_000
        updated_city = dao.update(save_city)
        self.assertEqual(updated_city.population, 11_000_000)

        # Deleting Created Info
        dao.delete(updated_city)

        # Failed Update
        # No info
        # Bad Input
        with self.assertRaises(ValueError):
            dao.update(1)