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

@@ -39,28 +39,24 @@ def test_legal_blueprint_registered():
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.')]
assert any('/' in r for r in rules), (
f"Expected marketing blueprint to have a route, found: {rules}"
assert any(r == '/' for r in rules), (
f"Expected marketing root 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}"
"""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 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
"""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}"
)