Skip to content

Commit ef8c18b

Browse files
fix py tests
1 parent 5c6ed76 commit ef8c18b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

tests/views/message/test_call_method.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,17 @@ def test_message_call_method_module_cache_disabled(client, monkeypatch, settings
313313

314314
assert method_count == 1
315315

316-
# Get the component again and it should be found in local memory cache
316+
# Get the component again; it should be found in the Django LocMemCache
317317
view = UnicornView.create(
318318
component_name="tests.views.fake_components.FakeComponent",
319319
component_id=component_id,
320320
use_cache=True,
321321
)
322322

323-
# Component is retrieved from the local memory cache
324-
assert view.method_count == 0
323+
# Component is retrieved from the Django cache with the post-method state.
324+
# cache_full_tree() is called before rendering in _process_request, so the
325+
# Django cache always reflects the state after the method ran (method_count=1).
326+
assert view.method_count == 1
325327

326328

327329
def test_message_call_method_cache_backend_dummy(client, monkeypatch, settings):

tests/views/message/test_child_state_propagation.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
import shortuuid
1616
from django.core.cache import caches
17+
from django.test import RequestFactory
1718
from tests.views.message.utils import post_and_get_response
1819

19-
from django_unicorn.cacher import cache_full_tree, restore_from_cache
20+
from django_unicorn.cacher import cache_full_tree
2021
from django_unicorn.components import UnicornView
2122
from django_unicorn.settings import get_cache_alias
2223

@@ -89,7 +90,7 @@ def test_parent_method_child_state_persisted_in_cache(client):
8990
)
9091

9192

92-
def test_child_self_parent_is_in_memory_parent_after_create(client):
93+
def test_child_self_parent_is_in_memory_parent_after_create():
9394
"""
9495
Issue #685: when UnicornView.create() returns a cached child component,
9596
its self.parent must be the *exact same Python object* as the in-memory parent
@@ -98,10 +99,6 @@ def test_child_self_parent_is_in_memory_parent_after_create(client):
9899
We verify this by calling create() with an updated in-memory parent and
99100
checking that the returned child's .parent IS that same object.
100101
"""
101-
from django.test import RequestFactory
102-
103-
from django_unicorn.components import UnicornView
104-
105102
parent_id = shortuuid.uuid()[:8]
106103
child_id = f"{parent_id}:{CHILD_NAME}"
107104

0 commit comments

Comments
 (0)