Test queries for list page

This commit is contained in:
Jake Howard 2022-08-27 12:39:50 +01:00
parent d83e3e0afe
commit 48c5aa0e56
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -52,16 +52,14 @@ class ListingPageTestCase(TestCase):
ContentPageFactory(parent=cls.page) ContentPageFactory(parent=cls.page)
def test_accessible(self) -> None: def test_accessible(self) -> None:
response = self.client.get(self.page.url) with self.assertNumQueries(25):
response = self.client.get(self.page.url)
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.context["listing_pages"]), 2) self.assertEqual(len(response.context["listing_pages"]), 2)
self.assertContains(response, self.page.reverse_subpage("feed")) self.assertContains(response, self.page.reverse_subpage("feed"))
def test_feed_accessible(self) -> None: def test_feed_accessible(self) -> None:
response = self.client.get(self.page.url + self.page.reverse_subpage("feed")) with self.assertNumQueries(11):
response = self.client.get(self.page.url + self.page.reverse_subpage("feed"))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertEqual(response["Content-Type"], "application/rss+xml; charset=utf-8") self.assertEqual(response["Content-Type"], "application/rss+xml; charset=utf-8")
def test_queries(self) -> None:
with self.assertNumQueries(25):
self.client.get(self.page.url)