Conversation
📝 WalkthroughWalkthroughThe PR adjusts HTTP content-type routing for three REST request-forwarder services to enable their ChangesREST Accept media type fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/imio/smartweb/core/tests/test_rest.py`:
- Around line 751-764: The failing line in
test_request_forwarder_ok_without_json_accept is too long: break the long
assertion into two shorter statements to keep under 88 chars; for example assign
the expected dict to a local variable (e.g. expected = {"status": "ok",
"service": service_name}) and then call self.assertEqual(resp.json(), expected).
Locate the code in the test_request_forwarder_ok_without_json_accept function
and replace the single long self.assertEqual(...) line with the two shorter
lines so line length rules are satisfied.
🪄 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: e73cef73-2444-4236-b487-88c93447d5cc
📒 Files selected for processing (3)
CHANGES.rstsrc/imio/smartweb/core/rest/configure.zcmlsrc/imio/smartweb/core/tests/test_rest.py
| def test_request_forwarder_ok_without_json_accept(self): | ||
| # passerelle's check_status sends `Accept: */*` (no application/json), | ||
| # so the endpoint must be registered for that media type too. | ||
| for endpoint, service_name in ( | ||
| ("@directory_request_forwarder", "directory"), | ||
| ("@events_request_forwarder", "events"), | ||
| ("@news_request_forwarder", "news"), | ||
| ): | ||
| session = RelativeSession(self.portal_url) | ||
| session.headers.pop("Accept", None) | ||
| resp = session.get(f"/{endpoint}/ok") | ||
| self.assertEqual(resp.status_code, 200) | ||
| self.assertEqual(resp.json(), {"status": "ok", "service": service_name}) | ||
| session.close() |
There was a problem hiding this comment.
Fix line length violation on line 763.
Line 763 exceeds the 88-character limit (89 characters). As per coding guidelines, Python line length must be 88 characters (black-compatible).
🔧 Suggested fix
session = RelativeSession(self.portal_url)
session.headers.pop("Accept", None)
resp = session.get(f"/{endpoint}/ok")
self.assertEqual(resp.status_code, 200)
- self.assertEqual(resp.json(), {"status": "ok", "service": service_name})
+ expected = {"status": "ok", "service": service_name}
+ self.assertEqual(resp.json(), expected)
session.close()📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def test_request_forwarder_ok_without_json_accept(self): | |
| # passerelle's check_status sends `Accept: */*` (no application/json), | |
| # so the endpoint must be registered for that media type too. | |
| for endpoint, service_name in ( | |
| ("@directory_request_forwarder", "directory"), | |
| ("@events_request_forwarder", "events"), | |
| ("@news_request_forwarder", "news"), | |
| ): | |
| session = RelativeSession(self.portal_url) | |
| session.headers.pop("Accept", None) | |
| resp = session.get(f"/{endpoint}/ok") | |
| self.assertEqual(resp.status_code, 200) | |
| self.assertEqual(resp.json(), {"status": "ok", "service": service_name}) | |
| session.close() | |
| def test_request_forwarder_ok_without_json_accept(self): | |
| # passerelle's check_status sends `Accept: */*` (no application/json), | |
| # so the endpoint must be registered for that media type too. | |
| for endpoint, service_name in ( | |
| ("`@directory_request_forwarder`", "directory"), | |
| ("`@events_request_forwarder`", "events"), | |
| ("`@news_request_forwarder`", "news"), | |
| ): | |
| session = RelativeSession(self.portal_url) | |
| session.headers.pop("Accept", None) | |
| resp = session.get(f"/{endpoint}/ok") | |
| self.assertEqual(resp.status_code, 200) | |
| expected = {"status": "ok", "service": service_name} | |
| self.assertEqual(resp.json(), expected) | |
| session.close() |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/imio/smartweb/core/tests/test_rest.py` around lines 751 - 764, The
failing line in test_request_forwarder_ok_without_json_accept is too long: break
the long assertion into two shorter statements to keep under 88 chars; for
example assign the expected dict to a local variable (e.g. expected = {"status":
"ok", "service": service_name}) and then call self.assertEqual(resp.json(),
expected). Locate the code in the test_request_forwarder_ok_without_json_accept
function and replace the single long self.assertEqual(...) line with the two
shorter lines so line length rules are satisfied.
Source: Coding guidelines
There was a problem hiding this comment.
we use ruff instead of black now
There was a problem hiding this comment.
@bsuttor, thanks for the clarification! I've noted that this project uses ruff instead of black for Python formatting.
✏️ Learnings added
Learnt from: bsuttor
Repo: IMIO/imio.smartweb.core PR: 85
File: src/imio/smartweb/core/tests/test_rest.py:751-764
Timestamp: 2026-06-09T13:51:59.137Z
Learning: In the imio.smartweb.core repository, ruff is used as the Python formatter/linter instead of black. When reviewing Python code style and line length compliance, reference ruff configuration rather than black.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
ref: KEYC-77
Summary by CodeRabbit
Bug Fixes
/ok) for directory, events, and news services to be reachable with any Accept header format, improving compatibility with external monitoring tools.Tests