class TestDishesViews(APITestCase):
def setUp(self):
Dish.objects.create(title="Dish 1")
def test_get_all_dishes(self):
response = self.client.get('/api/dishes/')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_get_dishes_detail(self):
response = self.client.get('/api/dishes/1')
self.assertEqual(response.status_code, status.HTTP_200_OK)
def test_dishes_post(self):
response = self.client.post('/api/dishes/', {'title': 'new idea'}, format='json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
response = self.client.put('/api/dishes/1/',
{'title': 'new idea', 'ingredients': ['1', '2']}, content_type='application/json')
self.assertEqual(response.status_code, status.HTTP_201_CREATED)