Spaces:
Running
Running
| import sys | |
| import os | |
| import pytest | |
| _this_dir = os.path.dirname(os.path.abspath(__file__)) | |
| sys.path.insert(0, _this_dir) | |
| sys.path.insert(0, os.path.dirname(_this_dir)) | |
| from config import AppConfig, ConfigError | |
| from pydantic import ValidationError | |
| def test_app_config_valid_bounds(): | |
| cfg = AppConfig(single_asset_min=0.0, single_asset_max=0.5, sector_limit=0.6) | |
| assert cfg.single_asset_min == 0.0 | |
| def test_app_config_invalid_bounds(): | |
| with pytest.raises(ConfigError, match="single_asset_min cannot be greater than single_asset_max"): | |
| AppConfig(single_asset_min=0.6, single_asset_max=0.5) | |
| def test_app_config_invalid_sector_limit(): | |
| with pytest.raises(ConfigError, match="sector_limit .* cannot be smaller than single_asset_max"): | |
| AppConfig(single_asset_max=0.5, sector_limit=0.4) | |
| def test_app_config_invalid_tax_rates(): | |
| with pytest.raises(ConfigError, match="Long-term tax rate is mathematically expected to be <= short-term tax rate"): | |
| AppConfig(tax_rate_lt=0.4, tax_rate_st=0.2) | |