Skip to content

Commit ef97cd4

Browse files
authored
Merge pull request #521 from tisnik/lcore-653-better-code-coverate-for-requests-unit-tests
LCORE-653: better code coverage for Requests unit tests
2 parents 2ba31bd + a63ba20 commit ef97cd4

File tree

3 files changed

+31
-0
lines changed

3 files changed

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