mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-28 23:52:09 -04:00
refactor(routes): move research domain into routes/research/ subpackage
Move the research route domain into the canonical routes/research/ subpackage while preserving the legacy routes.research_routes import path through a sys.modules compatibility shim. The moved canonical module is behavior-preserving, app wiring now imports the canonical route setup function, source-introspection tests point at the new canonical path, and shim regression coverage pins legacy/canonical same-object behavior plus string-targeted monkeypatch reach-through. Refs #4082. Refs #4071.
This commit is contained in:
@@ -54,7 +54,7 @@ def test_scheduler_fallbacks_and_research_headers_are_owner_scoped():
|
||||
|
||||
|
||||
def test_research_routes_fallbacks_are_owner_scoped():
|
||||
src = _src("routes/research_routes.py")
|
||||
src = _src("routes/research/research_routes.py")
|
||||
|
||||
assert 'resolve_endpoint("research", owner=user)' in src
|
||||
assert 'resolve_endpoint("utility", owner=user)' in src
|
||||
|
||||
@@ -402,7 +402,7 @@ def test_gallery_image_endpoint_lookups_are_owner_scoped():
|
||||
|
||||
|
||||
def test_research_endpoint_resolution_passes_owner():
|
||||
body = Path("routes/research_routes.py").read_text(encoding="utf-8")
|
||||
body = Path("routes/research/research_routes.py").read_text(encoding="utf-8")
|
||||
|
||||
assert "def _resolve_research_endpoint(sess, owner:" in body
|
||||
assert 'resolve_endpoint("research", owner=user)' in body
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
"""Regression test for the research route shim (slice 2b, #4082/#4071).
|
||||
|
||||
The backward-compat shim at ``routes/research_routes.py`` uses ``sys.modules``
|
||||
replacement so the legacy import path and the canonical ``routes.research.*``
|
||||
path resolve to the *same* module object. This is required because
|
||||
``test_research_owner_scope_routes.py`` does a string-targeted
|
||||
``monkeypatch.setattr("routes.research_routes.DEEP_RESEARCH_DIR", ...)`` which
|
||||
must reach the canonical module. This test pins that contract.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
|
||||
import routes.research_routes as _shim_research # noqa: F401
|
||||
|
||||
|
||||
def test_legacy_and_canonical_research_module_are_same_object():
|
||||
"""``import routes.research_routes`` must alias the canonical module."""
|
||||
legacy = importlib.import_module("routes.research_routes")
|
||||
canonical = importlib.import_module("routes.research.research_routes")
|
||||
assert legacy is canonical, (
|
||||
"routes.research_routes shim must resolve to the canonical "
|
||||
"routes.research.research_routes module object"
|
||||
)
|
||||
|
||||
|
||||
def test_string_targeted_monkeypatch_reaches_canonical(monkeypatch):
|
||||
"""String-targeted ``monkeypatch.setattr`` via the legacy path must reach
|
||||
the canonical module.
|
||||
|
||||
``test_research_owner_scope_routes.py`` patches
|
||||
``"routes.research_routes.DEEP_RESEARCH_DIR"`` as an autouse fixture; for
|
||||
that to take effect at runtime, the legacy module name and the canonical
|
||||
module must be identical.
|
||||
"""
|
||||
legacy = importlib.import_module("routes.research_routes")
|
||||
canonical = importlib.import_module("routes.research.research_routes")
|
||||
|
||||
sentinel = "/tmp/shim-test-sentinel"
|
||||
monkeypatch.setattr("routes.research_routes.DEEP_RESEARCH_DIR", sentinel)
|
||||
assert canonical.DEEP_RESEARCH_DIR == sentinel, (
|
||||
"string-targeted monkeypatch via legacy path did not reach the canonical module"
|
||||
)
|
||||
# restore is handled by monkeypatch fixture teardown
|
||||
assert legacy is canonical
|
||||
Reference in New Issue
Block a user