mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 16:10:09 +08:00
* fix(settings): answer 404 for unknown connection-test run ids * chore(api): refresh router index for the settings route change tests/api/test_router_loader.py::test_repository_index_matches_router_sources checks the fingerprint of router sources; regenerated with scripts/build_router_index.py. --------- Co-authored-by: zszz3 <91608029+zszz3@users.noreply.github.com>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
"""``ConfigTestRunner`` lookups must not raise for an unknown run id.
|
|
|
|
Runs live in memory only. A restart, or a Settings page that reconnects with an
|
|
id from an earlier process, asks for a run the runner no longer has; that is a
|
|
normal outcome, not a crash.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from deeptutor.services.config import test_runner as test_runner_module
|
|
from deeptutor.services.config.test_runner import ConfigTestRunner
|
|
|
|
|
|
class _NoThread:
|
|
"""Keep ``start`` from launching the real probing thread."""
|
|
|
|
def __init__(self, *args: object, **kwargs: object) -> None:
|
|
pass
|
|
|
|
def start(self) -> None:
|
|
pass
|
|
|
|
|
|
@pytest.fixture
|
|
def runner(monkeypatch: pytest.MonkeyPatch) -> ConfigTestRunner:
|
|
monkeypatch.setattr(test_runner_module.threading, "Thread", _NoThread)
|
|
return ConfigTestRunner()
|
|
|
|
|
|
def test_get_unknown_run_returns_none(runner: ConfigTestRunner) -> None:
|
|
assert runner.get("llm-never-started") is None
|
|
|
|
|
|
def test_get_started_run_returns_it(runner: ConfigTestRunner) -> None:
|
|
run = runner.start("llm", catalog={})
|
|
|
|
assert runner.get(run.id) is run
|
|
|
|
|
|
def test_cancel_unknown_run_reports_false(runner: ConfigTestRunner) -> None:
|
|
assert runner.cancel("llm-never-started") is False
|
|
|
|
|
|
def test_cancel_known_run_sets_flag_and_reports_true(runner: ConfigTestRunner) -> None:
|
|
run = runner.start("llm", catalog={})
|
|
|
|
assert runner.cancel(run.id) is True
|
|
assert run.cancelled
|