Repository navigation
test: add unit tests for dict_merge, merge_result and list_keys_to_dict - #4290
Conversation
petyaslavova
left a comment
There was a problem hiding this comment.
Hey @eeshsaxena, thank you for your contribution!
Thanks for resending this rebased - it applies cleanly and the shape matches what we asked for on the sibling PRs (tests in tests/test_utils.py, one fixed_client-marked class per helper). I checked the assertions against redis/utils.py and they all hold, and the fixed-clients CI job passes. The four failing matrix jobs are the hybrid-search timeout test and PyPy setup issues, both of which are also flaky on master, so they are unrelated to this change.
Two entirely optional notes, not blockers: test_returns_a_list is already implied by the flatten/dedupe test, and merge_result("CMD", {}) would be a slightly more interesting empty case than {"node1": []}. I'll re-run CI on the current head so we have a fresh run against our current Redis version, and then get this merged.
Re-opening #4178, which I'd closed to resend it rebased cleanly.
These three pure helpers in redis.utils, used by the cluster client, still
have no direct test coverage on master:
Tests live in tests/test_utils.py with the fixed_client marker, matching the
convention from the sibling PRs. Rebased on current master, ruff clean, all
tests green.
Note
Low Risk
Test-only changes with no production code or runtime behavior modified.
Overview
Adds direct unit test coverage in
tests/test_utils.pyfor three cluster-related helpers inredis.utilsthat previously had no dedicated tests.TestDictMergeexercises shallow merge of multiple dicts, later-key precedence, empty variadic calls, and non-mutation of inputs.TestMergeResultchecks flattening per-node list values into one deduplicated list (and empty-node behavior).TestListKeysToDictverifies each command name maps to the same callback viadict.fromkeys-style behavior.All new cases use
@pytest.mark.fixed_client, consistent with the rest of the file.Reviewed by Cursor Bugbot for commit 164eda3. Bugbot is set up for automated code reviews on this repo. Configure here.