refactor: improve config loader validation with Pydantic schemas
- Replace manual field type validation with Pydantic model schemas - Add pydantic>=2.0 as core dependency - Fix sync wrapper in decorator to properly handle rate limiting - Update pyright settings for stricter type checking - Fix repository URL in pyproject.toml - Remove unused main.py - Update test assertions for new validation error format
This commit is contained in:
@@ -365,7 +365,7 @@ class TestConfigLoaderValidation:
|
||||
"FASTAPI_TRAFFIC_RATE_LIMIT_ALGORITHM": "invalid_algorithm",
|
||||
}
|
||||
|
||||
with pytest.raises(ConfigurationError, match="Cannot parse value"):
|
||||
with pytest.raises(ConfigurationError):
|
||||
loader.load_rate_limit_config_from_env(env_vars)
|
||||
|
||||
def test_invalid_int_value(self, loader: ConfigLoader) -> None:
|
||||
@@ -374,7 +374,7 @@ class TestConfigLoaderValidation:
|
||||
"FASTAPI_TRAFFIC_RATE_LIMIT_LIMIT": "not_a_number",
|
||||
}
|
||||
|
||||
with pytest.raises(ConfigurationError, match="Cannot parse value"):
|
||||
with pytest.raises(ConfigurationError):
|
||||
loader.load_rate_limit_config_from_env(env_vars)
|
||||
|
||||
def test_invalid_float_value(self, loader: ConfigLoader) -> None:
|
||||
@@ -384,7 +384,7 @@ class TestConfigLoaderValidation:
|
||||
"FASTAPI_TRAFFIC_RATE_LIMIT_WINDOW_SIZE": "not_a_float",
|
||||
}
|
||||
|
||||
with pytest.raises(ConfigurationError, match="Cannot parse value"):
|
||||
with pytest.raises(ConfigurationError):
|
||||
loader.load_rate_limit_config_from_env(env_vars)
|
||||
|
||||
def test_unknown_field(self, loader: ConfigLoader, temp_dir: Path) -> None:
|
||||
@@ -411,7 +411,7 @@ class TestConfigLoaderValidation:
|
||||
config_data = {"limit": "not_an_int"}
|
||||
json_file.write_text(json.dumps(config_data))
|
||||
|
||||
with pytest.raises(ConfigurationError, match="Cannot parse value"):
|
||||
with pytest.raises(ConfigurationError):
|
||||
loader.load_rate_limit_config_from_json(json_file)
|
||||
|
||||
def test_bool_parsing_variations(self, loader: ConfigLoader) -> None:
|
||||
|
||||
Reference in New Issue
Block a user