Nombre de jours d'essai en dur plutot que via appels HTTP

This commit is contained in:
Colin Maudry
2026-07-02 13:55:22 +02:00
parent 1bdcaaf5d8
commit d08f7aeeac
2 changed files with 9 additions and 54 deletions
+5 -22
View File
@@ -1,13 +1,12 @@
import pytest
from src.subscriptions import client, plans
from src.subscriptions import plans
@pytest.fixture(autouse=True)
def _env(monkeypatch):
monkeypatch.setenv("FRISBII_PLAN_SIMPLE", "plan_simple")
monkeypatch.setenv("FRISBII_PLAN_SOUTIEN", "plan_soutien")
plans._trial_cache.clear()
def test_resolve_handle(monkeypatch):
@@ -15,29 +14,13 @@ def test_resolve_handle(monkeypatch):
assert plans.resolve_handle("inconnu") is None
def test_trial_days_parses_and_caches(monkeypatch):
calls = []
def fake_get_plan(handle):
calls.append(handle)
return {"trial_interval_unit": "days", "trial_interval_length": 2}
monkeypatch.setattr(client, "get_plan", fake_get_plan)
def test_trial_days_returns_configured_value():
assert plans.trial_days("simple") == 2
assert plans.trial_days("simple") == 2 # depuis le cache
assert calls == ["plan_simple"] # un seul appel API
assert plans.trial_days("soutien") == 2
def test_trial_days_none_on_error(monkeypatch):
def fake_get_plan(handle):
raise client.FrisbiiError(500, "boom")
monkeypatch.setattr(client, "get_plan", fake_get_plan)
assert plans.trial_days("simple") is None
def test_trial_days_none_when_no_trial(monkeypatch):
monkeypatch.setattr(client, "get_plan", lambda h: {})
def test_trial_days_none_when_plan_handle_unset(monkeypatch):
monkeypatch.delenv("FRISBII_PLAN_SIMPLE", raising=False)
assert plans.trial_days("simple") is None