コード例 #1
0
    def test_retrive(self):
        dao = CityDAO()

        # Success Retriving
        city = dao.retrive(City(1))
        self.assertEqual(city.name, 'Kabul')

        # Failed Retriving
        # No info
        city = dao.retrive(City(10000))
        self.assertEqual(city, None)
        # Bad Input
        with self.assertRaises(ValueError):
            dao.retrive(1)
コード例 #2
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)