Skip to content

Commit 4b82bf1

Browse files
authored
fix: standardise test comments (#15)
1 parent 55d621a commit 4b82bf1

File tree

8 files changed

+56
-15
lines changed

8 files changed

+56
-15
lines changed

tests/test_aigw_input.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
def test_json_object_hook_parses():
19+
"""Test that RequestInput.model_validate_json correctly parses valid JSON input."""
1920
input_json = json.dumps({"messages": [{"content": CONTENT_STRING}]})
2021

2122
parsed_input = RequestInput.model_validate_json(input_json)
@@ -27,6 +28,7 @@ def test_json_object_hook_parses():
2728

2829

2930
def test_json_object_hook_allows_role():
31+
"""Test that RequestInput.model_validate_json correctly handles input with a specific role."""
3032
input_json = json.dumps(
3133
{
3234
"messages": [
@@ -47,6 +49,7 @@ def test_json_object_hook_allows_role():
4749

4850

4951
def test_json_object_hook_allows_arbitrary_role():
52+
"""Test that RequestInput.model_validate_json accepts arbitrary role values."""
5053
CUSTOM_ROLE = "friend"
5154
input_json = json.dumps(
5255
{
@@ -68,6 +71,7 @@ def test_json_object_hook_allows_arbitrary_role():
6871

6972

7073
def test_json_object_invalid():
74+
"""Test that RequestInput.model_validate_json raises a ValidationError for invalid JSON."""
7175
input_json = json.dumps({"messages": [{"content": CONTENT_STRING}]})[1:]
7276

7377
with pytest.raises(ValidationError):

tests/test_aigw_response.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
def test_json_object_hook_parses():
18+
"""Test that ResponseOutput.model_validate_json correctly parses valid JSON response."""
1819
response_json = json.dumps(
1920
{
2021
"choices": [

tests/test_multipart_response.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@pytest.mark.usefixtures("class_data_loader")
3636
class MultipartResponseTest(unittest.IsolatedAsyncioTestCase):
3737
def test_consequence_invalid_status_code(self):
38-
"""Verify that the status code of 4xx send to MultipartResponse raises."""
38+
"""Verify that an invalid HTTP status code (outside the valid range) sent to MultipartResponse raises a ValueError."""
3939
metadata = {
4040
"user_id": "1234",
4141
"processor_result": {"processor": "testing"},
@@ -52,7 +52,7 @@ def test_consequence_invalid_status_code(self):
5252
self.assertIn("Invalid HTTP status code", err.value.args)
5353

5454
def test_consequence_undefined_metadata(self):
55-
"""Verify, as far as render_multipart is, that a default metadata raises."""
55+
"""Verify that creating a MultipartResponse without metadata raises a ValueError."""
5656

5757
with pytest.raises(ValueError) as err:
5858
# noinspection PyTypeChecker

tests/test_processor.py

Lines changed: 42 additions & 12 deletions
Large diffs are not rendered by default.

tests/test_processor_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_routes_as_json():
108108

109109

110110
def test_list_extensions():
111-
"""Run through the provided list extensions."""
111+
"""Verify that ProcessorRoutes implements list-like behaviors such as iteration, indexing, length, membership testing, copying, and equality comparison."""
112112
processor_routes = fake_processor_routes()
113113
assert (
114114
vanilla_order := tuple([proc for proc in iter(processor_routes)])

tests/test_result.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
def test_prompt_not_allowed_with_response():
16+
"""Test that modified_prompt and modified_response cannot be used together in a Result."""
1617
with pytest.raises(
1718
ValueError,
1819
match="modified_prompt and modified_response are mutually exlusive",

tests/test_sysinfo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
def test_init():
14+
"""Test that SysInfo initializes correctly with service name and version."""
1415
sys_info = SysInfo(service_name="service_name", service_version="1.0.0")
1516
assert isinstance(sys_info, SysInfo)
1617
assert "service.name" in sys_info
@@ -20,6 +21,7 @@ def test_init():
2021

2122

2223
def test_init_no_version():
24+
"""Test that SysInfo initializes correctly with only service name and no version."""
2325
sys_info = SysInfo(service_name="service_name", service_version=None)
2426
assert isinstance(sys_info, SysInfo)
2527
assert "service.name" in sys_info
@@ -28,6 +30,7 @@ def test_init_no_version():
2830

2931

3032
def test_sysinfo_is_immutable():
33+
"""Test that SysInfo objects are immutable and cannot be modified after creation."""
3134
with pytest.raises(TypeError):
3235
sys_info = SysInfo(service_name="service_name", service_version=None)
3336
sys_info["service_name"] = "service_name"

tests/test_tags.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
def test_tags_init():
15+
"""Test that Tags initializes correctly with various valid inputs and raises appropriate errors for invalid inputs."""
1516
assert isinstance(Tags(), Tags)
1617
assert isinstance(Tags({}), Tags)
1718
assert isinstance(Tags({"a": ["b"]}), Tags)
@@ -29,6 +30,7 @@ def check_arg_error(arg):
2930

3031

3132
def test_tags_modify():
33+
"""Test that Tags can be modified through add_tag, remove_tag, and remove_key operations."""
3234
tag = Tags({"a": ["b"]})
3335
tag.add_tag("c", "d", "e") # First arg is a tag name.
3436

0 commit comments

Comments
 (0)