From e288ab46bd19d6a8c14dee2e1db28b638ca4ee40 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 26 Jan 2026 09:14:46 +0100 Subject: [PATCH 1/4] Fixed issues found by Pyright in tests for A2a, Authentication, and ByokRag tests --- .../config/test_a2a_state_configuration.py | 23 ++- .../test_authentication_configuration.py | 140 +++++++++++++++--- tests/unit/models/config/test_byok_rag.py | 14 +- 3 files changed, 146 insertions(+), 31 deletions(-) diff --git a/tests/unit/models/config/test_a2a_state_configuration.py b/tests/unit/models/config/test_a2a_state_configuration.py index 3f2148180..52681f099 100644 --- a/tests/unit/models/config/test_a2a_state_configuration.py +++ b/tests/unit/models/config/test_a2a_state_configuration.py @@ -3,7 +3,9 @@ # pylint: disable=no-member import pytest -from pydantic import ValidationError +from pydantic import SecretStr, ValidationError + +import constants from models.config import ( A2AStateConfiguration, @@ -42,7 +44,11 @@ def test_postgres_configuration(self) -> None: port=5432, db="a2a_state", user="lightspeed", - password="secret", + password=SecretStr("secret"), + namespace="namespace", + ssl_mode=constants.POSTGRES_DEFAULT_SSL_MODE, + gss_encmode=constants.POSTGRES_DEFAULT_GSS_ENCMODE, + ca_cert_path=None, ) config = A2AStateConfiguration(postgres=postgres_config) @@ -52,6 +58,9 @@ def test_postgres_configuration(self) -> None: assert config.postgres.port == 5432 assert config.postgres.db == "a2a_state" assert config.config == postgres_config + assert config.postgres.namespace == "namespace" + assert config.postgres.ssl_mode == constants.POSTGRES_DEFAULT_SSL_MODE + assert config.postgres.gss_encmode == constants.POSTGRES_DEFAULT_GSS_ENCMODE def test_postgres_with_all_options(self) -> None: """Test PostgreSQL configuration with all options.""" @@ -60,14 +69,16 @@ def test_postgres_with_all_options(self) -> None: port=5433, db="lightspeed", user="admin", - password="secret123", + password=SecretStr("secret123"), namespace="a2a", ssl_mode="require", + gss_encmode=constants.POSTGRES_DEFAULT_GSS_ENCMODE, ca_cert_path=None, ) config = A2AStateConfiguration(postgres=postgres_config) assert config.storage_type == "postgres" + assert config.postgres is not None assert config.postgres.host == "postgres.example.com" assert config.postgres.port == 5433 assert config.postgres.namespace == "a2a" @@ -82,7 +93,11 @@ def test_both_sqlite_and_postgres_raises_error(self, tmp_path: str) -> None: port=5432, db="test", user="test", - password="test", + password=SecretStr("test"), + namespace="namespace", + ssl_mode=constants.POSTGRES_DEFAULT_SSL_MODE, + gss_encmode=constants.POSTGRES_DEFAULT_GSS_ENCMODE, + ca_cert_path=None, ) with pytest.raises(ValidationError) as exc_info: diff --git a/tests/unit/models/config/test_authentication_configuration.py b/tests/unit/models/config/test_authentication_configuration.py index aa9f0633b..d7ae357d5 100644 --- a/tests/unit/models/config/test_authentication_configuration.py +++ b/tests/unit/models/config/test_authentication_configuration.py @@ -4,7 +4,7 @@ import pytest -from pydantic import ValidationError, SecretStr +from pydantic import ValidationError, SecretStr, AnyHttpUrl from models.config import ( AuthenticationConfiguration, @@ -61,6 +61,7 @@ def test_authentication_configuration_rh_identity() -> None: k8s_ca_cert_path=None, k8s_cluster_api=None, rh_identity_config=RHIdentityConfiguration(required_entitlements=[]), + skip_for_health_probes=True, ) assert auth_config is not None assert auth_config.module == AUTH_MOD_RH_IDENTITY @@ -70,6 +71,7 @@ def test_authentication_configuration_rh_identity() -> None: assert auth_config.rh_identity_config is not None assert auth_config.rh_identity_configuration is auth_config.rh_identity_config assert auth_config.rh_identity_configuration.required_entitlements == [] + assert auth_config.skip_for_health_probes is True def test_authentication_configuration_rh_identity_default_value() -> None: @@ -80,7 +82,8 @@ def test_authentication_configuration_rh_identity_default_value() -> None: skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, - rh_identity_config=RHIdentityConfiguration(), + rh_identity_config=RHIdentityConfiguration(required_entitlements=None), + skip_for_health_probes=True, ) assert auth_config is not None assert auth_config.module == AUTH_MOD_RH_IDENTITY @@ -90,6 +93,7 @@ def test_authentication_configuration_rh_identity_default_value() -> None: assert auth_config.rh_identity_config is not None assert auth_config.rh_identity_configuration is auth_config.rh_identity_config assert auth_config.rh_identity_configuration.required_entitlements is None + assert auth_config.skip_for_health_probes is True def test_authentication_configuration_rh_identity_one_entitlement() -> None: @@ -101,6 +105,7 @@ def test_authentication_configuration_rh_identity_one_entitlement() -> None: k8s_ca_cert_path=None, k8s_cluster_api=None, rh_identity_config=RHIdentityConfiguration(required_entitlements=["foo"]), + skip_for_health_probes=True, ) assert auth_config is not None assert auth_config.module == AUTH_MOD_RH_IDENTITY @@ -110,6 +115,7 @@ def test_authentication_configuration_rh_identity_one_entitlement() -> None: assert auth_config.rh_identity_config is not None assert auth_config.rh_identity_configuration is auth_config.rh_identity_config assert auth_config.rh_identity_configuration.required_entitlements == ["foo"] + assert auth_config.skip_for_health_probes is True def test_authentication_configuration_rh_identity_more_entitlements() -> None: @@ -123,6 +129,7 @@ def test_authentication_configuration_rh_identity_more_entitlements() -> None: rh_identity_config=RHIdentityConfiguration( required_entitlements=["foo", "bar", "baz"] ), + skip_for_health_probes=True, ) assert auth_config is not None assert auth_config.module == AUTH_MOD_RH_IDENTITY @@ -136,6 +143,7 @@ def test_authentication_configuration_rh_identity_more_entitlements() -> None: "bar", "baz", ] + assert auth_config.skip_for_health_probes is True def test_authentication_configuration_rh_identity_but_insufficient_config() -> None: @@ -155,6 +163,7 @@ def test_authentication_configuration_rh_identity_but_insufficient_config() -> N skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, + skip_for_health_probes=True, ) @@ -166,7 +175,8 @@ def test_authentication_configuration_jwk_token() -> None: skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, - jwk_config=JwkConfiguration(url="http://foo.bar.baz"), + jwk_config=JwkConfiguration(url=AnyHttpUrl("http://foo.bar.baz")), + skip_for_health_probes=True, ) assert auth_config is not None assert auth_config.module == AUTH_MOD_JWK_TOKEN @@ -195,7 +205,8 @@ def test_authentication_configuration_jwk_token_but_insufficient_config() -> Non skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, - jwk_config=JwkConfiguration(), + jwk_config=JwkConfiguration(), # pyright: ignore[reportCallIssue] + skip_for_health_probes=True, ) @@ -211,6 +222,7 @@ def test_authentication_configuration_jwk_token_but_not_config() -> None: skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, + skip_for_health_probes=True, # no JwkConfiguration ) @@ -231,7 +243,8 @@ def test_authentication_configuration_jwk_broken_config() -> None: skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, - jwk_config=JwkConfiguration(url="http://foo.bar.baz"), + jwk_config=JwkConfiguration(url=AnyHttpUrl("http://foo.bar.baz")), + skip_for_health_probes=True, ) assert auth_config is not None @@ -256,6 +269,7 @@ def test_authentication_configuration_supported() -> None: skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, + skip_for_health_probes=True, ) assert auth_config is not None assert auth_config.module == AUTH_MOD_K8S @@ -272,6 +286,7 @@ def test_authentication_configuration_module_unsupported() -> None: skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, + skip_for_health_probes=True, ) @@ -280,15 +295,31 @@ def test_authentication_configuration_in_config_noop() -> None: # pylint: disable=no-member cfg = Configuration( name="test_name", - service=ServiceConfiguration(), + service=ServiceConfiguration( + host="localhost", + port=1234, + base_url="", + auth_enabled=False, + color_log=True, + access_log=True, + workers=1, + ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", + url="localhost", + api_key=SecretStr(""), ), user_data_collection=UserDataCollection( - feedback_enabled=False, feedback_storage=None + feedback_enabled=False, + feedback_storage=None, + transcripts_enabled=False, + transcripts_storage=None, ), mcp_servers=[], + authorization=None, + customization=None, + deployment_environment="", ) assert cfg.authentication is not None assert cfg.authentication.module == AUTH_MOD_NOOP @@ -302,22 +333,38 @@ def test_authentication_configuration_skip_readiness_probe() -> None: # pylint: disable=no-member cfg = Configuration( name="test_name", - service=ServiceConfiguration(), + service=ServiceConfiguration( + host="localhost", + port=1234, + base_url="", + auth_enabled=False, + color_log=True, + access_log=True, + workers=1, + ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", + url="localhost", + api_key=SecretStr(""), ), user_data_collection=UserDataCollection( - feedback_enabled=False, feedback_storage=None + feedback_enabled=False, + feedback_storage=None, + transcripts_enabled=False, + transcripts_storage=None, ), mcp_servers=[], authentication=AuthenticationConfiguration( module=AUTH_MOD_K8S, skip_tls_verification=True, skip_for_health_probes=True, - k8s_ca_cert_path="tests/configuration/server.crt", + k8s_ca_cert_path=Path("tests/configuration/server.crt"), k8s_cluster_api=None, ), + authorization=None, + customization=None, + deployment_environment="", ) assert cfg.authentication is not None assert cfg.authentication.module == AUTH_MOD_K8S @@ -332,21 +379,38 @@ def test_authentication_configuration_in_config_k8s() -> None: # pylint: disable=no-member cfg = Configuration( name="test_name", - service=ServiceConfiguration(), + service=ServiceConfiguration( + host="localhost", + port=1234, + base_url="", + auth_enabled=False, + color_log=True, + access_log=True, + workers=1, + ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", + url="localhost", + api_key=SecretStr(""), ), user_data_collection=UserDataCollection( - feedback_enabled=False, feedback_storage=None + feedback_enabled=False, + feedback_storage=None, + transcripts_enabled=False, + transcripts_storage=None, ), mcp_servers=[], authentication=AuthenticationConfiguration( module=AUTH_MOD_K8S, skip_tls_verification=True, - k8s_ca_cert_path="tests/configuration/server.crt", + k8s_ca_cert_path=Path("tests/configuration/server.crt"), k8s_cluster_api=None, + skip_for_health_probes=False, ), + authorization=None, + customization=None, + deployment_environment="", ) assert cfg.authentication is not None assert cfg.authentication.module == AUTH_MOD_K8S @@ -371,22 +435,39 @@ def test_authentication_configuration_in_config_rh_identity() -> None: # pylint: disable=no-member cfg = Configuration( name="test_name", - service=ServiceConfiguration(), + service=ServiceConfiguration( + host="localhost", + port=1234, + base_url="", + auth_enabled=False, + color_log=True, + access_log=True, + workers=1, + ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", + url="localhost", + api_key=SecretStr(""), ), user_data_collection=UserDataCollection( - feedback_enabled=False, feedback_storage=None + feedback_enabled=False, + feedback_storage=None, + transcripts_enabled=False, + transcripts_storage=None, ), mcp_servers=[], authentication=AuthenticationConfiguration( module=AUTH_MOD_RH_IDENTITY, skip_tls_verification=True, - k8s_ca_cert_path="tests/configuration/server.crt", + k8s_ca_cert_path=Path("tests/configuration/server.crt"), k8s_cluster_api=None, rh_identity_config=RHIdentityConfiguration(required_entitlements=[]), + skip_for_health_probes=False, ), + authorization=None, + customization=None, + deployment_environment="", ) assert cfg.authentication is not None assert cfg.authentication.module == AUTH_MOD_RH_IDENTITY @@ -400,22 +481,39 @@ def test_authentication_configuration_in_config_jwktoken() -> None: # pylint: disable=no-member cfg = Configuration( name="test_name", - service=ServiceConfiguration(), + service=ServiceConfiguration( + host="localhost", + port=1234, + base_url="", + auth_enabled=False, + color_log=True, + access_log=True, + workers=1, + ), llama_stack=LlamaStackConfiguration( use_as_library_client=True, library_client_config_path="tests/configuration/run.yaml", + url="localhost", + api_key=SecretStr(""), ), user_data_collection=UserDataCollection( - feedback_enabled=False, feedback_storage=None + feedback_enabled=False, + feedback_storage=None, + transcripts_enabled=False, + transcripts_storage=None, ), mcp_servers=[], authentication=AuthenticationConfiguration( module=AUTH_MOD_JWK_TOKEN, skip_tls_verification=True, - k8s_ca_cert_path="tests/configuration/server.crt", + k8s_ca_cert_path=Path("tests/configuration/server.crt"), k8s_cluster_api=None, - jwk_config=JwkConfiguration(url="http://foo.bar.baz"), + jwk_config=JwkConfiguration(url=AnyHttpUrl("http://foo.bar.baz")), + skip_for_health_probes=False, ), + authorization=None, + customization=None, + deployment_environment="", ) assert cfg.authentication is not None assert cfg.authentication.module == AUTH_MOD_JWK_TOKEN @@ -433,6 +531,7 @@ def test_authentication_configuration_api_token() -> None: k8s_ca_cert_path=None, k8s_cluster_api=None, api_key_config=APIKeyTokenConfiguration(api_key=SecretStr("my-api-key")), + skip_for_health_probes=True, ) assert auth_config is not None assert auth_config.module == AUTH_MOD_APIKEY_TOKEN @@ -461,4 +560,5 @@ def test_authentication_configuration_api_key_but_insufficient_config() -> None: skip_tls_verification=False, k8s_ca_cert_path=None, k8s_cluster_api=None, + skip_for_health_probes=True, ) diff --git a/tests/unit/models/config/test_byok_rag.py b/tests/unit/models/config/test_byok_rag.py index fed3e5062..d66373479 100644 --- a/tests/unit/models/config/test_byok_rag.py +++ b/tests/unit/models/config/test_byok_rag.py @@ -18,7 +18,7 @@ def test_byok_rag_configuration_default_values() -> None: """Test the ByokRag constructor.""" - byok_rag = ByokRag( + byok_rag = ByokRag( # pyright: ignore[reportCallIssue] rag_id="rag_id", vector_db_id="vector_db_id", db_path="tests/configuration/rag.txt", @@ -48,7 +48,7 @@ def test_byok_rag_configuration_nondefault_values() -> None: embedding_model="embedding_model", embedding_dimension=1024, vector_db_id="vector_db_id", - db_path="tests/configuration/rag.txt", + db_path=Path("tests/configuration/rag.txt"), ) assert byok_rag is not None assert byok_rag.rag_id == "rag_id" @@ -69,7 +69,7 @@ def test_byok_rag_configuration_wrong_dimension() -> None: embedding_model="embedding_model", embedding_dimension=-1024, vector_db_id="vector_db_id", - db_path="tests/configuration/rag.txt", + db_path=Path("tests/configuration/rag.txt"), ) @@ -85,7 +85,7 @@ def test_byok_rag_configuration_empty_rag_id() -> None: embedding_model="embedding_model", embedding_dimension=1024, vector_db_id="vector_db_id", - db_path="tests/configuration/rag.txt", + db_path=Path("tests/configuration/rag.txt"), ) @@ -108,7 +108,7 @@ def test_byok_rag_configuration_empty_rag_type() -> None: embedding_model="embedding_model", embedding_dimension=1024, vector_db_id="vector_db_id", - db_path="tests/configuration/rag.txt", + db_path=Path("tests/configuration/rag.txt"), ) @@ -124,7 +124,7 @@ def test_byok_rag_configuration_empty_embedding_model() -> None: embedding_model="", embedding_dimension=1024, vector_db_id="vector_db_id", - db_path="tests/configuration/rag.txt", + db_path=Path("tests/configuration/rag.txt"), ) @@ -140,5 +140,5 @@ def test_byok_rag_configuration_empty_vector_db_id() -> None: embedding_model="embedding_model", embedding_dimension=1024, vector_db_id="", - db_path="tests/configuration/rag.txt", + db_path=Path("tests/configuration/rag.txt"), ) From 41bceb767fbc4ea7c51be1e4c8ef4348834b766f Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 26 Jan 2026 09:14:46 +0100 Subject: [PATCH 2/4] Fixed issues found by Pyright in tests for ConversationHistory, ModelContextProtocolServer, and PostgresDatabaseConfiguration tests --- .../config/test_conversation_history.py | 52 +++++++++++-------- .../test_model_context_protocol_server.py | 10 ++-- .../test_postgresql_database_configuration.py | 16 +++--- 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/tests/unit/models/config/test_conversation_history.py b/tests/unit/models/config/test_conversation_history.py index 48731cb6f..b21c083cd 100644 --- a/tests/unit/models/config/test_conversation_history.py +++ b/tests/unit/models/config/test_conversation_history.py @@ -22,7 +22,7 @@ def test_conversation_cache_no_type_specified() -> None: Verify that a ConversationHistoryConfiguration created with no arguments has its type set to None. """ - c = ConversationHistoryConfiguration() + c = ConversationHistoryConfiguration() # pyright: ignore[reportCallIssue] assert c.type is None @@ -40,7 +40,9 @@ def test_conversation_cache_unknown_type() -> None: ValidationError, match="Input should be 'noop', 'memory', 'sqlite' or 'postgres'", ): - _ = ConversationHistoryConfiguration(type="foo") + _ = ConversationHistoryConfiguration( + type="foo" + ) # pyright: ignore[reportCallIssue] def test_conversation_cache_correct_type_but_not_configured(subtests: SubTests) -> None: @@ -57,19 +59,25 @@ def test_conversation_cache_correct_type_but_not_configured(subtests: SubTests) with pytest.raises( ValidationError, match="Memory cache is selected, but not configured" ): - _ = ConversationHistoryConfiguration(type=constants.CACHE_TYPE_MEMORY) + _ = ConversationHistoryConfiguration( + type=constants.CACHE_TYPE_MEMORY + ) # pyright: ignore[reportCallIssue] with subtests.test(msg="SQLite cache"): with pytest.raises( ValidationError, match="SQLite cache is selected, but not configured" ): - _ = ConversationHistoryConfiguration(type=constants.CACHE_TYPE_SQLITE) + _ = ConversationHistoryConfiguration( + type=constants.CACHE_TYPE_SQLITE + ) # pyright: ignore[reportCallIssue] with subtests.test(msg="SQLite cache"): with pytest.raises( ValidationError, match="PostgreSQL cache is selected, but not configured" ): - _ = ConversationHistoryConfiguration(type=constants.CACHE_TYPE_POSTGRES) + _ = ConversationHistoryConfiguration( + type=constants.CACHE_TYPE_POSTGRES + ) # pyright: ignore[reportCallIssue] def test_conversation_cache_no_type_but_configured(subtests: SubTests) -> None: @@ -89,13 +97,13 @@ def test_conversation_cache_no_type_but_configured(subtests: SubTests) -> None: with pytest.raises(ValidationError, match=m): _ = ConversationHistoryConfiguration( memory=InMemoryCacheConfig(max_entries=100) - ) + ) # pyright: ignore[reportCallIssue] with subtests.test(msg="SQLite cache"): with pytest.raises(ValidationError, match=m): _ = ConversationHistoryConfiguration( sqlite=SQLiteDatabaseConfiguration(db_path="path") - ) + ) # pyright: ignore[reportCallIssue] with subtests.test(msg="PostgreSQL cache"): d = PostgreSQLDatabaseConfiguration( @@ -104,9 +112,11 @@ def test_conversation_cache_no_type_but_configured(subtests: SubTests) -> None: password="password", port=1234, ca_cert_path=Path("tests/configuration/server.crt"), - ) + ) # pyright: ignore[reportCallIssue] with pytest.raises(ValidationError, match=m): - _ = ConversationHistoryConfiguration(postgres=d) + _ = ConversationHistoryConfiguration( + postgres=d + ) # pyright: ignore[reportCallIssue] def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None: @@ -117,7 +127,7 @@ def test_conversation_cache_multiple_configurations(subtests: SubTests) -> None: password="password", port=1234, ca_cert_path=Path("tests/configuration/server.crt"), - ) + ) # pyright: ignore[reportCallIssue] with subtests.test(msg="Memory cache"): with pytest.raises( @@ -157,7 +167,7 @@ def test_conversation_type_memory() -> None: """Test the memory conversation cache configuration.""" c = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(max_entries=100) - ) + ) # pyright: ignore[reportCallIssue] assert c.type == constants.CACHE_TYPE_MEMORY assert c.memory is not None assert c.sqlite is None @@ -180,14 +190,14 @@ def test_conversation_type_memory_wrong_config() -> None: with pytest.raises(ValidationError, match="Field required"): _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_MEMORY, - memory=InMemoryCacheConfig(), - ) + memory=InMemoryCacheConfig(), # pyright: ignore[reportCallIssue] + ) # pyright: ignore[reportCallIssue] with pytest.raises(ValidationError, match="Input should be greater than 0"): _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_MEMORY, memory=InMemoryCacheConfig(max_entries=-100), - ) + ) # pyright: ignore[reportCallIssue] def test_conversation_type_sqlite() -> None: @@ -195,7 +205,7 @@ def test_conversation_type_sqlite() -> None: c = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_SQLITE, sqlite=SQLiteDatabaseConfiguration(db_path="path"), - ) + ) # pyright: ignore[reportCallIssue] assert c.type == constants.CACHE_TYPE_SQLITE assert c.memory is None assert c.sqlite is not None @@ -216,8 +226,8 @@ def test_conversation_type_sqlite_wrong_config() -> None: with pytest.raises(ValidationError, match="Field required"): _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_SQLITE, - memory=SQLiteDatabaseConfiguration(), - ) + memory=SQLiteDatabaseConfiguration(), # pyright: ignore[reportCallIssue] + ) # pyright: ignore[reportCallIssue] def test_conversation_type_postgres() -> None: @@ -228,12 +238,12 @@ def test_conversation_type_postgres() -> None: password="password", port=1234, ca_cert_path=Path("tests/configuration/server.crt"), - ) + ) # pyright: ignore[reportCallIssue] c = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_POSTGRES, postgres=d, - ) + ) # pyright: ignore[reportCallIssue] assert c.type == constants.CACHE_TYPE_POSTGRES assert c.memory is None assert c.sqlite is None @@ -255,5 +265,5 @@ def test_conversation_type_postgres_wrong_config() -> None: with pytest.raises(ValidationError, match="Field required"): _ = ConversationHistoryConfiguration( type=constants.CACHE_TYPE_POSTGRES, - postgres=PostgreSQLDatabaseConfiguration(), - ) + postgres=PostgreSQLDatabaseConfiguration(), # pyright: ignore[reportCallIssue] + ) # pyright: ignore[reportCallIssue] diff --git a/tests/unit/models/config/test_model_context_protocol_server.py b/tests/unit/models/config/test_model_context_protocol_server.py index 3bc2f7b2a..3c8fb3853 100644 --- a/tests/unit/models/config/test_model_context_protocol_server.py +++ b/tests/unit/models/config/test_model_context_protocol_server.py @@ -45,13 +45,17 @@ def test_model_context_protocol_server_required_fields() -> None: """Test that ModelContextProtocolServer requires name and url.""" with pytest.raises(ValidationError): - ModelContextProtocolServer() # pyright: ignore + ModelContextProtocolServer() # pyright: ignore[reportCallIssue] with pytest.raises(ValidationError): - ModelContextProtocolServer(name="test-server") # pyright: ignore + ModelContextProtocolServer( + name="test-server" + ) # pyright: ignore[reportCallIssue] with pytest.raises(ValidationError): - ModelContextProtocolServer(url="http://localhost:8080") # pyright: ignore + ModelContextProtocolServer( + url="http://localhost:8080" + ) # pyright: ignore[reportCallIssue] def test_configuration_empty_mcp_servers() -> None: diff --git a/tests/unit/models/config/test_postgresql_database_configuration.py b/tests/unit/models/config/test_postgresql_database_configuration.py index ea655cf4e..b9206b6fb 100644 --- a/tests/unit/models/config/test_postgresql_database_configuration.py +++ b/tests/unit/models/config/test_postgresql_database_configuration.py @@ -18,7 +18,9 @@ def test_postgresql_database_configuration() -> None: """Test the PostgreSQLDatabaseConfiguration model.""" # pylint: disable=no-member - c = PostgreSQLDatabaseConfiguration(db="db", user="user", password="password") + c = PostgreSQLDatabaseConfiguration( + db="db", user="user", password="password" + ) # pyright: ignore[reportCallIssue] assert c is not None assert c.host == "localhost" assert c.port == 5432 @@ -36,7 +38,7 @@ def test_postgresql_database_configuration_namespace_specification() -> None: # pylint: disable=no-member c = PostgreSQLDatabaseConfiguration( db="db", user="user", password="password", namespace="foo" - ) + ) # pyright: ignore[reportCallIssue] assert c is not None assert c.host == "localhost" assert c.port == 5432 @@ -62,7 +64,7 @@ def test_postgresql_database_configuration_port_setting(subtests: SubTests) -> N with subtests.test(msg="Correct port value"): c = PostgreSQLDatabaseConfiguration( db="db", user="user", password="password", port=1234 - ) + ) # pyright: ignore[reportCallIssue] assert c is not None assert c.port == 1234 @@ -70,13 +72,13 @@ def test_postgresql_database_configuration_port_setting(subtests: SubTests) -> N with pytest.raises(ValidationError, match="Input should be greater than 0"): PostgreSQLDatabaseConfiguration( db="db", user="user", password="password", port=-1 - ) + ) # pyright: ignore[reportCallIssue] with subtests.test(msg="Too big port value"): with pytest.raises(ValueError, match="Port value should be less than 65536"): PostgreSQLDatabaseConfiguration( db="db", user="user", password="password", port=100000 - ) + ) # pyright: ignore[reportCallIssue] def test_postgresql_database_configuration_ca_cert_path(subtests: SubTests) -> None: @@ -99,7 +101,7 @@ def test_postgresql_database_configuration_ca_cert_path(subtests: SubTests) -> N password="password", port=1234, ca_cert_path=Path("tests/configuration/server.crt"), - ) + ) # pyright: ignore[reportCallIssue] assert c.ca_cert_path == Path("tests/configuration/server.crt") with subtests.test(msg="Path does not exist"): @@ -110,4 +112,4 @@ def test_postgresql_database_configuration_ca_cert_path(subtests: SubTests) -> N password="password", port=1234, ca_cert_path=Path("not a file"), - ) + ) # pyright: ignore[reportCallIssue] From 8e27af8a988d60328ef9f850986ebaeef7ba9ce0 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 26 Jan 2026 09:14:46 +0100 Subject: [PATCH 3/4] Fixed issues found by Pyright in tests for QuotaHandlersConfig, QuotaLimiterConfig, and QuotaSchedulerConfig tests --- .../config/test_quota_handlers_config.py | 6 ++++- .../config/test_quota_limiter_config.py | 2 +- .../config/test_quota_scheduler_config.py | 22 +++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/tests/unit/models/config/test_quota_handlers_config.py b/tests/unit/models/config/test_quota_handlers_config.py index 7d4f5a98a..beb8f7d32 100644 --- a/tests/unit/models/config/test_quota_handlers_config.py +++ b/tests/unit/models/config/test_quota_handlers_config.py @@ -9,7 +9,11 @@ def test_quota_handlers_configuration() -> None: sqlite=None, postgres=None, limiters=[], - scheduler=QuotaSchedulerConfiguration(period=10), + scheduler=QuotaSchedulerConfiguration( + database_reconnection_count=10, + database_reconnection_delay=60, + period=10, + ), enable_token_history=False, ) assert cfg is not None diff --git a/tests/unit/models/config/test_quota_limiter_config.py b/tests/unit/models/config/test_quota_limiter_config.py index e5b640e15..d899cdb41 100644 --- a/tests/unit/models/config/test_quota_limiter_config.py +++ b/tests/unit/models/config/test_quota_limiter_config.py @@ -71,7 +71,7 @@ def test_quota_limiter_configuration_improper_value_3() -> None: ValueError, match="Input should be 'user_limiter' or 'cluster_limiter'" ): _ = QuotaLimiterConfiguration( - type="unknown_limiter", + type="unknown_limiter", # pyright: ignore[reportArgumentType] name="cluster_monthly_limits", initial_quota=1, quota_increase=10, diff --git a/tests/unit/models/config/test_quota_scheduler_config.py b/tests/unit/models/config/test_quota_scheduler_config.py index d34f42287..0b925b9da 100644 --- a/tests/unit/models/config/test_quota_scheduler_config.py +++ b/tests/unit/models/config/test_quota_scheduler_config.py @@ -9,7 +9,7 @@ def test_quota_scheduler_default_configuration() -> None: """Test the default configuration.""" - cfg = QuotaSchedulerConfiguration() + cfg = QuotaSchedulerConfiguration() # pyright: ignore[reportCallIssue] assert cfg is not None # default value assert cfg.period == 1 @@ -39,34 +39,42 @@ def test_quota_scheduler_custom_configuration() -> None: def test_quota_scheduler_custom_configuration_zero_period() -> None: """Test that zero period value raises ValidationError.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - QuotaSchedulerConfiguration(period=0) + QuotaSchedulerConfiguration(period=0) # pyright: ignore[reportCallIssue] def test_quota_scheduler_custom_configuration_negative_period() -> None: """Test that negative period value raises ValidationError.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - QuotaSchedulerConfiguration(period=-10) + QuotaSchedulerConfiguration(period=-10) # pyright: ignore[reportCallIssue] def test_quota_scheduler_custom_configuration_zero_reconnection_count() -> None: """Test that zero database reconnection count value raises ValidationError.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - QuotaSchedulerConfiguration(database_reconnection_count=0) + QuotaSchedulerConfiguration( + database_reconnection_count=0 + ) # pyright: ignore[reportCallIssue] def test_quota_scheduler_custom_configuration_negative_reconnection_count() -> None: """Test that negative database reconnection count value raises ValidationError.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - QuotaSchedulerConfiguration(database_reconnection_count=-10) + QuotaSchedulerConfiguration( + database_reconnection_count=-10 + ) # pyright: ignore[reportCallIssue] def test_quota_scheduler_custom_configuration_zero_reconnection_delay() -> None: """Test that zero database reconnection delay value raises ValidationError.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - QuotaSchedulerConfiguration(database_reconnection_delay=0) + QuotaSchedulerConfiguration( + database_reconnection_delay=0 + ) # pyright: ignore[reportCallIssue] def test_quota_scheduler_custom_configuration_negative_reconnection_delay() -> None: """Test that negative database reconnection delay value raises ValidationError.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - QuotaSchedulerConfiguration(database_reconnection_delay=-10) + QuotaSchedulerConfiguration( + database_reconnection_delay=-10 + ) # pyright: ignore[reportCallIssue] From 6986a49e4ac84f0a546fea8c7a4e6a690785b723 Mon Sep 17 00:00:00 2001 From: Pavel Tisnovsky Date: Mon, 26 Jan 2026 09:14:46 +0100 Subject: [PATCH 4/4] Fixed issues found by Pyright in tests for ServiceConfiguration, SplunkConfiguration, TLSConfiguration, and UserDataCollection tests --- .../config/test_service_configuration.py | 10 +++---- .../config/test_splunk_configuration.py | 18 ++++++++----- .../models/config/test_tls_configuration.py | 9 ++++++- .../config/test_user_data_collection.py | 26 ++++++++++++++----- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/tests/unit/models/config/test_service_configuration.py b/tests/unit/models/config/test_service_configuration.py index 2a2f4563b..986424e48 100644 --- a/tests/unit/models/config/test_service_configuration.py +++ b/tests/unit/models/config/test_service_configuration.py @@ -12,7 +12,7 @@ def test_service_configuration_constructor() -> None: Verify that the ServiceConfiguration constructor sets default values for all fields. """ - s = ServiceConfiguration() + s = ServiceConfiguration() # pyright: ignore[reportCallIssue] assert s is not None assert s.host == "localhost" @@ -21,19 +21,19 @@ def test_service_configuration_constructor() -> None: assert s.workers == 1 assert s.color_log is True assert s.access_log is True - assert s.tls_config == TLSConfiguration() + assert s.tls_config == TLSConfiguration() # pyright: ignore[reportCallIssue] def test_service_configuration_port_value() -> None: """Test the ServiceConfiguration port value validation.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - ServiceConfiguration(port=-1) + ServiceConfiguration(port=-1) # pyright: ignore[reportCallIssue] with pytest.raises(ValueError, match="Port value should be less than 65536"): - ServiceConfiguration(port=100000) + ServiceConfiguration(port=100000) # pyright: ignore[reportCallIssue] def test_service_configuration_workers_value() -> None: """Test the ServiceConfiguration workers value validation.""" with pytest.raises(ValidationError, match="Input should be greater than 0"): - ServiceConfiguration(workers=-1) + ServiceConfiguration(workers=-1) # pyright: ignore[reportCallIssue] diff --git a/tests/unit/models/config/test_splunk_configuration.py b/tests/unit/models/config/test_splunk_configuration.py index 636821d27..585426c27 100644 --- a/tests/unit/models/config/test_splunk_configuration.py +++ b/tests/unit/models/config/test_splunk_configuration.py @@ -17,7 +17,7 @@ def token_file_fixture(tmp_path: Path) -> Path: def test_default_values() -> None: """Test default SplunkConfiguration has expected values.""" - cfg = SplunkConfiguration() + cfg = SplunkConfiguration() # pyright: ignore[reportCallIssue] assert cfg.enabled is False assert cfg.url is None assert cfg.token_path is None @@ -29,7 +29,7 @@ def test_default_values() -> None: def test_disabled_skips_validation() -> None: """Test that disabled Splunk config doesn't require other fields.""" - cfg = SplunkConfiguration(enabled=False) + cfg = SplunkConfiguration(enabled=False) # pyright: ignore[reportCallIssue] assert cfg.enabled is False assert cfg.url is None @@ -65,7 +65,7 @@ def test_enabled_missing_required_fields( url=url, token_path=token_file if has_token else None, index=index, - ) + ) # pyright: ignore[reportCallIssue] def test_valid_enabled_configuration(token_file: Path) -> None: @@ -91,17 +91,23 @@ def test_valid_enabled_configuration(token_file: Path) -> None: def test_custom_source() -> None: """Test custom source value is preserved.""" - cfg = SplunkConfiguration(enabled=False, source="custom-source") + cfg = SplunkConfiguration( + enabled=False, source="custom-source" + ) # pyright: ignore[reportCallIssue] assert cfg.source == "custom-source" def test_custom_timeout() -> None: """Test custom timeout value is preserved.""" - cfg = SplunkConfiguration(enabled=False, timeout=30) + cfg = SplunkConfiguration( + enabled=False, timeout=30 + ) # pyright: ignore[reportCallIssue] assert cfg.timeout == 30 def test_verify_ssl_disabled() -> None: """Test verify_ssl can be disabled.""" - cfg = SplunkConfiguration(enabled=False, verify_ssl=False) + cfg = SplunkConfiguration( + enabled=False, verify_ssl=False + ) # pyright: ignore[reportCallIssue] assert cfg.verify_ssl is False diff --git a/tests/unit/models/config/test_tls_configuration.py b/tests/unit/models/config/test_tls_configuration.py index 503ae4ea8..b9013123a 100644 --- a/tests/unit/models/config/test_tls_configuration.py +++ b/tests/unit/models/config/test_tls_configuration.py @@ -28,7 +28,14 @@ def test_tls_configuration_in_service_configuration() -> None: tls_certificate_path=Path("tests/configuration/server.crt"), tls_key_path=Path("tests/configuration/server.key"), tls_key_password=Path("tests/configuration/password"), - ) + ), + host="localhost", + base_url="", + port=1234, + color_log=True, + access_log=True, + workers=10, + auth_enabled=True, ) assert cfg is not None assert cfg.tls_config is not None diff --git a/tests/unit/models/config/test_user_data_collection.py b/tests/unit/models/config/test_user_data_collection.py index 36e56d2f0..28b89950c 100644 --- a/tests/unit/models/config/test_user_data_collection.py +++ b/tests/unit/models/config/test_user_data_collection.py @@ -9,7 +9,9 @@ def test_user_data_collection_feedback_enabled() -> None: """Test the UserDataCollection constructor for feedback.""" # correct configuration - cfg = UserDataCollection(feedback_enabled=False, feedback_storage=None) + cfg = UserDataCollection( + feedback_enabled=False, feedback_storage=None + ) # pyright: ignore[reportCallIssue] assert cfg is not None assert cfg.feedback_enabled is False assert cfg.feedback_storage is None @@ -22,14 +24,20 @@ def test_user_data_collection_feedback_disabled() -> None: ValueError, match="feedback_storage is required when feedback is enabled", ): - UserDataCollection(feedback_enabled=True, feedback_storage=None) + UserDataCollection( + feedback_enabled=True, feedback_storage=None + ) # pyright: ignore[reportCallIssue] def test_user_data_collection_transcripts_enabled() -> None: """Test the UserDataCollection constructor for transcripts.""" # correct configuration - cfg = UserDataCollection(transcripts_enabled=False, transcripts_storage=None) + cfg = UserDataCollection( + transcripts_enabled=False, transcripts_storage=None + ) # pyright: ignore[reportCallIssue] assert cfg is not None + assert cfg.transcripts_enabled is False + assert cfg.transcripts_storage is None def test_user_data_collection_transcripts_disabled() -> None: @@ -47,7 +55,9 @@ def test_user_data_collection_transcripts_disabled() -> None: ValueError, match="transcripts_storage is required when transcripts is enabled", ): - UserDataCollection(transcripts_enabled=True, transcripts_storage=None) + UserDataCollection( + transcripts_enabled=True, transcripts_storage=None + ) # pyright: ignore[reportCallIssue] def test_user_data_collection_wrong_directory_path() -> None: @@ -66,10 +76,14 @@ def test_user_data_collection_wrong_directory_path() -> None: InvalidConfigurationError, match="Check directory to store feedback '/root' is not writable", ): - _ = UserDataCollection(feedback_enabled=True, feedback_storage="/root") + _ = UserDataCollection( + feedback_enabled=True, feedback_storage="/root" + ) # pyright: ignore[reportCallIssue] with pytest.raises( InvalidConfigurationError, match="Check directory to store transcripts '/root' is not writable", ): - _ = UserDataCollection(transcripts_enabled=True, transcripts_storage="/root") + _ = UserDataCollection( + transcripts_enabled=True, transcripts_storage="/root" + ) # pyright: ignore[reportCallIssue]