|
3 | 3 | import pytest |
4 | 4 |
|
5 | 5 | from runtime_config_support import ( |
| 6 | + _resolve_non_negative_float_env, |
6 | 7 | _resolve_ratio_env, |
7 | 8 | _runtime_execution_window_trading_days_env, |
8 | 9 | load_platform_runtime_settings, |
@@ -72,6 +73,22 @@ def test_reserved_cash_ratio_rejects_invalid_env(monkeypatch): |
72 | 73 | _resolve_ratio_env("FIRSTRADE_RESERVED_CASH_RATIO", default=0.0) |
73 | 74 |
|
74 | 75 |
|
| 76 | +@pytest.mark.parametrize("raw_value", ["nan", "inf", "-inf"]) |
| 77 | +def test_reserved_cash_floor_rejects_non_finite_env(monkeypatch, raw_value): |
| 78 | + monkeypatch.setenv("FIRSTRADE_MIN_RESERVED_CASH_USD", raw_value) |
| 79 | + |
| 80 | + with pytest.raises(ValueError, match="FIRSTRADE_MIN_RESERVED_CASH_USD must be finite"): |
| 81 | + _resolve_non_negative_float_env("FIRSTRADE_MIN_RESERVED_CASH_USD", default=0.0) |
| 82 | + |
| 83 | + |
| 84 | +@pytest.mark.parametrize("raw_value", ["nan", "inf", "-inf"]) |
| 85 | +def test_reserved_cash_ratio_rejects_non_finite_env(monkeypatch, raw_value): |
| 86 | + monkeypatch.setenv("FIRSTRADE_RESERVED_CASH_RATIO", raw_value) |
| 87 | + |
| 88 | + with pytest.raises(ValueError, match="FIRSTRADE_RESERVED_CASH_RATIO must be finite"): |
| 89 | + _resolve_ratio_env("FIRSTRADE_RESERVED_CASH_RATIO", default=0.0) |
| 90 | + |
| 91 | + |
75 | 92 | @pytest.mark.parametrize("raw_value", ["0", "-1", "abc"]) |
76 | 93 | def test_runtime_execution_window_rejects_invalid_generic_env(monkeypatch, raw_value): |
77 | 94 | monkeypatch.setenv("FIRSTRADE_RUNTIME_EXECUTION_WINDOW_TRADING_DAYS", raw_value) |
|
0 commit comments