refactor: remove backward compatibility code for pre-launch baseline
Clean up accumulated backward-compat shims, deprecated wrappers, unused aliases, and legacy code across the codebase. Since the platform is not live yet, this establishes a clean baseline. Changes: - Delete deprecated middleware/context.py (RequestContext, get_request_context) - Remove unused factory get_store_email_settings_service() - Remove deprecated pagination_full macro, /admin/platform-homepage route - Remove ConversationResponse, InvoiceSettings* unprefixed aliases - Simplify celery_config.py (remove empty LEGACY_TASK_MODULES) - Standardize billing exceptions: *Error aliases → *Exception names - Consolidate duplicate TierNotFoundError/FeatureNotFoundError classes - Remove deprecated is_admin_request() from Store/PlatformContextManager - Remove is_platform_default field, MediaUploadResponse legacy flat fields - Remove MediaItemResponse.url alias, update JS to use file_url - Update all affected tests and documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import pytest
|
||||
from fastapi import Request
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.frontend_detector import FrontendDetector
|
||||
from middleware.platform_context import (
|
||||
DEFAULT_PLATFORM_CODE,
|
||||
PlatformContextManager,
|
||||
@@ -210,7 +211,7 @@ class TestPlatformContextManager:
|
||||
request.headers = {"host": "admin.localhost"}
|
||||
request.url = Mock(path="/dashboard")
|
||||
|
||||
assert PlatformContextManager.is_admin_request(request) is True
|
||||
assert FrontendDetector.is_admin("admin.localhost", "/dashboard") is True
|
||||
|
||||
context = PlatformContextManager.detect_platform_context(request)
|
||||
assert context is None
|
||||
@@ -221,26 +222,18 @@ class TestPlatformContextManager:
|
||||
request.headers = {"host": "localhost"}
|
||||
request.url = Mock(path="/admin/stores")
|
||||
|
||||
assert PlatformContextManager.is_admin_request(request) is True
|
||||
assert FrontendDetector.is_admin("localhost", "/admin/stores") is True
|
||||
|
||||
context = PlatformContextManager.detect_platform_context(request)
|
||||
assert context is None
|
||||
|
||||
def test_skip_admin_path_with_port(self):
|
||||
"""Test admin detection with port in host."""
|
||||
request = Mock(spec=Request)
|
||||
request.headers = {"host": "admin.localhost:9999"}
|
||||
request.url = Mock(path="/dashboard")
|
||||
|
||||
assert PlatformContextManager.is_admin_request(request) is True
|
||||
assert FrontendDetector.is_admin("admin.localhost:9999", "/dashboard") is True
|
||||
|
||||
def test_not_admin_regular_path(self):
|
||||
"""Test non-admin path is not detected as admin."""
|
||||
request = Mock(spec=Request)
|
||||
request.headers = {"host": "localhost"}
|
||||
request.url = Mock(path="/shop/products")
|
||||
|
||||
assert PlatformContextManager.is_admin_request(request) is False
|
||||
assert FrontendDetector.is_admin("localhost", "/shop/products") is False
|
||||
|
||||
# ========================================================================
|
||||
# Static File Detection Tests
|
||||
@@ -925,11 +918,7 @@ class TestEdgeCases:
|
||||
|
||||
def test_admin_subdomain_with_production_domain(self):
|
||||
"""Test admin subdomain detection for production domains."""
|
||||
request = Mock(spec=Request)
|
||||
request.headers = {"host": "admin.oms.lu"}
|
||||
request.url = Mock(path="/dashboard")
|
||||
|
||||
assert PlatformContextManager.is_admin_request(request) is True
|
||||
assert FrontendDetector.is_admin("admin.oms.lu", "/dashboard") is True
|
||||
|
||||
def test_static_file_case_insensitive(self):
|
||||
"""Test static file detection is case-insensitive."""
|
||||
|
||||
Reference in New Issue
Block a user