def test_delete_table(self): client = self.app.test_client() # assuming test_post_tables executed before self.test_post_tables() t = tables_toaddedit[0] response = client.delete(t["url"]) json = response.get_data() self.assertEqual(response.status_code, 204, msg=json) response = client.get(t["url"]) json = response.get_json() self.assertEqual(response.status_code, 404, msg=json) response = client.delete(tables[2]["url"]) json = response.get_data() self.assertEqual(response.status_code, 409, msg=json) response = client.get(restaurants[2]["url"]) json = response.get_json() self.assertEqual(response.status_code, 200, msg=json) # check incremental id t = tables_toaddedit[2] dup = clone_for_post(t, table_post_keys) response = client.post('/restaurants/%d/tables' % t["restaurant_id"], json=dup) json = response.get_json() ret = same_restaurant(json, t) self.assertIsNone(ret, msg=str(json) + "\n\n" + str(t)) self.assertEqual(response.status_code, 201, msg=json)
def test_delete_restaurant(self): client = self.app.test_client() # assuming test_post_restaurants executed before self.test_post_restaurants() r = restaurants_toaddedit[0] response = client.delete(r["url"]) json = response.get_data() self.assertEqual(response.status_code, 204, msg=json) response = client.get(r["url"]) json = response.get_json() self.assertEqual(response.status_code, 404, msg=json) response = client.delete(restaurants[3]["url"]) json = response.get_data() self.assertEqual(response.status_code, 409, msg=json) response = client.get(restaurants[3]["url"]) json = response.get_json() self.assertEqual(response.status_code, 200, msg=json) #check incremental id r = restaurants_toaddedit[2] dup = clone_for_post(r, restaurant_post_keys) response = client.post('/restaurants', json=dup) json = response.get_json() ret = same_restaurant(json, r) self.assertIsNone(ret, msg=str(json) + "\n\n" + str(r)) self.assertEqual(response.status_code, 201, msg=json)
def test_get_restaurant(self): client = self.app.test_client() for r in restaurants: response = client.get(r['url']) json = response.get_json() self.assertEqual(response.status_code, 200, msg=json) ret = same_restaurant(json, r) self.assertIsNone(ret, msg=str(json) + "\n\n" + str(r))
def test_post_restaurants(self): client = self.app.test_client() dup = clone_for_post(restaurants_toaddedit[0], restaurant_post_keys) response = client.post('/restaurants', json=dup) json = response.get_json() ret = same_restaurant(json, restaurants_toaddedit[0]) self.assertIsNone(ret, msg=str(json) + "\n\n" + str(restaurants_toaddedit[0])) self.assertEqual(response.status_code, 201, msg=json)