diff --git a/open_prices/api/prices/tests.py b/open_prices/api/prices/tests.py index 1cf008b2..5d4875b2 100644 --- a/open_prices/api/prices/tests.py +++ b/open_prices/api/prices/tests.py @@ -152,10 +152,12 @@ def setUpTestData(cls): ) def test_price_list_without_filter(self): + self.assertEqual(Price.objects.count(), 5) response = self.client.get(self.url) self.assertEqual(response.data["total"], 5) def test_price_list_filter_by_product(self): + self.assertEqual(Price.objects.count(), 5) # product_code url = self.url + "?product_code=8001505005707" response = self.client.get(url) @@ -178,6 +180,7 @@ def test_price_list_filter_by_product(self): self.assertEqual(response.data["total"], 3) def test_price_list_filter_by_tags(self): + self.assertEqual(Price.objects.count(), 5) # labels_tags url = self.url + "?labels_tags__contains=en:organic" response = self.client.get(url) @@ -199,6 +202,7 @@ def test_price_list_filter_by_tags(self): self.assertEqual(response.data["total"], 1) def test_price_list_filter_by_price(self): + self.assertEqual(Price.objects.count(), 5) # exact price url = self.url + "?price=15" response = self.client.get(url) @@ -223,11 +227,13 @@ def test_price_list_filter_by_price(self): self.assertEqual(response.data["total"], 4) def test_price_list_filter_by_currency(self): + self.assertEqual(Price.objects.count(), 5) url = self.url + "?currency=EUR" response = self.client.get(url) self.assertEqual(response.data["total"], 4) def test_price_list_filter_by_location(self): + self.assertEqual(Price.objects.count(), 5) # location_osm_id url = self.url + f"?location_osm_id={self.user_price.location_osm_id}" response = self.client.get(url) @@ -245,6 +251,7 @@ def test_price_list_filter_by_location(self): self.assertEqual(response.data["total"], 4) def test_price_list_filter_by_proof(self): + self.assertEqual(Price.objects.count(), 5) # proof_id url = self.url + f"?proof_id={self.user_price.proof_id}" response = self.client.get(url) @@ -258,6 +265,7 @@ def test_price_list_filter_by_proof(self): self.assertEqual(response.data["total"], 1) def test_price_list_filter_by_date(self): + self.assertEqual(Price.objects.count(), 5) # exact date url = self.url + "?date=2024-01-01" response = self.client.get(url) @@ -276,11 +284,13 @@ def test_price_list_filter_by_date(self): self.assertEqual(response.data["total"], 2) def test_price_list_filter_by_owner(self): + self.assertEqual(Price.objects.count(), 5) url = self.url + f"?owner={self.user_session.user.user_id}" response = self.client.get(url) self.assertEqual(response.data["total"], 4) def test_price_list_filter_by_created(self): + self.assertEqual(Price.objects.count(), 5) url = self.url + "?created__gte=2024-01-01T00:00:00Z" response = self.client.get(url) self.assertEqual(response.data["total"], 5) diff --git a/open_prices/api/proofs/tests.py b/open_prices/api/proofs/tests.py index ace1eabd..68d7f66a 100644 --- a/open_prices/api/proofs/tests.py +++ b/open_prices/api/proofs/tests.py @@ -209,8 +209,7 @@ def test_proof_create(self): self.assertEqual(response.data["price_count"], 0) # ignored self.assertEqual(response.data["owner"], self.user_session.user.user_id) self.assertTrue("source" not in response.data) - p = Proof.objects.last() - self.assertEqual(p.source, "API") # default value + self.assertEqual(Proof.objects.last().source, "API") # default value def test_proof_create_with_location_id(self): location_osm = LocationFactory(**LOCATION_OSM_NODE_652825274) @@ -260,8 +259,7 @@ def test_proof_create_with_app_name(self): ) self.assertEqual(response.status_code, 201) self.assertTrue("source" not in response.data) - p = Proof.objects.last() - self.assertEqual(p.source, result) + self.assertEqual(Proof.objects.last().source, result) class ProofUpdateApiTest(TestCase):