Skip to content

Commit

Permalink
use status enum for product api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris272 committed Jan 7, 2025
1 parent fe12f0a commit af240c3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/open_producten/producten/tests/api/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def detail_path(self, product_type):

def test_read_product_without_credentials_returns_error(self):
response = APIClient().get(self.path)
self.assertEqual(response.status_code, 401)
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)

def test_required_fields(self):
response = self.client.post(self.path, {})
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_create_product_without_bsn_or_kvk_returns_error(self):
data = self.data.copy()
data.pop("bsn")
response = self.client.post(self.path, data)
self.assertEqual(response.status_code, 400)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.data,
{
Expand All @@ -108,7 +108,7 @@ def test_update_product(self):
data = self.data | {"eind_datum": datetime.date(2025, 12, 31)}
response = self.client.put(self.detail_path(product), data)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(Product.objects.count(), 1)
self.assertEqual(Product.objects.first().eind_datum, data["eind_datum"])

Expand All @@ -118,7 +118,7 @@ def test_update_product_without_bsn_or_kvk(self):
data = self.data | {"bsn": None}
response = self.client.put(self.detail_path(product), data)

self.assertEqual(response.status_code, 400)
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(
response.data,
{
Expand All @@ -137,7 +137,7 @@ def test_partial_update_product(self):
data = {"eind_datum": datetime.date(2025, 12, 31)}
response = self.client.patch(self.detail_path(product), data)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(Product.objects.count(), 1)
self.assertEqual(Product.objects.first().eind_datum, data["eind_datum"])

Expand All @@ -151,7 +151,7 @@ def test_read_producten(self):

response = self.client.get(self.path)

self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data["count"], 2)
expected_data = [
{
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_read_product(self):

response = self.client.get(self.detail_path(product))

self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, status.HTTP_200_OK)
expected_data = {
"id": str(product.id),
"bsn": product.bsn,
Expand Down

0 comments on commit af240c3

Please sign in to comment.