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)
This commit is contained in:
Allison
2026-04-27 16:21:34 -04:00
parent e01523125e
commit 55ae09431d
4 changed files with 32 additions and 19 deletions

View File

@@ -8,4 +8,10 @@ Routes added in Tasks B-2.7 (checkout) and B-2.8 (webhook).
""" """
from flask import Blueprint from flask import Blueprint
billing_bp = Blueprint('billing', __name__, url_prefix='/checkout') billing_bp = Blueprint(
'billing',
__name__,
url_prefix='/checkout',
template_folder='../../templates/billing',
static_folder=None,
)

View File

@@ -8,4 +8,10 @@ Routes added in Task B-2.9.
""" """
from flask import Blueprint from flask import Blueprint
legal_bp = Blueprint('legal', __name__, url_prefix='/legal') legal_bp = Blueprint(
'legal',
__name__,
url_prefix='/legal',
template_folder='../../templates/legal',
static_folder=None,
)

View File

@@ -5,7 +5,12 @@ blueprints. Routes added incrementally in Phase 2 (Tasks A-2.x).
""" """
from flask import Blueprint from flask import Blueprint
marketing_bp = Blueprint('marketing', __name__) marketing_bp = Blueprint(
'marketing',
__name__,
template_folder='../../templates/marketing',
static_folder=None,
)
# Import routes module so it registers route handlers via decorators # Import routes module so it registers route handlers via decorators
from . import routes # noqa: E402,F401 from . import routes # noqa: E402,F401

View File

@@ -39,28 +39,24 @@ def test_legal_blueprint_registered():
def test_marketing_landing_route_exists(): def test_marketing_landing_route_exists():
"""The marketing blueprint should expose at least a placeholder root route.""" """Marketing blueprint must expose root '/' route."""
rules = [str(r) for r in app.url_map.iter_rules() if r.endpoint.startswith('marketing.')] rules = [str(r) for r in app.url_map.iter_rules() if r.endpoint.startswith('marketing.')]
assert any('/' in r for r in rules), ( assert any(r == '/' for r in rules), (
f"Expected marketing blueprint to have a route, found: {rules}" f"Expected marketing root route '/', found: {rules}"
) )
def test_legal_blueprint_has_url_prefix(): def test_legal_blueprint_has_url_prefix():
"""Legal blueprint should be mounted at /legal/* prefix.""" """Legal blueprint must be mounted with /legal url_prefix."""
rules = [str(r) for r in app.url_map.iter_rules() if r.endpoint.startswith('legal.')] assert 'legal' in app.blueprints
assert all('/legal' in r for r in rules), ( assert app.blueprints['legal'].url_prefix == '/legal', (
f"Expected /legal/ prefix on all legal routes, found: {rules}" f"Expected legal blueprint url_prefix='/legal', got {app.blueprints['legal'].url_prefix!r}"
) )
def test_billing_blueprint_has_url_prefix(): def test_billing_blueprint_has_url_prefix():
"""Billing blueprint should be mounted at /checkout/* prefix. """Billing blueprint must be mounted with /checkout url_prefix."""
assert 'billing' in app.blueprints
Phase 1 minimum: blueprint is registered but may have no routes yet. assert app.blueprints['billing'].url_prefix == '/checkout', (
Routes added in B-2.7 (checkout) and B-2.8 (webhook). f"Expected billing blueprint url_prefix='/checkout', got {app.blueprints['billing'].url_prefix!r}"
""" )
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