Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/unit/models/requests/test_feedback_status_update_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Unit tests for FeedbackStatusUpdateRequest model."""

from models.requests import FeedbackStatusUpdateRequest


class TestFeedbackStatusUpdateRequest:
"""Test cases for the FeedbackStatusUpdateRequest model."""

def test_constructor(self) -> None:
"""Test the FeedbackStatusUpdateRequest constructor."""
fs = FeedbackStatusUpdateRequest(status=False)
assert fs.status is False

fs = FeedbackStatusUpdateRequest(status=True)
assert fs.status is True

def test_get_value(self) -> None:
"""Test the FeedbackStatusUpdateRequest.get_value method."""
fs = FeedbackStatusUpdateRequest(status=False)
assert fs.get_value() is False

fs = FeedbackStatusUpdateRequest(status=True)
assert fs.get_value() is True
5 changes: 5 additions & 0 deletions tests/unit/models/requests/test_query_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ def test_constructor(self) -> None:
assert qr.system_prompt is None
assert qr.attachments is 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'"):
_ = QueryRequest(query="Tell me about Kubernetes", conversation_id="xyzzy")
Comment on lines +25 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.


def test_with_attachments(self) -> None:
"""Test the QueryRequest with attachments."""
attachments = [
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/models/responses/test_authorized_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def test_constructor(self) -> None:

def test_constructor_fields_required(self) -> None:
"""Test the AuthorizedResponse constructor."""
with pytest.raises(ValidationError):
# missing all parameters
_ = AuthorizedResponse() # pyright: ignore

with pytest.raises(ValidationError):
# missing user_id parameter
Expand Down