From 8ecff3be951c6d92dd0802bd743a56729f286bfc Mon Sep 17 00:00:00 2001 From: kuse <3133746534@qq.com> Date: Wed, 30 Sep 2026 17:21:43 +0800 Subject: [PATCH] test(config): make refresh_skew rejection test load-bearing (#6080) test_refresh_skew_rejects_negative_and_boolean omitted the required token_url, so McpOAuthConfig(refresh_skew_seconds=-1) failed validation on the missing field alone -- deleting the ge=0 bound and the boolean validator would leave the test green. Pass token_url (the same URL the refresh_skew_seconds=0 boundary test uses) so only the guards can satisfy pytest.raises; verified by stripping both guards from extensions_config.py, which now fails exactly the two parametrized cases, and restoring them, which returns the suite to 42 passed. Also move SandboxOwnershipConfig up beside the other config imports and drop the redundant in-test `import pytest` (review nits on #6026). Generated-by: ZCode (GLM, coding agent) Co-authored-by: liwenjie200543 --- backend/tests/test_numeric_config_guards.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/backend/tests/test_numeric_config_guards.py b/backend/tests/test_numeric_config_guards.py index efe550b97e..ab1afe44d2 100644 --- a/backend/tests/test_numeric_config_guards.py +++ b/backend/tests/test_numeric_config_guards.py @@ -17,7 +17,7 @@ from deerflow.config.app_config import CircuitBreakerConfig from deerflow.config.extensions_config import McpOAuthConfig, McpServerConfig from deerflow.config.model_config import ModelConfig from deerflow.config.run_events_config import RunEventsConfig -from deerflow.config.sandbox_config import SandboxConfig +from deerflow.config.sandbox_config import SandboxConfig, SandboxOwnershipConfig from deerflow.config.summarization_config import SummarizationConfig @@ -54,7 +54,7 @@ class TestMcpTimeoutGuards: @pytest.mark.parametrize("bad", [-1, True]) def test_refresh_skew_rejects_negative_and_boolean(self, bad: int | bool) -> None: with pytest.raises(ValidationError): - McpOAuthConfig(refresh_skew_seconds=bad) + McpOAuthConfig(token_url="https://sso.example.org/token", refresh_skew_seconds=bad) class TestStreamChunkTimeoutGuard: @@ -102,10 +102,6 @@ class TestSiblingBoolRejection: """Same-class siblings with bounds but no boolean rejection, flagged in review.""" def test_sandbox_numeric_fields_reject_booleans(self) -> None: - import pytest - - from deerflow.config.sandbox_config import SandboxOwnershipConfig - with pytest.raises(ValidationError): SandboxConfig(use="local", replicas=True) with pytest.raises(ValidationError): @@ -128,8 +124,6 @@ class TestSiblingBoolRejection: SandboxOwnershipConfig(ttl_multiplier=True) def test_ownership_defaults_still_pass(self) -> None: - from deerflow.config.sandbox_config import SandboxOwnershipConfig - config = SandboxOwnershipConfig() assert config.renewal_interval_seconds == 30.0 assert config.ttl_multiplier == 4.0