shinkan-jinkendo/backend/tests/test_account_onboarding_gate.py

69 lines
1.6 KiB
Python
Raw Normal View History

"""Tests für account_onboarding_gate."""
import pytest
from account_onboarding_gate import (
check_api_onboarding_gate,
is_public_api_path,
normalize_api_path,
)
def test_public_directory_is_public():
assert is_public_api_path("/api/clubs/public-directory")
def test_exercises_blocked_for_pending():
allowed, reason = check_api_onboarding_gate(
path="/api/exercises",
method="GET",
profile_id=1,
account_state="verified_pending_club",
)
assert not allowed
assert reason == "account_state_verified_pending_club"
def test_join_request_allowed_for_pending():
allowed, _ = check_api_onboarding_gate(
path="/api/me/club-join-requests",
method="POST",
profile_id=1,
account_state="verified_pending_club",
)
assert allowed
def test_creation_request_allowed_for_pending():
allowed, _ = check_api_onboarding_gate(
path="/api/me/club-creation-requests",
method="POST",
profile_id=1,
account_state="verified_pending_club",
)
assert allowed
def test_active_member_domain_ok():
allowed, reason = check_api_onboarding_gate(
path="/api/exercises",
method="GET",
profile_id=1,
account_state="active_member",
)
assert allowed
assert reason is None
def test_profile_self_update_allowed_unverified():
allowed, _ = check_api_onboarding_gate(
path="/api/profiles/42",
method="PUT",
profile_id=42,
account_state="unverified",
)
assert allowed
def test_normalize_trailing_slash():
assert normalize_api_path("/api/exercises/") == "/api/exercises"