-
Notifications
You must be signed in to change notification settings - Fork 55
LCORE-641: split unit tests for HTTP requests models #510
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-641: split unit tests for HTTP requests models #510
Conversation
WalkthroughAdds new unit tests for Attachment and QueryRequest models and simplifies FeedbackRequest tests to focus only on FeedbackRequest. The changes introduce constructor, attachment handling, provider/model validation, get_documents and media_type logging tests while removing unrelated suites from the FeedbackRequest file. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
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 |
92c0ef5 to
6f3e0ab
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: 0
🧹 Nitpick comments (2)
tests/unit/models/requests/test_attachment.py (2)
1-4: De-duplicate via parametrization and fix misnamed caseBoth tests validate the same constructor behavior; parametrize on content_type to reduce duplication and implicitly fix the “unknown_attachment_type” misnomer (it’s actually testing content_type).
Apply:
@@ -"""Unit tests for Attachment model.""" +"""Unit tests for Attachment model.""" -from models.requests import Attachment +from models.requests import Attachment +import pytest @@ - def test_constructor(self) -> None: - """Test the Attachment with custom values.""" - a = Attachment( - attachment_type="configuration", - content_type="application/yaml", - content="kind: Pod\n metadata:\n name: private-reg", - ) - assert a.attachment_type == "configuration" - assert a.content_type == "application/yaml" - assert a.content == "kind: Pod\n metadata:\n name: private-reg" + @pytest.mark.parametrize("content_type", ["application/yaml", "unknown/type"]) + def test_constructor(self, content_type: str) -> None: + """Attachment accepts any content_type; fields are preserved.""" + a = Attachment( + attachment_type="configuration", + content_type=content_type, + content="kind: Pod\n metadata:\n name: private-reg", + ) + assert a.attachment_type == "configuration" + assert a.content_type == content_type + assert a.content == "kind: Pod\n metadata:\n name: private-reg" @@ - def test_constructor_unknown_attachment_type(self) -> None: - """Test the Attachment with custom values.""" - # for now we allow any content type - a = Attachment( - attachment_type="configuration", - content_type="unknown/type", - content="kind: Pod\n metadata:\n name: private-reg", - ) - assert a.attachment_type == "configuration" - assert a.content_type == "unknown/type" - assert a.content == "kind: Pod\n metadata:\n name: private-reg"Also applies to: 9-30
1-4: Add a negative test for forbidden extra fields (pydantic model_config extra='forbid')Covers an important contract of Attachment: unexpected fields should raise ValidationError.
Apply:
@@ -from models.requests import Attachment +from models.requests import Attachment +from pydantic import ValidationError @@ class TestAttachment: @@ + def test_extra_fields_forbidden(self) -> None: + with pytest.raises(ValidationError): + Attachment( + attachment_type="log", + content_type="text/plain", + content="payload", + unexpected="boom", + )Also applies to: 31-31
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
tests/unit/models/requests/test_attachment.py(1 hunks)tests/unit/models/requests/test_feedback_request.py(1 hunks)tests/unit/models/requests/test_query_request.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- tests/unit/models/requests/test_query_request.py
- tests/unit/models/requests/test_feedback_request.py
🧰 Additional context used
🧬 Code graph analysis (1)
tests/unit/models/requests/test_attachment.py (1)
src/models/requests.py (1)
Attachment(15-69)
⏰ 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). (1)
- GitHub Check: build-pr
🔇 Additional comments (1)
tests/unit/models/requests/test_attachment.py (1)
9-18: Solid constructor happy-path coverageAsserts match the model fields and preserve exact content. Good baseline.
Description
LCORE-641: split unit tests for HTTP requests models
Type of change
Related Tickets & Documents
Summary by CodeRabbit