Ajoute le drapeau TOUS_ABONNES pour l'accès gratuit

Ouvre les fonctionnalités d'abonné à tout utilisateur connecté tant que
Frisbii n'a pas validé la réception de paiements.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Colin Maudry
2026-06-26 18:06:27 +02:00
parent e229caf320
commit 2bdcfdeb1a
4 changed files with 42 additions and 0 deletions
+33
View File
@@ -1,6 +1,15 @@
from unittest.mock import patch
from src.pages import _compte_shell as shell
def _fake_user(authenticated: bool):
user = type("U", (), {})()
user.is_authenticated = authenticated
user.id = 1
return user
def test_visible_sections_hides_gated_without_subscription():
keys = {s["key"] for s in shell.visible_sections(has_subscription=False)}
assert "admin" in keys
@@ -41,3 +50,27 @@ def test_guard_redirect_allowed_returns_none():
path="/compte/admin",
)
assert href is None
def test_has_subscription_true_for_authenticated_when_tous_abonnes(monkeypatch):
monkeypatch.setattr("src.utils.TOUS_ABONNES", True)
with patch("src.pages._compte_shell.current_user", _fake_user(True)):
assert shell.current_user_has_subscription() is True
def test_has_subscription_false_for_anonymous_even_with_tous_abonnes(monkeypatch):
monkeypatch.setattr("src.utils.TOUS_ABONNES", True)
with patch("src.pages._compte_shell.current_user", _fake_user(False)):
assert shell.current_user_has_subscription() is False
def test_has_subscription_uses_db_when_flag_off(monkeypatch):
monkeypatch.setattr("src.utils.TOUS_ABONNES", False)
with (
patch("src.pages._compte_shell.current_user", _fake_user(True)),
patch(
"src.subscriptions.db.has_active_subscription", return_value=False
) as mocked,
):
assert shell.current_user_has_subscription() is False
mocked.assert_called_once_with(1)