Skip to content

test: add unit tests for dict_merge, merge_result and list_keys_to_dict - #4290

Merged
petyaslavova merged 8 commits into
redis:masterfrom
eeshsaxena:test/merge-utils
Sep 2, 2026
Merged

petyaslavova merged 8 commits into
redis:masterfrom
eeshsaxena:test/merge-utils

Conversation

@eeshsaxena

@eeshsaxena eeshsaxena commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • dict_merge(*dicts)
  • merge_result(command, res)
  • list_keys_to_dict(key_list, callback)

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.py for three cluster-related helpers in redis.utils that previously had no dedicated tests.

TestDictMerge exercises shallow merge of multiple dicts, later-key precedence, empty variadic calls, and non-mutation of inputs. TestMergeResult checks flattening per-node list values into one deduplicated list (and empty-node behavior). TestListKeysToDict verifies each command name maps to the same callback via dict.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.

@petyaslavova petyaslavova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label Aug 31, 2026

@petyaslavova petyaslavova left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@petyaslavova
petyaslavova merged commit 77b079a into redis:master Sep 2, 2026
368 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants