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:
@@ -17,6 +17,7 @@ import pytest
|
||||
from fastapi import Request
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.frontend_detector import FrontendDetector
|
||||
from app.modules.tenancy.exceptions import StoreNotFoundException
|
||||
from middleware.store_context import (
|
||||
StoreContextManager,
|
||||
@@ -372,35 +373,19 @@ class TestStoreContextManager:
|
||||
|
||||
def test_is_admin_request_admin_subdomain(self):
|
||||
"""Test admin request detection from subdomain."""
|
||||
request = Mock(spec=Request)
|
||||
request.headers = {"host": "admin.platform.com"}
|
||||
request.url = Mock(path="/dashboard")
|
||||
|
||||
assert StoreContextManager.is_admin_request(request) is True
|
||||
assert FrontendDetector.is_admin("admin.platform.com", "/dashboard") is True
|
||||
|
||||
def test_is_admin_request_admin_path(self):
|
||||
"""Test admin request detection from path."""
|
||||
request = Mock(spec=Request)
|
||||
request.headers = {"host": "localhost"}
|
||||
request.url = Mock(path="/admin/dashboard")
|
||||
|
||||
assert StoreContextManager.is_admin_request(request) is True
|
||||
assert FrontendDetector.is_admin("localhost", "/admin/dashboard") is True
|
||||
|
||||
def test_is_admin_request_with_port(self):
|
||||
"""Test admin request detection with port number."""
|
||||
request = Mock(spec=Request)
|
||||
request.headers = {"host": "admin.localhost:8000"}
|
||||
request.url = Mock(path="/dashboard")
|
||||
|
||||
assert StoreContextManager.is_admin_request(request) is True
|
||||
assert FrontendDetector.is_admin("admin.localhost:8000", "/dashboard") is True
|
||||
|
||||
def test_is_not_admin_request(self):
|
||||
"""Test non-admin request."""
|
||||
request = Mock(spec=Request)
|
||||
request.headers = {"host": "store1.platform.com"}
|
||||
request.url = Mock(path="/storefront")
|
||||
|
||||
assert StoreContextManager.is_admin_request(request) is False
|
||||
assert FrontendDetector.is_admin("store1.platform.com", "/storefront") is False
|
||||
|
||||
def test_is_api_request(self):
|
||||
"""Test API request detection."""
|
||||
@@ -599,7 +584,7 @@ class TestStoreContextMiddleware:
|
||||
|
||||
call_next = AsyncMock(return_value=Mock())
|
||||
|
||||
with patch.object(StoreContextManager, "is_admin_request", return_value=True):
|
||||
with patch.object(FrontendDetector, "is_admin", return_value=True):
|
||||
await middleware.dispatch(request, call_next)
|
||||
|
||||
assert request.state.store is None
|
||||
@@ -775,7 +760,7 @@ class TestStoreContextMiddleware:
|
||||
call_next = AsyncMock(return_value=Mock())
|
||||
|
||||
with (
|
||||
patch.object(StoreContextManager, "is_admin_request", return_value=False),
|
||||
patch.object(FrontendDetector, "is_admin", return_value=False),
|
||||
patch.object(
|
||||
StoreContextManager, "is_static_file_request", return_value=False
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user