diff --git a/open_prices/api/locations/tests.py b/open_prices/api/locations/tests.py index f29b6731..d25b0465 100644 --- a/open_prices/api/locations/tests.py +++ b/open_prices/api/locations/tests.py @@ -106,6 +106,7 @@ def test_location_detail(self): self.assertEqual(response.status_code, 404) # existing location response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) self.assertEqual(response.data["id"], self.location.id) # self.assertEqual(response.data["osm_lat"], 45.1805534) @@ -120,6 +121,7 @@ def test_location_detail_by_osm(self): args=[self.location.osm_type, self.location.osm_id], ) response = self.client.get(url) + self.assertEqual(response.status_code, 200) self.assertEqual(response.data["id"], self.location.id) diff --git a/open_prices/api/prices/tests.py b/open_prices/api/prices/tests.py index efdeec04..e930a2d8 100644 --- a/open_prices/api/prices/tests.py +++ b/open_prices/api/prices/tests.py @@ -251,9 +251,15 @@ def setUpTestData(cls): ) cls.url = reverse("api:prices-detail", args=[cls.price.id]) - def test_price_detail_not_allowed(self): + def test_price_detail(self): + # 404 + url = reverse("api:prices-detail", args=[999]) + response = self.client.get(url) + self.assertEqual(response.status_code, 404) + # existing price response = self.client.get(self.url) - self.assertEqual(response.status_code, 405) + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data["id"], self.price.id) class PriceCreateApiTest(TestCase): diff --git a/open_prices/api/prices/views.py b/open_prices/api/prices/views.py index 51883960..369a44b5 100644 --- a/open_prices/api/prices/views.py +++ b/open_prices/api/prices/views.py @@ -16,6 +16,7 @@ class PriceViewSet( mixins.ListModelMixin, + mixins.RetrieveModelMixin, mixins.CreateModelMixin, mixins.UpdateModelMixin, mixins.DestroyModelMixin, diff --git a/open_prices/api/products/tests.py b/open_prices/api/products/tests.py index 438822e4..fd5f672c 100644 --- a/open_prices/api/products/tests.py +++ b/open_prices/api/products/tests.py @@ -120,6 +120,7 @@ def test_product_detail(self): self.assertEqual(response.status_code, 404) # existing product response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) self.assertEqual(response.data["id"], self.product.id) def test_product_detail_by_code(self): @@ -130,6 +131,7 @@ def test_product_detail_by_code(self): # existing product url = reverse("api:products-get-by-code", args=[self.product.code]) response = self.client.get(url) + self.assertEqual(response.status_code, 200) self.assertEqual(response.data["id"], self.product.id)