refactor: remove all backward compatibility code across 70 files
Some checks failed
Some checks failed
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:
@@ -12,7 +12,7 @@ Tests cover:
|
||||
|
||||
import pytest
|
||||
|
||||
from app.core.frontend_detector import FrontendDetector, get_frontend_type
|
||||
from app.core.frontend_detector import FrontendDetector
|
||||
from app.modules.enums import FrontendType
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class TestFrontendDetectorAdmin:
|
||||
|
||||
def test_detect_admin_from_subdomain(self):
|
||||
"""Test admin detection from admin subdomain."""
|
||||
result = FrontendDetector.detect(host="admin.oms.lu", path="/dashboard")
|
||||
result = FrontendDetector.detect(host="admin.omsflow.lu", path="/dashboard")
|
||||
assert result == FrontendType.ADMIN
|
||||
|
||||
def test_detect_admin_from_subdomain_with_port(self):
|
||||
@@ -42,7 +42,7 @@ class TestFrontendDetectorAdmin:
|
||||
|
||||
def test_detect_admin_nested_path(self):
|
||||
"""Test admin detection with nested admin path."""
|
||||
result = FrontendDetector.detect(host="oms.lu", path="/admin/stores/123/products")
|
||||
result = FrontendDetector.detect(host="omsflow.lu", path="/admin/stores/123/products")
|
||||
assert result == FrontendType.ADMIN
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestFrontendDetectorStore:
|
||||
|
||||
def test_detect_store_nested_path(self):
|
||||
"""Test store detection with nested store path."""
|
||||
result = FrontendDetector.detect(host="oms.lu", path="/store/dashboard/analytics")
|
||||
result = FrontendDetector.detect(host="omsflow.lu", path="/store/dashboard/analytics")
|
||||
assert result == FrontendType.STORE
|
||||
|
||||
def test_stores_plural_not_store_dashboard(self):
|
||||
@@ -92,7 +92,7 @@ class TestFrontendDetectorStorefront:
|
||||
|
||||
def test_detect_storefront_from_store_subdomain(self):
|
||||
"""Test storefront detection from store subdomain."""
|
||||
result = FrontendDetector.detect(host="orion.oms.lu", path="/products")
|
||||
result = FrontendDetector.detect(host="orion.omsflow.lu", path="/products")
|
||||
assert result == FrontendType.STOREFRONT
|
||||
|
||||
def test_detect_storefront_from_store_context(self):
|
||||
@@ -115,7 +115,7 @@ class TestFrontendDetectorPlatform:
|
||||
|
||||
def test_detect_platform_from_marketing_page(self):
|
||||
"""Test platform detection from marketing page."""
|
||||
result = FrontendDetector.detect(host="oms.lu", path="/pricing")
|
||||
result = FrontendDetector.detect(host="omsflow.lu", path="/pricing")
|
||||
assert result == FrontendType.PLATFORM
|
||||
|
||||
def test_detect_platform_from_about(self):
|
||||
@@ -135,7 +135,7 @@ class TestFrontendDetectorPriority:
|
||||
|
||||
def test_admin_subdomain_priority_over_path(self):
|
||||
"""Test that admin subdomain takes priority."""
|
||||
result = FrontendDetector.detect(host="admin.oms.lu", path="/storefront/products")
|
||||
result = FrontendDetector.detect(host="admin.omsflow.lu", path="/storefront/products")
|
||||
assert result == FrontendType.ADMIN
|
||||
|
||||
def test_admin_path_priority_over_store_context(self):
|
||||
@@ -148,7 +148,7 @@ class TestFrontendDetectorPriority:
|
||||
def test_path_priority_over_subdomain(self):
|
||||
"""Test that explicit path takes priority for store/storefront."""
|
||||
# /store/ path on a store subdomain -> STORE (path wins)
|
||||
result = FrontendDetector.detect(host="orion.oms.lu", path="/store/settings")
|
||||
result = FrontendDetector.detect(host="orion.omsflow.lu", path="/store/settings")
|
||||
assert result == FrontendType.STORE
|
||||
|
||||
|
||||
@@ -159,20 +159,20 @@ class TestFrontendDetectorHelpers:
|
||||
def test_strip_port(self):
|
||||
"""Test port stripping from host."""
|
||||
assert FrontendDetector._strip_port("localhost:8000") == "localhost"
|
||||
assert FrontendDetector._strip_port("oms.lu") == "oms.lu"
|
||||
assert FrontendDetector._strip_port("omsflow.lu") == "omsflow.lu"
|
||||
assert FrontendDetector._strip_port("admin.localhost:9999") == "admin.localhost"
|
||||
|
||||
def test_get_subdomain(self):
|
||||
"""Test subdomain extraction."""
|
||||
assert FrontendDetector._get_subdomain("orion.oms.lu") == "orion"
|
||||
assert FrontendDetector._get_subdomain("admin.oms.lu") == "admin"
|
||||
assert FrontendDetector._get_subdomain("oms.lu") is None
|
||||
assert FrontendDetector._get_subdomain("orion.omsflow.lu") == "orion"
|
||||
assert FrontendDetector._get_subdomain("admin.omsflow.lu") == "admin"
|
||||
assert FrontendDetector._get_subdomain("omsflow.lu") is None
|
||||
assert FrontendDetector._get_subdomain("localhost") is None
|
||||
assert FrontendDetector._get_subdomain("127.0.0.1") is None
|
||||
|
||||
def test_is_admin(self):
|
||||
"""Test is_admin convenience method."""
|
||||
assert FrontendDetector.is_admin("admin.oms.lu", "/dashboard") is True
|
||||
assert FrontendDetector.is_admin("admin.omsflow.lu", "/dashboard") is True
|
||||
assert FrontendDetector.is_admin("localhost", "/admin/stores") is True
|
||||
assert FrontendDetector.is_admin("localhost", "/store/settings") is False
|
||||
|
||||
@@ -185,13 +185,13 @@ class TestFrontendDetectorHelpers:
|
||||
def test_is_storefront(self):
|
||||
"""Test is_storefront convenience method."""
|
||||
assert FrontendDetector.is_storefront("localhost", "/storefront/products") is True
|
||||
assert FrontendDetector.is_storefront("orion.oms.lu", "/products") is True
|
||||
assert FrontendDetector.is_storefront("orion.omsflow.lu", "/products") is True
|
||||
assert FrontendDetector.is_storefront("localhost", "/admin/dashboard") is False
|
||||
|
||||
def test_is_platform(self):
|
||||
"""Test is_platform convenience method."""
|
||||
assert FrontendDetector.is_platform("localhost", "/") is True
|
||||
assert FrontendDetector.is_platform("oms.lu", "/pricing") is True
|
||||
assert FrontendDetector.is_platform("omsflow.lu", "/pricing") is True
|
||||
assert FrontendDetector.is_platform("localhost", "/admin/dashboard") is False
|
||||
|
||||
def test_is_api_request(self):
|
||||
@@ -201,46 +201,21 @@ class TestFrontendDetectorHelpers:
|
||||
assert FrontendDetector.is_api_request("/admin/dashboard") is False
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestGetFrontendTypeFunction:
|
||||
"""Test suite for get_frontend_type convenience function."""
|
||||
|
||||
def test_get_frontend_type_admin(self):
|
||||
"""Test get_frontend_type returns admin."""
|
||||
result = get_frontend_type("localhost", "/admin/dashboard")
|
||||
assert result == FrontendType.ADMIN
|
||||
|
||||
def test_get_frontend_type_store(self):
|
||||
"""Test get_frontend_type returns store."""
|
||||
result = get_frontend_type("localhost", "/store/settings")
|
||||
assert result == FrontendType.STORE
|
||||
|
||||
def test_get_frontend_type_storefront(self):
|
||||
"""Test get_frontend_type returns storefront."""
|
||||
result = get_frontend_type("localhost", "/storefront/products")
|
||||
assert result == FrontendType.STOREFRONT
|
||||
|
||||
def test_get_frontend_type_platform(self):
|
||||
"""Test get_frontend_type returns platform."""
|
||||
result = get_frontend_type("localhost", "/pricing")
|
||||
assert result == FrontendType.PLATFORM
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestReservedSubdomains:
|
||||
"""Test suite for reserved subdomain handling."""
|
||||
|
||||
def test_www_subdomain_not_storefront(self):
|
||||
"""Test that www subdomain is not treated as store storefront."""
|
||||
result = FrontendDetector.detect(host="www.oms.lu", path="/")
|
||||
result = FrontendDetector.detect(host="www.omsflow.lu", path="/")
|
||||
assert result == FrontendType.PLATFORM
|
||||
|
||||
def test_api_subdomain_not_storefront(self):
|
||||
"""Test that api subdomain is not treated as store storefront."""
|
||||
result = FrontendDetector.detect(host="api.oms.lu", path="/v1/products")
|
||||
result = FrontendDetector.detect(host="api.omsflow.lu", path="/v1/products")
|
||||
assert result == FrontendType.PLATFORM
|
||||
|
||||
def test_portal_subdomain_not_storefront(self):
|
||||
"""Test that portal subdomain is not treated as store storefront."""
|
||||
result = FrontendDetector.detect(host="portal.oms.lu", path="/")
|
||||
result = FrontendDetector.detect(host="portal.omsflow.lu", path="/")
|
||||
assert result == FrontendType.PLATFORM
|
||||
|
||||
Reference in New Issue
Block a user