mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-08-26 19:04:18 +02:00
Merge pull request #6081 from ydonghao/refactor/routes-task-to-subdir
refactor(routes): move task domain into routes/task/ subpackage
This commit is contained in:
commit
2a6b09b968
9 changed files with 1225 additions and 1181 deletions
2
app.py
2
app.py
|
|
@ -784,7 +784,7 @@ from src.task_scheduler import TaskScheduler
|
|||
task_scheduler = TaskScheduler(session_manager)
|
||||
from src.event_bus import set_task_scheduler
|
||||
set_task_scheduler(task_scheduler)
|
||||
from routes.task_routes import setup_task_routes
|
||||
from routes.task.task_routes import setup_task_routes
|
||||
app.include_router(setup_task_routes(task_scheduler))
|
||||
|
||||
from routes.assistant_routes import setup_assistant_routes
|
||||
|
|
|
|||
5
routes/task/__init__.py
Normal file
5
routes/task/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"""Task route domain package (slice 2p, #4082/#4071).
|
||||
|
||||
Contains task_routes.py, migrated from the flat routes/ directory.
|
||||
Backward-compat shim at routes/task_routes.py re-exports from here.
|
||||
"""
|
||||
1181
routes/task/task_routes.py
Normal file
1181
routes/task/task_routes.py
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -16,7 +16,7 @@ def test_registered_manual_compaction_uses_session_owner_for_utility_endpoint():
|
|||
|
||||
|
||||
def test_task_name_generation_uses_owner_scoped_session_endpoint():
|
||||
src = _src("routes/task_routes.py")
|
||||
src = _src("routes/task/task_routes.py")
|
||||
|
||||
assert "async def _generate_task_name(prompt: str, owner: Optional[str] = None)" in src
|
||||
assert "q = q.filter(DbSession.owner == owner)" in src
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ def test_no_hardcoded_loopback_left_in_call_sites():
|
|||
"src/tools/_common.py",
|
||||
"src/cookbook_serve_lifecycle.py",
|
||||
"src/builtin_actions.py",
|
||||
"routes/task_routes.py",
|
||||
"routes/task/task_routes.py",
|
||||
):
|
||||
text = (root / rel).read_text(encoding="utf-8")
|
||||
# Allow it only inside comments; flag any code occurrence.
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def test_calendar_quick_parse_resolves_with_owner_scope():
|
|||
|
||||
|
||||
def test_task_parse_resolves_with_owner_scope():
|
||||
body = _function_source("routes/task_routes.py", "parse_task")
|
||||
body = _function_source("routes/task/task_routes.py", "parse_task")
|
||||
assert "user = _owner(request)" in body
|
||||
assert 'resolve_endpoint("utility", owner=user or None)' in body
|
||||
assert 'resolve_endpoint("default", owner=user or None)' in body
|
||||
|
|
|
|||
20
tests/test_task_routes_shim.py
Normal file
20
tests/test_task_routes_shim.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
"""Regression test for the task route shim (slice 2p, #4082/#4071).
|
||||
|
||||
The backward-compat shim at ``routes/task_routes.py`` uses ``sys.modules``
|
||||
replacement so the legacy import path and the canonical ``routes.task.*``
|
||||
path resolve to the *same* module object. This is required because multiple
|
||||
tests do ``import routes.task_routes as task_routes`` followed by
|
||||
``monkeypatch.setattr(task_routes, "SessionLocal", ...)`` /
|
||||
``"get_current_user"``, and test_auth_regressions.py reads
|
||||
``task_routes.__file__`` for source introspection.
|
||||
"""
|
||||
|
||||
import importlib
|
||||
|
||||
import routes.task_routes as _shim_task # noqa: F401
|
||||
|
||||
|
||||
def test_legacy_and_canonical_task_module_are_same_object():
|
||||
legacy = importlib.import_module("routes.task_routes")
|
||||
canonical = importlib.import_module("routes.task.task_routes")
|
||||
assert legacy is canonical
|
||||
|
|
@ -87,6 +87,7 @@ def test_webhook_trigger_handler_still_validates_token():
|
|||
routes_path = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
|
||||
"routes",
|
||||
"task",
|
||||
"task_routes.py",
|
||||
)
|
||||
with open(routes_path, encoding="utf-8") as fh:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue