Skip to content

Commit 4f51b4a

Browse files
committed
Add num query tests for codefix viewset
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 5639fba commit 4f51b4a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

vulnerabilities/tests/test_api_v2.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -816,19 +816,22 @@ def setUp(self):
816816
self.url = reverse("advisory-codefix-list")
817817

818818
def test_list_all_codefixes(self):
819-
response = self.client.get(self.url)
819+
with self.assertNumQueries(10):
820+
response = self.client.get(self.url)
820821
assert response.status_code == status.HTTP_200_OK
821822
assert response.data["count"] == 1
822823
assert response.data["results"][0]["affected_advisory_id"] == self.advisory.avid
823824

824825
def test_filter_codefix_by_advisory_id_success(self):
825-
response = self.client.get(self.url, {"advisory_id": self.advisory.avid})
826+
with self.assertNumQueries(10):
827+
response = self.client.get(self.url, {"advisory_id": self.advisory.avid})
826828
assert response.status_code == status.HTTP_200_OK
827829
assert response.data["count"] == 1
828830
assert response.data["results"][0]["affected_advisory_id"] == self.advisory.avid
829831

830832
def test_filter_codefix_by_advisory_id_not_found(self):
831-
response = self.client.get(self.url, {"advisory_id": "nonexistent/ADVISORY-ID"})
833+
with self.assertNumQueries(6):
834+
response = self.client.get(self.url, {"advisory_id": "nonexistent/ADVISORY-ID"})
832835
assert response.status_code == status.HTTP_200_OK
833836
assert response.data["count"] == 0
834837

0 commit comments

Comments
 (0)