Skip to content

Commit

Permalink
feat(prices): GET /prices/id detail endpoint (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Sep 5, 2024
1 parent 04e9e10 commit 0d67b5c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions open_prices/api/locations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)


Expand Down
10 changes: 8 additions & 2 deletions open_prices/api/prices/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions open_prices/api/prices/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

class PriceViewSet(
mixins.ListModelMixin,
mixins.RetrieveModelMixin,
mixins.CreateModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
Expand Down
2 changes: 2 additions & 0 deletions open_prices/api/products/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)


Expand Down

0 comments on commit 0d67b5c

Please sign in to comment.