Skip to content

Commit 6e34e2a

Browse files
committed
add tests
1 parent 80b6fc0 commit 6e34e2a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/unit/actor/test_configuration.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import json
2+
from decimal import Decimal
23
from pathlib import Path
34

45
import pytest
@@ -275,6 +276,34 @@ def test_default_values() -> None:
275276
assert config.test_pay_per_event is False
276277

277278

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+
278307
def test_max_total_charge_usd_decimal_parsing(monkeypatch: pytest.MonkeyPatch) -> None:
279308
"""Test that max_total_charge_usd is parsed as Decimal from env var."""
280309
from decimal import Decimal

0 commit comments

Comments
 (0)