Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions testapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
from .models import TestModel


def clear_contenttype_cache():
print("Clearing content type cache...")
ContentType.objects.clear_cache()

class ContentTypeCacheTestCase(ChannelsLiveServerTestCase):
"""
Test case that demonstrates ContentType caching behavior using ChannelsLiveServerTestCase.

This test case includes two tests that both hit the same view endpoint
which tests ContentType.get_for_model() behavior before and after clearing the cache.
"""

@classmethod
def setUpClass(cls):
super().setUpClass()
commands = {
"clear_contenttype_cache": clear_contenttype_cache
}

def setUp(self):
"""Set up before each test."""
# Clear the cache before each test to ensure clean state
ContentType.objects.clear_cache()
self.addCleanup(ContentType.objects.clear_cache)
super().setUp()
self.run_server_command("clear_contenttype_cache")

def test_contenttype_cache_first(self):
"""
Expand Down