Skip to content

Commit 6e2c199

Browse files
authored
Merge pull request #750 from tisnik/lcore-740-type-hints-for-models-unit-tests
LCORE-740: type hints for models unit tests
2 parents 6b45ae4 + 744c75a commit 6e2c199

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

tests/unit/models/config/test_conversation_cache.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44

55
import pytest
6+
from pytest_subtests import SubTests
67

78
from pydantic import ValidationError
89

@@ -30,7 +31,7 @@ def test_conversation_cache_unknown_type() -> None:
3031
_ = ConversationCacheConfiguration(type="foo")
3132

3233

33-
def test_conversation_cache_correct_type_but_not_configured(subtests) -> None:
34+
def test_conversation_cache_correct_type_but_not_configured(subtests: SubTests) -> None:
3435
"""Check the test for cache type."""
3536
with subtests.test(msg="Memory cache"):
3637
with pytest.raises(
@@ -51,7 +52,7 @@ def test_conversation_cache_correct_type_but_not_configured(subtests) -> None:
5152
_ = ConversationCacheConfiguration(type=constants.CACHE_TYPE_POSTGRES)
5253

5354

54-
def test_conversation_cache_no_type_but_configured(subtests) -> None:
55+
def test_conversation_cache_no_type_but_configured(subtests: SubTests) -> None:
5556
"""Check the test for cache type."""
5657
m = "Conversation cache type must be set when backend configuration is provided"
5758

@@ -79,7 +80,7 @@ def test_conversation_cache_no_type_but_configured(subtests) -> None:
7980
_ = ConversationCacheConfiguration(postgres=d)
8081

8182

82-
def test_conversation_cache_multiple_configurations(subtests) -> None:
83+
def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None:
8384
"""Test how multiple configurations are handled."""
8485
d = PostgreSQLDatabaseConfiguration(
8586
db="db",

tests/unit/models/config/test_customization.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""Unit tests for Customization model."""
22

33
import pytest
4+
from pytest_subtests import SubTests
45

56
from pydantic import ValidationError
67

78
from models.config import Customization
89

910

10-
def test_service_customization(subtests) -> None:
11+
def test_service_customization(subtests: SubTests) -> None:
1112
"""Check the service customization class."""
1213
with subtests.test(msg="System prompt is enabled"):
1314
c = Customization()
@@ -43,7 +44,7 @@ def test_service_customization_wrong_system_prompt_path() -> None:
4344
_ = Customization(system_prompt_path="/path/does/not/exists")
4445

4546

46-
def test_service_customization_correct_system_prompt_path(subtests) -> None:
47+
def test_service_customization_correct_system_prompt_path(subtests: SubTests) -> None:
4748
"""Check the service customization class."""
4849
with subtests.test(msg="One line system prompt"):
4950
# pass a file containing system prompt

tests/unit/models/config/test_database_configuration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44

55
import pytest
6+
from pytest_subtests import SubTests
67

78
from pydantic import ValidationError
89

@@ -13,7 +14,7 @@
1314
)
1415

1516

16-
def test_database_configuration(subtests) -> None:
17+
def test_database_configuration(subtests: SubTests) -> None:
1718
"""Test the database configuration handling."""
1819
with subtests.test(msg="PostgreSQL"):
1920
d1 = PostgreSQLDatabaseConfiguration(

tests/unit/models/config/test_dump_configuration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424

2525

26-
def test_dump_configuration(tmp_path) -> None:
26+
def test_dump_configuration(tmp_path: Path) -> None:
2727
"""
2828
Test that the Configuration object can be serialized to a JSON file and
2929
that the resulting file contains all expected sections and values.
@@ -186,7 +186,7 @@ def test_dump_configuration(tmp_path) -> None:
186186
}
187187

188188

189-
def test_dump_configuration_with_one_mcp_server(tmp_path) -> None:
189+
def test_dump_configuration_with_one_mcp_server(tmp_path: Path) -> None:
190190
"""
191191
Verify that a configuration with a single MCP server can be
192192
serialized to JSON and that all expected fields and values are
@@ -234,7 +234,7 @@ def test_dump_configuration_with_one_mcp_server(tmp_path) -> None:
234234
]
235235

236236

237-
def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None:
237+
def test_dump_configuration_with_more_mcp_servers(tmp_path: Path) -> None:
238238
"""
239239
Test that a configuration with multiple MCP servers can be
240240
serialized to JSON and that all server entries are correctly
@@ -301,7 +301,7 @@ def test_dump_configuration_with_more_mcp_servers(tmp_path) -> None:
301301
]
302302

303303

304-
def test_dump_configuration_with_quota_limiters(tmp_path) -> None:
304+
def test_dump_configuration_with_quota_limiters(tmp_path: Path) -> None:
305305
"""
306306
Test that the Configuration object can be serialized to a JSON file and
307307
that the resulting file contains all expected sections and values.

tests/unit/models/config/test_postgresql_database_configuration.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44

55
import pytest
6+
from pytest_subtests import SubTests
67

78
from pydantic import ValidationError
89

@@ -29,7 +30,7 @@ def test_postgresql_database_configuration() -> None:
2930
assert c.ca_cert_path is None
3031

3132

32-
def test_postgresql_database_configuration_port_setting(subtests) -> None:
33+
def test_postgresql_database_configuration_port_setting(subtests: SubTests) -> None:
3334
"""Test the PostgreSQLDatabaseConfiguration model."""
3435
with subtests.test(msg="Correct port value"):
3536
c = PostgreSQLDatabaseConfiguration(
@@ -51,7 +52,7 @@ def test_postgresql_database_configuration_port_setting(subtests) -> None:
5152
)
5253

5354

54-
def test_postgresql_database_configuration_ca_cert_path(subtests) -> None:
55+
def test_postgresql_database_configuration_ca_cert_path(subtests: SubTests) -> None:
5556
"""Test the PostgreSQLDatabaseConfiguration model."""
5657
with subtests.test(msg="Path exists"):
5758
c = PostgreSQLDatabaseConfiguration(

tests/unit/models/requests/test_query_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_get_documents(self) -> None:
102102

103103
def test_get_documents_no_attachments(self) -> None:
104104
"""Test the get_documents method."""
105-
attachments = []
105+
attachments: list[Attachment] = []
106106
qr = QueryRequest(
107107
query="Tell me about Kubernetes",
108108
attachments=attachments,

0 commit comments

Comments
 (0)