mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-22 17:41:08 +00:00
Adds query time logger to dashbaord views
This commit is contained in:
parent
d56a21e232
commit
dc72b5b9a0
1 changed files with 6 additions and 1 deletions
|
@ -2,12 +2,14 @@
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from django.contrib.auth.models import Group
|
from django.contrib.auth.models import Group
|
||||||
|
from django.db import connection
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
|
||||||
from bookwyrm import models, views
|
from bookwyrm import models, views
|
||||||
from bookwyrm.management.commands import initdb
|
from bookwyrm.management.commands import initdb
|
||||||
|
from bookwyrm.tests.query_logger import QueryLogger, raise_long_query_runtime
|
||||||
from bookwyrm.tests.validate_html import validate_html
|
from bookwyrm.tests.validate_html import validate_html
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,7 +48,10 @@ class DashboardViews(TestCase):
|
||||||
request = self.factory.get("")
|
request = self.factory.get("")
|
||||||
request.user = self.local_user
|
request.user = self.local_user
|
||||||
|
|
||||||
result = view(request)
|
query_logger = QueryLogger()
|
||||||
|
with connection.execute_wrapper(query_logger):
|
||||||
|
result = view(request)
|
||||||
|
raise_long_query_runtime(query_logger.queries)
|
||||||
self.assertIsInstance(result, TemplateResponse)
|
self.assertIsInstance(result, TemplateResponse)
|
||||||
validate_html(result.render())
|
validate_html(result.render())
|
||||||
self.assertEqual(result.status_code, 200)
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
Loading…
Reference in a new issue