Skip to content

Commit ca8639b

Browse files
authored
Merge pull request lightspeed-core#946 from tisnik/updated-docstrings-in-models-responses
LCORE-1092: Updated docstrings in models/responses
2 parents 8bd7fc6 + 0cb17aa commit ca8639b

3 files changed

Lines changed: 49 additions & 6 deletions

File tree

tests/unit/models/responses/test_authorized_response.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ def test_constructor(self) -> None:
2121
assert ar.skip_userid_check is True
2222

2323
def test_constructor_fields_required(self) -> None:
24-
"""Test the AuthorizedResponse constructor."""
24+
"""Test the AuthorizedResponse constructor.
25+
26+
Verify that constructing AuthorizedResponse without required fields
27+
raises ValidationError.
28+
29+
Checks three cases where a ValidationError is expected:
30+
- no parameters provided
31+
- missing `user_id`
32+
- missing `username`
33+
"""
2534
with pytest.raises(ValidationError):
2635
# missing all parameters
2736
_ = AuthorizedResponse() # pyright: ignore

tests/unit/models/responses/test_error_responses.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,14 @@ def test_different_resource_types(self) -> None:
6161
)
6262

6363
def test_openapi_response(self) -> None:
64-
"""Test BadRequestResponse.openapi_response() method."""
64+
"""Test BadRequestResponse.openapi_response() method.
65+
66+
Verify that BadRequestResponse.openapi_response() produces an OpenAPI
67+
entry with the correct description, model reference, and JSON examples,
68+
and that the examples list matches the model schema's examples and
69+
contains a `conversation_id` example whose detail.response equals
70+
"Invalid conversation ID format".
71+
"""
6572
schema = BadRequestResponse.model_json_schema()
6673
model_examples = schema.get("examples", [])
6774
expected_count = len(model_examples)
@@ -86,7 +93,16 @@ def test_openapi_response(self) -> None:
8693
)
8794

8895
def test_openapi_response_with_explicit_examples(self) -> None:
89-
"""Test BadRequestResponse.openapi_response() with explicit examples."""
96+
"""Test BadRequestResponse.openapi_response() with explicit examples.
97+
98+
Verify BadRequestResponse.openapi_response returns only the specified
99+
example when explicit example labels are provided.
100+
101+
Asserts that calling
102+
BadRequestResponse.openapi_response(examples=["conversation_id"])
103+
produces application/json examples containing exactly one entry with
104+
the key "conversation_id".
105+
"""
90106
result = BadRequestResponse.openapi_response(examples=["conversation_id"])
91107
examples = result["content"]["application/json"]["examples"]
92108

@@ -204,7 +220,11 @@ def test_factory_endpoint(self) -> None:
204220
)
205221

206222
def test_factory_feedback_disabled(self) -> None:
207-
"""Test ForbiddenResponse.feedback_disabled() factory method."""
223+
"""Test ForbiddenResponse.feedback_disabled() factory method.
224+
225+
Verifies that ForbiddenResponse.feedback_disabled() produces a 403
226+
AbstractErrorResponse with the expected detail message and cause.
227+
"""
208228
response = ForbiddenResponse.feedback_disabled()
209229
assert isinstance(response, AbstractErrorResponse)
210230
assert response.status_code == status.HTTP_403_FORBIDDEN

tests/unit/models/responses/test_rag_chunk.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ def test_constructor_with_content_only(self) -> None:
1414
assert chunk.score is None
1515

1616
def test_constructor_with_all_fields(self) -> None:
17-
"""Test RAGChunk constructor with all fields."""
17+
"""Test RAGChunk constructor with all fields.
18+
19+
Verify that providing content, source, and score assigns those values
20+
to the RAGChunk instance.
21+
22+
Asserts that the chunk's `content`, `source`, and `score` fields equal
23+
the values passed to the constructor.
24+
"""
1825
chunk = RAGChunk(
1926
content="Kubernetes is an open-source container orchestration system",
2027
source="kubernetes-docs/overview.md",
@@ -66,7 +73,14 @@ def test_empty_content(self) -> None:
6673
assert chunk.score is None
6774

6875
def test_multiline_content(self) -> None:
69-
"""Test RAGChunk with multiline content."""
76+
"""Test RAGChunk with multiline content.
77+
78+
Verify that a RAGChunk preserves multiline content and stores the
79+
provided source and score.
80+
81+
Asserts that the chunk's `content` equals the original multiline
82+
string, `source` equals "docs/multiline.md", and `score` equals 0.88.
83+
"""
7084
multiline_content = """This is a multiline content
7185
that spans multiple lines
7286
and contains various information."""

0 commit comments

Comments
 (0)