Skip to content

Commit 0e68552

Browse files
fix tests
1 parent 5768165 commit 0e68552

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/django_unicorn/views/response.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ def _collect_all_calls(self) -> list[dict[str, Any]]:
3333
all_calls = list(self.component.calls) # Start with parent's calls
3434

3535
# Recursively collect from all children
36-
for child in self.component.children:
37-
all_calls.extend(child.calls)
38-
# Recursively collect from grandchildren
39-
all_calls.extend(self._collect_calls_from_component(child))
36+
all_calls.extend(self._collect_calls_from_component(self.component))
4037

4138
return all_calls
4239

@@ -50,12 +47,11 @@ def _collect_calls_from_component(self, component: UnicornView) -> list[dict[str
5047
Returns:
5148
List of call dictionaries from all descendants.
5249
"""
53-
# Base case: if component has no children, return empty list
54-
if not component.children:
55-
return []
5650
calls = []
5751
for child in component.children:
52+
# Add this child's calls
5853
calls.extend(child.calls)
54+
# Recursively collect from this child's descendants
5955
calls.extend(self._collect_calls_from_component(child))
6056
return calls
6157

tests/views/test_unit_views.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def test_component_response_structure():
8686
component = Mock(spec=Component)
8787
component.errors = {}
8888
component.calls = []
89+
component.children = []
8990
component.parent = None
9091
component.force_render = False
9192

0 commit comments

Comments
 (0)