Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
playbook_dirfixture replacesPathwith a plain function that asserts on the exact string path; consider monkeypatching only the specificPath('/interface/playbooks')resolution (e.g., patching the constant or wrappingPath) to avoid coupling tests too tightly to the concrete implementation and to better mirror actualPathbehavior. - The
_reset_module_cachesautouse fixture directly manipulatesplaybooks.__dict__and private globals; to reduce brittleness against future refactors, you could centralize this reset logic in a small helper in the module under test and call that from the fixture instead of reaching into__dict__.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `playbook_dir` fixture replaces `Path` with a plain function that asserts on the exact string path; consider monkeypatching only the specific `Path('/interface/playbooks')` resolution (e.g., patching the constant or wrapping `Path`) to avoid coupling tests too tightly to the concrete implementation and to better mirror actual `Path` behavior.
- The `_reset_module_caches` autouse fixture directly manipulates `playbooks.__dict__` and private globals; to reduce brittleness against future refactors, you could centralize this reset logic in a small helper in the module under test and call that from the fixture instead of reaching into `__dict__`.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Covers the lazy YAML loader and module-level __getattr__ in osism/data/playbooks.py: multi-file merging into _MAP_ROLE2ENVIRONMENT, filename-stem mapping in _MAP_ROLE2RUNTIME, swallowing of yaml.YAMLError with a logged warning, cache short-circuit on re-entry, and the __getattr__ paths for MAP_ROLE2ENVIRONMENT, MAP_ROLE2RUNTIME, plus the AttributeError fallback. Module caches are reset via an autouse fixture so tests are order-independent. Closes #2196 AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Covers the lazy YAML loader and module-level getattr in osism/data/playbooks.py: multi-file merging into _MAP_ROLE2ENVIRONMENT, filename-stem mapping in _MAP_ROLE2RUNTIME, swallowing of yaml.YAMLError with a logged warning, cache short-circuit on re-entry, and the getattr paths for MAP_ROLE2ENVIRONMENT, MAP_ROLE2RUNTIME, plus the AttributeError fallback. Module caches are reset via an autouse fixture so tests are order-independent.
Closes #2196
AI-assisted: Claude Code