Repository navigation
feat: add contract compliance scan handler tests [OMN-6844] - #130
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdds a new integration test module validating Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_handler_contract_compliance_scan.py`:
- Around line 93-110: The test fixture declares routing for a handler identity
(e.g., HandlerExample) but the provided handler is a bare function, so the
scanner cannot match the routing entry; update the test's handler_code in
test_handler_registered_in_routing_no_violations to define a class with the
routed name that implements handle (e.g., class HandlerExample: def handle(self,
data): ...) so the scanner resolves the identity, and make the same change for
the related fixture referenced at lines 114-115.
- Around line 80-85: node_code is written verbatim which preserves caller
indentation and can produce malformed/shifted source so the scanner misses
LOGIC_IN_NODE; change the assignment of node_py_content to apply textwrap.dedent
to node_code (e.g. node_py_content = textwrap.dedent(node_code) if node_code
else textwrap.dedent("""...""")) before calling (node_dir /
"node.py").write_text(...); make the same dedent change for the other
occurrences referenced around the node_py_content creation sites so all inserted
fixtures are normalized.
- Around line 242-249: The test constructs an absolute handler_path and passes
it into allowlisted_paths, which mismatches the scanner's canonical handler_path
format; instead, call cross_reference() first (the function under test) and use
the handler_path value it returns (from the results returned by cross_reference)
as the key for allowlisted_paths/ALLOWLISTED assertions so no path-normalization
mismatch occurs—apply this change where handler_path is built (the handler_path
variable usage) and at the other occurrence around lines 251–252 in the test.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 20c2cf40-7a45-40ac-a711-ef835a5b057c
📒 Files selected for processing (1)
tests/test_handler_contract_compliance_scan.py
- Fix compliance tests: use src/ layout so _infer_module_path resolves correctly, fix handler_routing YAML to match scanner's expected nested handler structure, fix allowlist path to use relative path - Fix node_code dedenting in test helper (was causing SyntaxError in ast.parse, silently hiding LOGIC_IN_NODE violations) - Fix version matrix tests: add git user config in test repos for CI runner compatibility (GitHub Actions lacks default git identity)
Summary
Test plan
pytest tests/test_handler_contract_compliance_scan.pySummary by CodeRabbit