Skip to content

fix: standardise test comments #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2025
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
4 changes: 4 additions & 0 deletions tests/test_aigw_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


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

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


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


def test_json_object_hook_allows_arbitrary_role():
"""Test that RequestInput.model_validate_json accepts arbitrary role values."""
CUSTOM_ROLE = "friend"
input_json = json.dumps(
{
Expand All @@ -68,6 +71,7 @@ def test_json_object_hook_allows_arbitrary_role():


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

with pytest.raises(ValidationError):
Expand Down
1 change: 1 addition & 0 deletions tests/test_aigw_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@


def test_json_object_hook_parses():
"""Test that ResponseOutput.model_validate_json correctly parses valid JSON response."""
response_json = json.dumps(
{
"choices": [
Expand Down
4 changes: 2 additions & 2 deletions tests/test_multipart_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@pytest.mark.usefixtures("class_data_loader")
class MultipartResponseTest(unittest.IsolatedAsyncioTestCase):
def test_consequence_invalid_status_code(self):
"""Verify that the status code of 4xx send to MultipartResponse raises."""
"""Verify that an invalid HTTP status code (outside the valid range) sent to MultipartResponse raises a ValueError."""
metadata = {
"user_id": "1234",
"processor_result": {"processor": "testing"},
Expand All @@ -52,7 +52,7 @@ def test_consequence_invalid_status_code(self):
self.assertIn("Invalid HTTP status code", err.value.args)

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

with pytest.raises(ValueError) as err:
# noinspection PyTypeChecker
Expand Down
54 changes: 42 additions & 12 deletions tests/test_processor.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/test_processor_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_routes_as_json():


def test_list_extensions():
"""Run through the provided list extensions."""
"""Verify that ProcessorRoutes implements list-like behaviors such as iteration, indexing, length, membership testing, copying, and equality comparison."""
processor_routes = fake_processor_routes()
assert (
vanilla_order := tuple([proc for proc in iter(processor_routes)])
Expand Down
1 change: 1 addition & 0 deletions tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


def test_prompt_not_allowed_with_response():
"""Test that modified_prompt and modified_response cannot be used together in a Result."""
with pytest.raises(
ValueError,
match="modified_prompt and modified_response are mutually exlusive",
Expand Down
3 changes: 3 additions & 0 deletions tests/test_sysinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


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


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


def test_sysinfo_is_immutable():
"""Test that SysInfo objects are immutable and cannot be modified after creation."""
with pytest.raises(TypeError):
sys_info = SysInfo(service_name="service_name", service_version=None)
sys_info["service_name"] = "service_name"
2 changes: 2 additions & 0 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@


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


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

Expand Down