Skip to content

Commit ed1cc70

Browse files
committed
fix: replace tautological assertion with exclusion-set verification
The elif branch at _assert_shuffle line 1237 checked make_query_plan_with_exclusion.called then immediately called .assert_called(), which can never fail. Replace with a meaningful assertion that verifies the exclusion set actually contains the yielded replicas.
1 parent 32a6acf commit ed1cc70

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tests/unit/test_policies.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,18 @@ def _assert_shuffle(self, patched_shuffle, cluster, keyspace, routing_key):
12351235
child_policy.make_query_plan.assert_called_with(keyspace, query)
12361236
child_policy.make_query_plan_with_exclusion.assert_called()
12371237
elif child_policy.make_query_plan_with_exclusion.called:
1238-
child_policy.make_query_plan_with_exclusion.assert_called()
1238+
# Non-tablet path with replicas: exclusion set should contain
1239+
# the replicas that were already yielded
1240+
exc_call = child_policy.make_query_plan_with_exclusion.call_args
1241+
excluded_hosts = (
1242+
exc_call[0][2]
1243+
if len(exc_call[0]) > 2
1244+
else exc_call[1].get("excluded", set())
1245+
)
1246+
assert set(replicas).issubset(excluded_hosts), (
1247+
"Exclusion set should contain the yielded replicas, "
1248+
"got %s, expected superset of %s" % (excluded_hosts, set(replicas))
1249+
)
12391250
else:
12401251
child_policy.make_query_plan.assert_called_once_with(keyspace, query)
12411252
assert patched_shuffle.call_count == 1

0 commit comments

Comments
 (0)