28 lines
897 B
Python
28 lines
897 B
Python
|
|
"""Unit-Tests für club_features (ohne DB)."""
|
||
|
|
from datetime import datetime, timezone
|
||
|
|
|
||
|
|
from club_features import _calculate_next_reset, _normalize_limit
|
||
|
|
|
||
|
|
|
||
|
|
def test_normalize_limit_none_and_negative():
|
||
|
|
assert _normalize_limit(None) is None
|
||
|
|
assert _normalize_limit(-1) is None
|
||
|
|
assert _normalize_limit(0) == 0
|
||
|
|
assert _normalize_limit(50) == 50
|
||
|
|
|
||
|
|
|
||
|
|
def test_calculate_next_reset_never():
|
||
|
|
assert _calculate_next_reset("never") is None
|
||
|
|
|
||
|
|
|
||
|
|
def test_calculate_next_reset_monthly_december():
|
||
|
|
ref = datetime(2026, 12, 15, 12, 0, tzinfo=timezone.utc)
|
||
|
|
nxt = _calculate_next_reset("monthly", now=ref)
|
||
|
|
assert nxt == datetime(2027, 1, 1, tzinfo=timezone.utc)
|
||
|
|
|
||
|
|
|
||
|
|
def test_calculate_next_reset_monthly_mid_year():
|
||
|
|
ref = datetime(2026, 6, 6, 12, 0, tzinfo=timezone.utc)
|
||
|
|
nxt = _calculate_next_reset("monthly", now=ref)
|
||
|
|
assert nxt == datetime(2026, 7, 1, tzinfo=timezone.utc)
|