Files
colibre/tests/subscriptions/test_compte_abonnement.py
T

69 lines
2.3 KiB
Python

def test_reabo_button_never_subscribed():
from src.pages.compte import abonnement as compte_abonnement
text = str(compte_abonnement._reabo_button(has_used_trial=False))
assert "M'abonner" in text
assert "Me réabonner" not in text
assert "href='/a-propos/abonnement'" in text
def test_reabo_button_former_subscriber():
from src.pages.compte import abonnement as compte_abonnement
text = str(compte_abonnement._reabo_button(has_used_trial=True))
assert "Me réabonner" in text
assert "href='/a-propos/abonnement'" in text
def test_active_view_shows_cancel(monkeypatch):
from src.pages.compte import abonnement as compte_abonnement
row = {
"plan": "simple",
"status": "active",
"current_period_end": "2099-01-01T00:00:00+00:00",
}
view = compte_abonnement._active_view(row)
assert "Me désabonner" in str(view)
def test_active_view_trial_banner(monkeypatch):
from src.pages.compte import abonnement as compte_abonnement
row = {
"plan": "simple",
"status": "trial",
"current_period_end": "2099-01-01T00:00:00+00:00",
}
assert "Essai gratuit" in str(compte_abonnement._active_view(row))
def test_banner_present_when_tous_abonnes(monkeypatch):
monkeypatch.setattr("src.utils.TOUS_ABONNES", True)
from src.pages.compte import abonnement as compte_abonnement
text = str(compte_abonnement._tous_abonnes_banner())
assert "accessibles à tous et toutes" in text
def test_banner_absent_when_flag_off(monkeypatch):
monkeypatch.setattr("src.utils.TOUS_ABONNES", False)
from src.pages.compte import abonnement as compte_abonnement
assert compte_abonnement._tous_abonnes_banner() is None
def test_show_active_view_true_for_live_statuses(monkeypatch):
from src.pages.compte import abonnement as compte_abonnement
for status in ("pending", "trial", "active", "cancelled"):
assert compte_abonnement._show_active_view({"status": status}) is True
def test_show_active_view_false_for_failed_expired_or_none(monkeypatch):
from src.pages.compte import abonnement as compte_abonnement
assert compte_abonnement._show_active_view({"status": "failed"}) is False
assert compte_abonnement._show_active_view({"status": "expired"}) is False
assert compte_abonnement._show_active_view(None) is False