diff --git a/tests/unit/models/config/test_cors.py b/tests/unit/models/config/test_cors.py index ab79f02f..f032d9e6 100644 --- a/tests/unit/models/config/test_cors.py +++ b/tests/unit/models/config/test_cors.py @@ -6,7 +6,17 @@ def test_cors_default_configuration() -> None: - """Test the CORS configuration.""" + """Test the CORS configuration. + + Verify that a default CORSConfiguration instance has the expected default + values. + + Asserts that: + - allow_origins is ["*"] + - allow_credentials is False + - allow_methods is ["*"] + - allow_headers is ["*"] + """ cfg = CORSConfiguration() assert cfg is not None assert cfg.allow_origins == ["*"] @@ -46,7 +56,15 @@ def test_cors_custom_configuration_v2() -> None: def test_cors_custom_configuration_v3() -> None: - """Test the CORS configuration.""" + """Test the CORS configuration. + + Verify that CORSConfiguration accepts a wildcard origin when credentials + are disabled and preserves provided methods and headers. + + Creates a CORSConfiguration with allow_origins ["*"], allow_credentials + False, and explicit allow_methods and allow_headers, then asserts the + instance exists and its attributes match the provided values. + """ cfg = CORSConfiguration( allow_origins=["*"], allow_credentials=False, @@ -61,7 +79,15 @@ def test_cors_custom_configuration_v3() -> None: def test_cors_improper_configuration() -> None: - """Test the CORS configuration.""" + """Test the CORS configuration. + + Verify that constructing CORSConfiguration with a wildcard origin and + credentials enabled raises a ValueError. + + Asserts the raised ValueError contains the message that `allow_credentials` + cannot be true when `allow_origins` contains the '*' wildcard and advises + using explicit origins or disabling credentials. + """ expected = ( "Value error, Invalid CORS configuration: " + "allow_credentials can not be set to true when allow origins contains the '\\*' wildcard." diff --git a/tests/unit/models/config/test_customization.py b/tests/unit/models/config/test_customization.py index d3a5fa22..0b6f2f19 100644 --- a/tests/unit/models/config/test_customization.py +++ b/tests/unit/models/config/test_customization.py @@ -9,7 +9,24 @@ def test_service_customization(subtests: SubTests) -> None: - """Check the service customization class.""" + """Check the service customization class. + + Run subtests validating Customization model loading and disable-flag behavior. + + Performs three subtests: + - "System prompt is enabled": verifies defaults + (disable_query_system_prompt is False; system_prompt_path and + system_prompt are None). + - "System prompt is disabled": verifies disable_query_system_prompt is True + and prompt fields remain None. + - "Disabled overrides provided path, but the prompt is still loaded": + verifies that providing a system_prompt_path while + disable_query_system_prompt is True still loads the prompt content, and + the disable flag remains True. + + Parameters: + subtests (SubTests): Pytest SubTests context used to group related assertions. + """ with subtests.test(msg="System prompt is enabled"): c = Customization() assert c is not None diff --git a/tests/unit/models/config/test_database_configuration.py b/tests/unit/models/config/test_database_configuration.py index f26e8df1..4c28b338 100644 --- a/tests/unit/models/config/test_database_configuration.py +++ b/tests/unit/models/config/test_database_configuration.py @@ -65,7 +65,18 @@ def test_no_databases_configuration() -> None: def test_two_databases_configuration() -> None: - """Test if two databases configuration is checked.""" + """Test if two databases configuration is checked. + + Verify that constructing DatabaseConfiguration with both PostgreSQL and + SQLite configurations raises a validation error. + + Asserts that passing both `postgres` and `sqlite` to DatabaseConfiguration + triggers a `ValidationError` with message "Only one database configuration + can be provided". + + Raises: + ValidationError: If more than one database configuration is provided. + """ d1 = PostgreSQLDatabaseConfiguration(db="db", user="user", password="password") d2 = SQLiteDatabaseConfiguration(db_path="foo_bar_baz") with pytest.raises( diff --git a/tests/unit/models/config/test_postgresql_database_configuration.py b/tests/unit/models/config/test_postgresql_database_configuration.py index b25a7405..ea655cf4 100644 --- a/tests/unit/models/config/test_postgresql_database_configuration.py +++ b/tests/unit/models/config/test_postgresql_database_configuration.py @@ -50,7 +50,15 @@ def test_postgresql_database_configuration_namespace_specification() -> None: def test_postgresql_database_configuration_port_setting(subtests: SubTests) -> None: - """Test the PostgreSQLDatabaseConfiguration model.""" + """Test the PostgreSQLDatabaseConfiguration model. + + Validate port handling of PostgreSQLDatabaseConfiguration. + + Checks three scenarios: + - A valid explicit port (1234) is preserved on the model. + - A negative port raises ValidationError with message "Input should be greater than 0". + - A port >= 65536 raises ValueError with message "Port value should be less than 65536". + """ with subtests.test(msg="Correct port value"): c = PostgreSQLDatabaseConfiguration( db="db", user="user", password="password", port=1234 @@ -72,7 +80,18 @@ def test_postgresql_database_configuration_port_setting(subtests: SubTests) -> N def test_postgresql_database_configuration_ca_cert_path(subtests: SubTests) -> None: - """Test the PostgreSQLDatabaseConfiguration model.""" + """Test the PostgreSQLDatabaseConfiguration model. + + Validate ca_cert_path handling in PostgreSQLDatabaseConfiguration. + + Verifies two behaviors using subtests: + - When `ca_cert_path` points to an existing file, the value is preserved on the model. + - When `ca_cert_path` points to a non-existent path, a ValidationError is + raised with the message "Path does not point to a file". + + Parameters: + subtests (SubTests): Test helper providing subtest contexts. + """ with subtests.test(msg="Path exists"): c = PostgreSQLDatabaseConfiguration( db="db", diff --git a/tests/unit/models/config/test_quota_limiter_config.py b/tests/unit/models/config/test_quota_limiter_config.py index b704ebf0..e5b640e1 100644 --- a/tests/unit/models/config/test_quota_limiter_config.py +++ b/tests/unit/models/config/test_quota_limiter_config.py @@ -23,7 +23,12 @@ def test_quota_limiter_configuration() -> None: def test_quota_limiter_configuration_improper_value_1() -> None: - """Test the default configuration.""" + """Test the default configuration. + + Verify that constructing a QuotaLimiterConfiguration with a negative + `initial_quota` raises a ValueError with message "Input should be greater + than or equal to 0". + """ with pytest.raises(ValueError, match="Input should be greater than or equal to 0"): _ = QuotaLimiterConfiguration( type="cluster_limiter", @@ -35,7 +40,14 @@ def test_quota_limiter_configuration_improper_value_1() -> None: def test_quota_limiter_configuration_improper_value_2() -> None: - """Test the default configuration.""" + """Test the default configuration. + + Verify that providing a negative `quota_increase` raises a ValueError. + + Asserts that constructing a QuotaLimiterConfiguration with `quota_increase` + less than zero raises a ValueError with the message "Input should be + greater than or equal to 0". + """ with pytest.raises(ValueError, match="Input should be greater than or equal to 0"): _ = QuotaLimiterConfiguration( type="cluster_limiter", @@ -47,7 +59,14 @@ def test_quota_limiter_configuration_improper_value_2() -> None: def test_quota_limiter_configuration_improper_value_3() -> None: - """Test the default configuration.""" + """Test the default configuration. + + Check that constructing QuotaLimiterConfiguration with an invalid `type` + raises a ValueError with the expected message. + + Raises: + ValueError: if `type` is not 'user_limiter' or 'cluster_limiter'. + """ with pytest.raises( ValueError, match="Input should be 'user_limiter' or 'cluster_limiter'" ):