feat: allow to configure media cache (for JS and CSS files) (#946)

This commit is contained in:
Juro Oravec 2025-02-03 21:24:26 +01:00 committed by GitHub
parent bb61ff42eb
commit 48bae51ab9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 305 additions and 73 deletions

View file

@ -30,12 +30,15 @@ class BaseTestCase(SimpleTestCase):
super().tearDown()
registry.clear()
from django_components.template import template_cache
from django_components.cache import component_media_cache, template_cache
# NOTE: There are 1-2 tests which check Templates, so we need to clear the cache
if template_cache:
template_cache.clear()
if component_media_cache:
component_media_cache.clear()
from django_components.component import component_node_subclasses_by_name
component_node_subclasses_by_name.clear()
@ -180,11 +183,14 @@ def parametrize_context_behavior(cases: List[ContextBehParam], settings: Optiona
self._start_gen_id_patch()
# Reset template cache
from django_components.template import template_cache
from django_components.cache import component_media_cache, template_cache
if template_cache: # May be None if the cache was not initialized
template_cache.clear()
if component_media_cache:
component_media_cache.clear()
from django_components.component import component_node_subclasses_by_name
component_node_subclasses_by_name.clear()