refactor: remove all backward compatibility code across 70 files
Some checks failed
CI / ruff (push) Successful in 11s
CI / validate (push) Has been cancelled
CI / dependency-scanning (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / deploy (push) Has been cancelled
CI / pytest (push) Has started running

Clean up 28 backward compatibility instances identified in the codebase.
The app is not live, so all shims are replaced with the target architecture:

- Remove legacy Inventory.location column (use bin_location exclusively)
- Remove dashboard _extract_metric_value helper (use flat metrics dict)
- Remove legacy stat field duplicates (total_stores, total_imports, etc.)
- Remove 13 re-export shims and class aliases across modules
- Remove module-enabling JSON fallback (use PlatformModule junction table)
- Remove menu_to_legacy_format() conversion (return dataclasses directly)
- Remove title/description from MarketplaceProductBase schema
- Clean billing convenience method docstrings
- Clean test fixtures and backward-compat comments
- Add PlatformModule seeding to init_production.py

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-15 13:20:29 +01:00
parent b0db8133a0
commit aad18c27ab
70 changed files with 501 additions and 841 deletions

View File

@@ -13,7 +13,7 @@ Tests cover:
URL Structure:
- Main marketing site: localhost:9999/ (no prefix) -> 'main' platform
- Platform sites: localhost:9999/platforms/{code}/ -> specific platform
- Production: domain-based (oms.lu, loyalty.lu)
- Production: domain-based (omsflow.lu, rewardflow.lu)
"""
from unittest.mock import AsyncMock, MagicMock, Mock, patch
@@ -42,35 +42,35 @@ class TestPlatformContextManager:
# ========================================================================
def test_detect_domain_based_platform(self):
"""Test domain-based platform detection for production (e.g., oms.lu)."""
"""Test domain-based platform detection for production (e.g., omsflow.lu)."""
request = Mock(spec=Request)
request.headers = {"host": "oms.lu"}
request.headers = {"host": "omsflow.lu"}
request.url = Mock(path="/pricing")
context = PlatformContextManager.detect_platform_context(request)
assert context is not None
assert context["detection_method"] == "domain"
assert context["domain"] == "oms.lu"
assert context["host"] == "oms.lu"
assert context["domain"] == "omsflow.lu"
assert context["host"] == "omsflow.lu"
assert context["original_path"] == "/pricing"
def test_detect_domain_with_port(self):
"""Test domain detection with port number."""
request = Mock(spec=Request)
request.headers = {"host": "loyalty.lu:8443"}
request.headers = {"host": "rewardflow.lu:8443"}
request.url = Mock(path="/features")
context = PlatformContextManager.detect_platform_context(request)
assert context is not None
assert context["detection_method"] == "domain"
assert context["domain"] == "loyalty.lu"
assert context["domain"] == "rewardflow.lu"
def test_detect_domain_three_level_not_detected(self):
"""Test that three-level domains (subdomains) are not detected as platform domains."""
request = Mock(spec=Request)
request.headers = {"host": "store.oms.lu"}
request.headers = {"host": "store.omsflow.lu"}
request.url = Mock(path="/shop")
context = PlatformContextManager.detect_platform_context(request)
@@ -295,7 +295,7 @@ class TestPlatformContextManager:
mock_db.query.return_value.filter.return_value.filter.return_value.first.return_value = mock_platform
context = {"detection_method": "domain", "domain": "oms.lu"}
context = {"detection_method": "domain", "domain": "omsflow.lu"}
platform = PlatformContextManager.get_platform_from_context(mock_db, context)
@@ -398,7 +398,7 @@ class TestPlatformContextManager:
request = Mock(spec=Request)
request.url = Mock(path="/pricing")
context = {"detection_method": "domain", "domain": "oms.lu"}
context = {"detection_method": "domain", "domain": "omsflow.lu"}
clean_path = PlatformContextManager.extract_clean_path(request, context)
@@ -598,7 +598,7 @@ class TestPlatformContextMiddleware:
scope = {
"type": "http",
"path": "/pricing",
"headers": [(b"host", b"oms.lu")],
"headers": [(b"host", b"omsflow.lu")],
}
receive = AsyncMock()
@@ -918,7 +918,7 @@ class TestEdgeCases:
def test_admin_subdomain_with_production_domain(self):
"""Test admin subdomain detection for production domains."""
assert FrontendDetector.is_admin("admin.oms.lu", "/dashboard") is True
assert FrontendDetector.is_admin("admin.omsflow.lu", "/dashboard") is True
def test_static_file_case_insensitive(self):
"""Test static file detection is case-insensitive."""
@@ -945,7 +945,7 @@ class TestURLRoutingSummary:
- Main marketing: localhost:9999/ -> 'main' platform, path unchanged
- OMS platform: localhost:9999/platforms/oms/pricing -> 'oms' platform, path=/pricing
- Loyalty platform: localhost:9999/platforms/loyalty/features -> 'loyalty' platform, path=/features
- Production OMS: oms.lu/pricing -> 'oms' platform, path=/pricing (no rewrite)
- Production OMS: omsflow.lu/pricing -> 'oms' platform, path=/pricing (no rewrite)
"""
def test_main_marketing_site_routing(self):
@@ -987,11 +987,11 @@ class TestURLRoutingSummary:
def test_production_domain_routing(self):
"""Document: Production domains don't rewrite path."""
request = Mock(spec=Request)
request.headers = {"host": "oms.lu"}
request.headers = {"host": "omsflow.lu"}
request.url = Mock(path="/pricing")
context = PlatformContextManager.detect_platform_context(request)
assert context["detection_method"] == "domain"
assert context["domain"] == "oms.lu"
assert context["domain"] == "omsflow.lu"
# clean_path not set for domain detection - uses original path