Self hosted FLOSS fitness/workout, nutrition and weight tracker
Improve overview cache test
Roland Geiderae870e8c2a53
diff --git a/wger/core/tests/api_base_test.py b/wger/core/tests/api_base_test.pyindex 40b7548f8..977762920 100644--- a/wger/core/tests/api_base_test.py+++ b/wger/core/tests/api_base_test.py@@ -15,6 +15,8 @@# Djangofrom django.contrib.auth.models import Userfrom django.core.cache import cache+from django.db import connection+from django.test.utils import CaptureQueriesContext# Third Partyfrom rest_framework import status@@ -186,10 +188,22 @@ class ApiGetTestCase:cache.clear()self.test_get_overview()- # Second request: should be served from cache with no DB queries- with self.assertNumQueries(0):+ # Second request: should be served from cache+ # Only session-related queries may still occur, but no queries for the actual resource+ with CaptureQueriesContext(connection) as context:self.client.get(self.url)+ resource_queries = [+ q for q in context.captured_queries+ if 'django_session' not in q['sql']+ and 'SAVEPOINT' not in q['sql']+ and 'RELEASE' not in q['sql']+ ]+ self.assertEqual(+ len(resource_queries), 0,+ f'Expected no resource queries on cached request, got: {resource_queries}'+ )+def test_special_endpoints(self):"""Test accessing any special endpoint the resource could have