コード例 #1
0
    def test_get_success(self):
        """ test for successful object retrival """
        storage = FileStorage()
        new_state = State()
        new_city = City()
        new_state.save()
        new_city.save()

        found_city = storage.get(City, new_city.id)
        found_state = storage.get(State, new_state.id)
        wrong_city = storage.get(City, "1234")
        wrong_state = storage.get(State, "12345")
        self.assertEqual(found_state, new_state)
        self.assertIs(found_state, new_state)
        self.assertIsInstance(found_state, State)
        self.assertNotEqual(found_state, None)
        self.assertIsNot(found_state, None)

        self.assertEqual(found_city, new_city)
        self.assertIs(found_city, new_city)
        self.assertIsInstance(found_city, City)
        self.assertNotEqual(found_city, None)
        self.assertIsNot(found_city, None)
        new_state.delete()
        new_city.delete()
コード例 #2
0
def city_delete(id, state):
    result = City.delete(id, state)
    if result:
        flash('City deleted successfully!!!')
    return redirect(url_for('city'))