Files
dictia-public/tests/test_blueprint_registration.py
Allison 55ae09431d fix(marketing): add template_folder + tighten blueprint registration tests
- Explicit template_folder on marketing/billing/legal blueprints prevents silent
  template fallback in Phase 2
- Replace vacuous test assertions (len>=0, substring '/' in r) with direct
  url_prefix and exact-match route checks (per code review I-1, I-2, I-3)
2026-04-27 16:21:34 -04:00

63 lines
2.2 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():
"""Marketing blueprint must expose root '/' route."""
rules = [str(r) for r in app.url_map.iter_rules() if r.endpoint.startswith('marketing.')]
assert any(r == '/' for r in rules), (
f"Expected marketing root route '/', found: {rules}"
)
def test_legal_blueprint_has_url_prefix():
"""Legal blueprint must be mounted with /legal url_prefix."""
assert 'legal' in app.blueprints
assert app.blueprints['legal'].url_prefix == '/legal', (
f"Expected legal blueprint url_prefix='/legal', got {app.blueprints['legal'].url_prefix!r}"
)
def test_billing_blueprint_has_url_prefix():
"""Billing blueprint must be mounted with /checkout url_prefix."""
assert 'billing' in app.blueprints
assert app.blueprints['billing'].url_prefix == '/checkout', (
f"Expected billing blueprint url_prefix='/checkout', got {app.blueprints['billing'].url_prefix!r}"
)