-
Notifications
You must be signed in to change notification settings - Fork 55
LCORE-653: better code coverage for Requests unit tests #521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LCORE-653: better code coverage for Requests unit tests #521
Conversation
WalkthroughAdds new and expanded unit tests: introduces tests for FeedbackStatusUpdateRequest, adds a constructor error test for QueryRequest invalid conversation_id, and extends AuthorizedResponse tests to assert that constructing without required fields raises ValidationError. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
✨ Finishing Touches
🧪 Generate unit tests
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 |
bfe3d80 to
2dee7ff
Compare
2dee7ff to
a63ba20
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/unit/models/requests/test_feedback_status_update_request.py (1)
1-23: Optionally extend coverage for defaults and forbidden extrasConsider asserting the default and
extra="forbid"behavior.Add:
import pytest from pydantic import ValidationError def test_default_and_extra_fields() -> None: fs = FeedbackStatusUpdateRequest() assert fs.status is False with pytest.raises(ValidationError): FeedbackStatusUpdateRequest(status=True, unexpected="x")
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tests/unit/models/requests/test_feedback_status_update_request.py(1 hunks)tests/unit/models/requests/test_query_request.py(1 hunks)tests/unit/models/responses/test_authorized_response.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/unit/models/requests/test_feedback_status_update_request.py (1)
src/models/requests.py (2)
FeedbackStatusUpdateRequest(387-412)get_value(410-412)
tests/unit/models/responses/test_authorized_response.py (1)
src/models/responses.py (1)
AuthorizedResponse(304-340)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Pyright
- GitHub Check: build-pr
- GitHub Check: e2e_tests
🔇 Additional comments (2)
tests/unit/models/responses/test_authorized_response.py (1)
26-28: LGTM: Validates required fields via Pydantic correctlyAsserting
ValidationErrorfor missing params is appropriate here.tests/unit/models/requests/test_feedback_status_update_request.py (1)
1-23: Solid coverage for constructor and accessorTests cover both boolean states and getter; no issues spotted.
| def test_constructor_wrong_conversation_id(self) -> None: | ||
| """Test the QueryRequest constructor with wrong conversation_id.""" | ||
| with pytest.raises(ValueError, match="Improper conversation ID 'xyzzy'"): | ||
| _ = QueryRequest(query="Tell me about Kubernetes", conversation_id="xyzzy") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ValidationError instead of ValueError for Pydantic field validation
check_uuid is a Pydantic field_validator; raising ValueError there surfaces as pydantic.ValidationError at model init. This test will otherwise fail.
Apply this diff:
- def test_constructor_wrong_conversation_id(self) -> None:
+ def test_constructor_wrong_conversation_id(self) -> None:
"""Test the QueryRequest constructor with wrong conversation_id."""
- with pytest.raises(ValueError, match="Improper conversation ID 'xyzzy'"):
+ with pytest.raises(ValidationError, match="Improper conversation ID 'xyzzy'"):
_ = QueryRequest(query="Tell me about Kubernetes", conversation_id="xyzzy")Also add the missing import near the other imports:
from pydantic import ValidationError🤖 Prompt for AI Agents
In tests/unit/models/requests/test_query_request.py around lines 25 to 28, the
test currently expects a ValueError but the field validator in the Pydantic
model surfaces a pydantic.ValidationError at model initialization; change the
pytest.raises(ValueError, ...) to pytest.raises(ValidationError, ...) and ensure
you add the missing import from pydantic import ValidationError alongside the
other imports at the top of the file so the test asserts the correct exception
type.
Description
LCORE-653: better code coverage for Requests unit tests
Type of change
Related Tickets & Documents
Summary by CodeRabbit