Repository navigation
test(nodes): the Elasticsearch store test restores the package attribute it binds - #2915
Conversation
…ute it binds Importing nodes.store_elasticsearch.elasticsearch_store inside patch.dict also sets it as an attribute of nodes.store_elasticsearch. patch.dict restores sys.modules on exit, not that attribute, so a later test reading it could get the module built on the stand-in elasticsearch. monkeypatch now restores it (CodeRabbit on #2912). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015nTVr6jfSFYm1GppxbjghP
🤖 Internal: Discord sync markerAuto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Save package attribute before import nodes/test/test_elasticsearch_credentials.py |
The test captures the existing elasticsearch_store attribute, using None if it is absent, before the import. |
Estimated code review effort: 1 (Trivial) | ~3 minutes
Change: Other
Possibly related PRs
- rocketride-org/rocketride-server#2912: Adds the Elasticsearch credential tests that this change updates.
Suggested labels: module:nodes, tests
Suggested reviewers: stepmikhaylov
Merge Risk: 
Minimal · up to aa909
-
The test cleanup preserves package state correctly and is safe to merge.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the test change: the Elasticsearch store test restores the package attribute that its import binds. The raw summary says the test now snapshots the existing
elasticsearch_storeattribute before the import and restores it afterward, so the title matches the main change. The title uses the conventionaltest(nodes):prefix and is 81 characters long, which is acceptable.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
asclearuc
left a comment
There was a problem hiding this comment.
Thanks @dk-rocketride — a precise test-isolation fix: patch.dict(sys.modules, ...) restores the module table but not the package attribute the import binds, and monkeypatch.setattr(..., raising=False) restores that attribute, or deletes it when it was absent.
Approve
No inline comments. I checked that importing nodes.store_elasticsearch outside the patch.dict block adds no new import side effect: the package __init__ only imports IEndpoint, IGlobal and IInstance, which the two earlier tests in this file already import through _iglobal.
Follow-up to #2912, from its CodeRabbit thread. I fixed it here, not on #2912: a commit there would have dismissed the approval.
test_the_elasticsearch_store_does_not_open_with_an_unfilled_keyimportsnodes.store_elasticsearch.elasticsearch_storeinsidepatch.dict(sys.modules, ...)with stand-inelasticsearchmodules. The import also binds the module as an attribute ofnodes.store_elasticsearch.patch.dictrestoressys.moduleson exit but not that attribute, so a later test that reads it (or a dottedmock.patchtarget) could get the stand-in-backed module.monkeypatchnow restores the attribute, or deletes it if it wasn't there.Test-only. The file's 5 tests pass in the current engine image.
🤖 Generated with Claude Code
https://claude.ai/code/session_015nTVr6jfSFYm1GppxbjghP
Summary by CodeRabbit