mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-01 19:18:35 -04:00
483c42bb12
Slice 2i of the route-domain reorganization (#4082/#4071). Moves compare_routes.py into routes/compare/, leaving a backward-compat sys.modules shim at the old path. Pure file reorganization, no behavior change. The shim uses sys.modules replacement so the `import ... as cr` + `monkeypatch.setattr(cr, "SessionLocal", ...)` / `"_owned_endpoint_by_url"` / `"_owned_endpoint_by_id"` pattern in test_endpoint_owner_scope_followup.py reaches the canonical module. Canonical module imports only from core/, src/, and routes.session_routes (zero dependency on the legacy shim). One source-introspection test site repointed: test_endpoint_owner_scope_followup.py (shared with other domains; only the compare entry repointed here). Adds tests/test_compare_routes_shim.py to pin the sys.modules shim contract. Verified: compileall clean; targeted tests pass.
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
"""Regression test for the compare route shim (slice 2i, #4082/#4071).
|
|
|
|
The backward-compat shim at ``routes/compare_routes.py`` uses ``sys.modules``
|
|
replacement so the legacy import path and the canonical ``routes.compare.*``
|
|
path resolve to the *same* module object. This is required because
|
|
``test_endpoint_owner_scope_followup.py`` uses ``import routes.compare_routes
|
|
as cr`` followed by ``monkeypatch.setattr(cr, "SessionLocal", ...)`` /
|
|
``"_owned_endpoint_by_url"`` / ``"_owned_endpoint_by_id"`` — for those patches
|
|
to take effect at runtime, the legacy module object and the canonical one
|
|
must be identical.
|
|
"""
|
|
|
|
import importlib
|
|
|
|
import routes.compare_routes as _shim_compare # noqa: F401
|
|
|
|
|
|
def test_legacy_and_canonical_compare_module_are_same_object():
|
|
"""``import routes.compare_routes`` must alias the canonical module."""
|
|
legacy = importlib.import_module("routes.compare_routes")
|
|
canonical = importlib.import_module("routes.compare.compare_routes")
|
|
assert legacy is canonical, (
|
|
"routes.compare_routes shim must resolve to the canonical "
|
|
"routes.compare.compare_routes module object"
|
|
)
|