feat(modernization): full architecture blueprint with hardening follow-up
Implement phased modernization infrastructure for transitioning from multi-page legacy routing to SPA portal-shell architecture, plus post-delivery hardening fixes for policy loading, fallback consistency, and governance drift detection. Key changes: - Add route contract enrichment with scope/visibility/compatibility policies - Canonical 302 redirects from legacy direct-entry to /portal-shell/ routes - Asset readiness enforcement and runtime fallback retirement for in-scope routes - Shared feature-flag helpers (env > config > default) replacing duplicated _to_bool - Defensive copy for lru_cached policy payloads preventing mutation corruption - Unified retired-fallback response helper across app and blueprint routes - Frontend/backend route-contract cross-validation in governance gates - Shell CSS token fallback values for routes rendered outside shell scope - Local-safe .env.example defaults with production recommendation comments - Legacy contract fallback warning logging and single-hop redirect optimization Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
25
tests/test_feature_flags.py
Normal file
25
tests/test_feature_flags.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Tests for shared feature-flag resolution helpers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from mes_dashboard.core.feature_flags import parse_bool, resolve_bool_flag
|
||||
|
||||
|
||||
def test_parse_bool_supports_true_and_false_tokens():
|
||||
assert parse_bool("true", default=False) is True
|
||||
assert parse_bool(" yes ", default=False) is True
|
||||
assert parse_bool("0", default=True) is False
|
||||
assert parse_bool("off", default=True) is False
|
||||
|
||||
|
||||
def test_resolve_bool_flag_prefers_environment_over_config():
|
||||
env = {"FEATURE_X": "false"}
|
||||
config = {"FEATURE_X": True}
|
||||
assert resolve_bool_flag("FEATURE_X", config=config, default=True, environ=env) is False
|
||||
|
||||
|
||||
def test_resolve_bool_flag_uses_config_then_default_when_env_missing():
|
||||
config = {"FEATURE_X": "true"}
|
||||
assert resolve_bool_flag("FEATURE_X", config=config, default=False, environ={}) is True
|
||||
assert resolve_bool_flag("MISSING", config=config, default=False, environ={}) is False
|
||||
Reference in New Issue
Block a user