Skip to content

Commit dffae39

Browse files
rtibblesbotclaude
andcommitted
Fix flaky test_contentnode_tree on PostgreSQL
Match API response nodes to expected nodes by id instead of relying on positional ordering, since fixture data has duplicate lft values for sibling nodes causing nondeterministic ORDER BY results on PostgreSQL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 370d0bd commit dffae39

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

kolibri/core/content/test/test_content_app.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,17 @@ def test_contentnode_list_long(self):
491491

492492
def _recurse_and_assert(self, data, nodes, recursion_depth=0):
493493
recursion_depths = []
494-
for actual, expected in zip(data, nodes):
494+
nodes_by_id = {n.id: n for n in nodes}
495+
for actual in data:
496+
expected = nodes_by_id[actual["id"]]
495497
children = actual.pop("children", None)
496498
self._assert_node(actual, expected)
497499
if children:
498-
child_nodes = content.ContentNode.objects.filter(
499-
available=True, parent=expected
500-
).order_by("lft")
500+
child_nodes = list(
501+
content.ContentNode.objects.filter(
502+
available=True, parent=expected
503+
).order_by("lft")
504+
)
501505
if children["more"] is None:
502506
self.assertEqual(len(child_nodes), len(children["results"]))
503507
else:

0 commit comments

Comments
 (0)