31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from datetime import date
|
|
|
|
import pytest
|
|
|
|
from app.models import FreeTurnProfile, PaymentInfo, ProxyAccess, ProxySettings
|
|
|
|
|
|
def test_payment_day_uses_last_day_of_month() -> None:
|
|
payment = PaymentInfo(monthly_price_rub=500, payment_day=31)
|
|
assert payment.due_date(2026, 2) == date(2026, 2, 28)
|
|
assert payment.due_date(2028, 2) == date(2028, 2, 29)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
("preset", "expected"),
|
|
[(1, (4, 4)), (2, (8, 4)), (3, (12, 6)), (4, (24, 6))],
|
|
)
|
|
def test_freeturn_presets(preset: int, expected: tuple[int, int]) -> None:
|
|
assert FreeTurnProfile(preset=preset).stream_settings == expected
|
|
|
|
|
|
def test_freeturn_stability_mode_caps_per_credential() -> None:
|
|
assert FreeTurnProfile(preset=3, stability_over_load=True).stream_settings == (12, 4)
|
|
assert FreeTurnProfile(preset=4, stability_over_load=True).stream_settings == (24, 4)
|
|
|
|
|
|
def test_hotspot_without_auth_is_allowed_but_auth_requires_credentials() -> None:
|
|
settings = ProxySettings(access=ProxyAccess.HOTSPOT, authentication=False)
|
|
settings.validate_for_access()
|
|
with pytest.raises(ValueError):
|
|
ProxySettings(authentication=True).validate_for_access()
|