mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
Update number of queries in test_num_queries
This commit is contained in:
parent
d4b9c3afb1
commit
2f613607af
@ -1,10 +1,10 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.cache import cache
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from model_bakery import baker
|
from model_bakery import baker
|
||||||
from model_bakery.recipe import Recipe
|
from model_bakery.recipe import Recipe
|
||||||
from pytest_django.asserts import assertNumQueries
|
|
||||||
|
|
||||||
from core.baker_recipes import old_subscriber_user, subscriber_user
|
from core.baker_recipes import old_subscriber_user, subscriber_user
|
||||||
from core.models import RealGroup, SithFile, User
|
from core.models import RealGroup, SithFile, User
|
||||||
@ -128,9 +128,11 @@ class TestPictureSearch(TestSas):
|
|||||||
def test_num_queries(self):
|
def test_num_queries(self):
|
||||||
"""Test that the number of queries is stable."""
|
"""Test that the number of queries is stable."""
|
||||||
self.client.force_login(subscriber_user.make())
|
self.client.force_login(subscriber_user.make())
|
||||||
with assertNumQueries(5):
|
cache.clear()
|
||||||
|
with self.assertNumQueries(7):
|
||||||
|
# 2 requests to create the session
|
||||||
# 1 request to fetch the user from the db
|
# 1 request to fetch the user from the db
|
||||||
# 2 requests to check the user permissions
|
# 2 requests to check the user permissions, depends on the db engine
|
||||||
# 1 request to fetch the pictures
|
# 1 request to fetch the pictures
|
||||||
# 1 request to count the total number of items in the pagination
|
# 1 request to count the total number of items in the pagination
|
||||||
self.client.get(self.url)
|
self.client.get(self.url)
|
||||||
|
Loading…
Reference in New Issue
Block a user