|
1 | 1 | import json |
| 2 | +from decimal import Decimal |
2 | 3 | from pathlib import Path |
3 | 4 |
|
4 | 5 | import pytest |
@@ -275,6 +276,34 @@ def test_default_values() -> None: |
275 | 276 | assert config.test_pay_per_event is False |
276 | 277 |
|
277 | 278 |
|
| 279 | +def test_max_paid_dataset_items_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) -> None: |
| 280 | + """Test that max_paid_dataset_items=0 is not treated as falsy and converted to None.""" |
| 281 | + monkeypatch.setenv('ACTOR_MAX_PAID_DATASET_ITEMS', '0') |
| 282 | + config = ApifyConfiguration() |
| 283 | + assert config.max_paid_dataset_items == 0 |
| 284 | + |
| 285 | + |
| 286 | +def test_max_total_charge_usd_zero_is_preserved(monkeypatch: pytest.MonkeyPatch) -> None: |
| 287 | + """Test that max_total_charge_usd=0 is not treated as falsy and converted to None.""" |
| 288 | + monkeypatch.setenv('ACTOR_MAX_TOTAL_CHARGE_USD', '0') |
| 289 | + config = ApifyConfiguration() |
| 290 | + assert config.max_total_charge_usd == Decimal(0) |
| 291 | + |
| 292 | + |
| 293 | +def test_max_paid_dataset_items_empty_string_becomes_none(monkeypatch: pytest.MonkeyPatch) -> None: |
| 294 | + """Test that an empty env var for max_paid_dataset_items is converted to None.""" |
| 295 | + monkeypatch.setenv('ACTOR_MAX_PAID_DATASET_ITEMS', '') |
| 296 | + config = ApifyConfiguration() |
| 297 | + assert config.max_paid_dataset_items is None |
| 298 | + |
| 299 | + |
| 300 | +def test_max_total_charge_usd_empty_string_becomes_none(monkeypatch: pytest.MonkeyPatch) -> None: |
| 301 | + """Test that an empty env var for max_total_charge_usd is converted to None.""" |
| 302 | + monkeypatch.setenv('ACTOR_MAX_TOTAL_CHARGE_USD', '') |
| 303 | + config = ApifyConfiguration() |
| 304 | + assert config.max_total_charge_usd is None |
| 305 | + |
| 306 | + |
278 | 307 | def test_max_total_charge_usd_decimal_parsing(monkeypatch: pytest.MonkeyPatch) -> None: |
279 | 308 | """Test that max_total_charge_usd is parsed as Decimal from env var.""" |
280 | 309 | from decimal import Decimal |
|
0 commit comments