Add test for number of queries to load the sites index view

pull/11758/head
Sage Abdullah 2024-03-04 10:19:24 +00:00 zatwierdzone przez Matt Westcott
rodzic e7170d5571
commit fa5531c5f2
1 zmienionych plików z 15 dodań i 0 usunięć

Wyświetl plik

@ -25,6 +25,21 @@ class TestSiteIndexView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
response.content,
)
def test_num_queries(self):
# Warm up the cache
self.get()
with self.assertNumQueries(10):
self.get()
sites = [
Site(hostname=f"host {i}", port=f"800{i}", root_page_id=2)
for i in range(10)
]
Site.objects.bulk_create(sites)
with self.assertNumQueries(20):
self.get()
class TestSiteCreateView(AdminTemplateTestUtils, WagtailTestUtils, TestCase):
def setUp(self):