diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 15:36:45 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 15:36:45 +0900 |
| commit | e5fc21f3c9c890c254c5f74412aa0b68c3863042 (patch) | |
| tree | 475f6ce445b9927c7c448ed3c3673c3d351e49ea /shared/tests/test_config_validation.py | |
| parent | be7dc5311328d5d4bcb16cd613bcc88c26eaffa2 (diff) | |
feat: add config validation, SecretStr for secrets, API security fields
Diffstat (limited to 'shared/tests/test_config_validation.py')
| -rw-r--r-- | shared/tests/test_config_validation.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/shared/tests/test_config_validation.py b/shared/tests/test_config_validation.py new file mode 100644 index 0000000..9376dc6 --- /dev/null +++ b/shared/tests/test_config_validation.py @@ -0,0 +1,29 @@ +"""Tests for config validation.""" + +import pytest +from pydantic import ValidationError + +from shared.config import Settings + + +class TestConfigValidation: + def test_valid_defaults(self): + settings = Settings() + assert settings.risk_max_position_size == 0.1 + + def test_invalid_position_size(self): + with pytest.raises(ValidationError, match="risk_max_position_size"): + Settings(risk_max_position_size=-0.1) + + def test_invalid_health_port(self): + with pytest.raises(ValidationError, match="health_port"): + Settings(health_port=80) + + def test_invalid_log_level(self): + with pytest.raises(ValidationError, match="log_level"): + Settings(log_level="INVALID") + + def test_secret_fields_masked(self): + settings = Settings(alpaca_api_key="my-secret-key") + assert "my-secret-key" not in repr(settings) + assert settings.alpaca_api_key.get_secret_value() == "my-secret-key" |
