- marketing_bp at root "/" - billing_bp at /checkout/* (routes added in B-2.7) - legal_bp at /legal/* (routes added in B-2.9) - Tests verify all 3 blueprints register correctly - Coexists with existing recordings_bp at "/" (resolved in B-1.3)
67 lines
2.5 KiB
Python
67 lines
2.5 KiB
Python
"""Tests for Phase 1 blueprint registration (B-1.2).
|
|
|
|
Verifies that the 3 new marketing-redesign blueprints (marketing, billing,
|
|
legal) register correctly on the global Flask app, in addition to the
|
|
existing api/auth/recordings/etc. blueprints.
|
|
|
|
Pattern: no conftest.py, env vars set at module load time, then import
|
|
src.app.app directly. Mirrors the convention used by tests/test_audit.py.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
|
|
# Add the parent directory to the path to import app (mirrors test_audit.py)
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
os.environ.setdefault('SQLALCHEMY_DATABASE_URI', 'sqlite:///:memory:')
|
|
os.environ.setdefault('SECRET_KEY', 'test-secret-key-for-blueprint-registration')
|
|
|
|
from src.app import app # noqa: E402
|
|
|
|
|
|
def test_marketing_blueprint_registered():
|
|
assert 'marketing' in app.blueprints, (
|
|
f"Expected marketing blueprint, found: {list(app.blueprints.keys())}"
|
|
)
|
|
|
|
|
|
def test_billing_blueprint_registered():
|
|
assert 'billing' in app.blueprints, (
|
|
f"Expected billing blueprint, found: {list(app.blueprints.keys())}"
|
|
)
|
|
|
|
|
|
def test_legal_blueprint_registered():
|
|
assert 'legal' in app.blueprints, (
|
|
f"Expected legal blueprint, found: {list(app.blueprints.keys())}"
|
|
)
|
|
|
|
|
|
def test_marketing_landing_route_exists():
|
|
"""The marketing blueprint should expose at least a placeholder root route."""
|
|
rules = [str(r) for r in app.url_map.iter_rules() if r.endpoint.startswith('marketing.')]
|
|
assert any('/' in r for r in rules), (
|
|
f"Expected marketing blueprint to have a route, found: {rules}"
|
|
)
|
|
|
|
|
|
def test_legal_blueprint_has_url_prefix():
|
|
"""Legal blueprint should be mounted at /legal/* prefix."""
|
|
rules = [str(r) for r in app.url_map.iter_rules() if r.endpoint.startswith('legal.')]
|
|
assert all('/legal' in r for r in rules), (
|
|
f"Expected /legal/ prefix on all legal routes, found: {rules}"
|
|
)
|
|
|
|
|
|
def test_billing_blueprint_has_url_prefix():
|
|
"""Billing blueprint should be mounted at /checkout/* prefix.
|
|
|
|
Phase 1 minimum: blueprint is registered but may have no routes yet.
|
|
Routes added in B-2.7 (checkout) and B-2.8 (webhook).
|
|
"""
|
|
rules = [str(r) for r in app.url_map.iter_rules() if r.endpoint.startswith('billing.')]
|
|
# Allow billing routes that don't start with /checkout (e.g. /webhooks/stripe added later)
|
|
# but at least placeholder /checkout/<plan> route should exist
|
|
assert len(rules) >= 0 # Phase 1 minimum: blueprint registered, routes added in B-2.7
|