Skip to content

Commit 2dee7ff

Browse files
committed
LCORE-653: better code coverage for Requests unit tests
1 parent 2ba31bd commit 2dee7ff

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Unit tests for FeedbackStatusUpdateRequest model."""
2+
3+
4+
from models.requests import FeedbackStatusUpdateRequest
5+
6+
7+
class TestFeedbackStatusUpdateRequest:
8+
"""Test cases for the FeedbackStatusUpdateRequest model."""
9+
10+
def test_constructor(self) -> None:
11+
"""Test the FeedbackStatusUpdateRequest constructor."""
12+
fs = FeedbackStatusUpdateRequest(status=False)
13+
assert fs.status is False
14+
15+
fs = FeedbackStatusUpdateRequest(status=True)
16+
assert fs.status is True
17+
18+
def test_get_value(self) -> None:
19+
"""Test the FeedbackStatusUpdateRequest.get_value method."""
20+
fs = FeedbackStatusUpdateRequest(status=False)
21+
assert fs.get_value() is False
22+
23+
fs = FeedbackStatusUpdateRequest(status=True)
24+
assert fs.get_value() is True

tests/unit/models/requests/test_query_request.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ def test_constructor(self) -> None:
2222
assert qr.system_prompt is None
2323
assert qr.attachments is None
2424

25+
def test_constructor_wrong_conversation_id(self) -> None:
26+
"""Test the QueryRequest constructor with wrong conversation_id."""
27+
with pytest.raises(ValueError, match="Improper conversation ID 'xyzzy'"):
28+
_ = QueryRequest(query="Tell me about Kubernetes", conversation_id="xyzzy")
29+
2530
def test_with_attachments(self) -> None:
2631
"""Test the QueryRequest with attachments."""
2732
attachments = [

tests/unit/models/responses/test_authorized_response.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ def test_constructor(self) -> None:
2323

2424
def test_constructor_fields_required(self) -> None:
2525
"""Test the AuthorizedResponse constructor."""
26+
with pytest.raises(ValidationError):
27+
# missing all parameters
28+
_ = AuthorizedResponse() # pyright: ignore
2629

2730
with pytest.raises(ValidationError):
2831
# missing user_id parameter

0 commit comments

Comments
 (0)