feat(dashboard): console fallbacks for the real API (#12)
CI / ruff · pytest (pull_request) Successful in 1m37s
CI / ruff · pytest (pull_request) Successful in 1m37s
- personas degrade: /demo/personas → doctor's patients (hero first) → env token - scenario file guessed from the transliterated first name (andrey.jsonl), like the backend - «Подключить демо-пациента»: connects the synthetic hero via /patients/connect when no seed - connect code prefilled from ?code= of the console link Refs #17 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,14 @@ from console.playback import ( # noqa: E402
|
||||
resolve_press,
|
||||
target_datetime,
|
||||
)
|
||||
from console.scenario import Action, load_scenario, parse_action, parse_scenario # noqa: E402
|
||||
from console.scenario import ( # noqa: E402
|
||||
Action,
|
||||
default_scenario_path,
|
||||
load_scenario,
|
||||
parse_action,
|
||||
parse_scenario,
|
||||
persona_slug,
|
||||
)
|
||||
|
||||
MSK = timezone(timedelta(hours=3))
|
||||
|
||||
@@ -388,3 +395,25 @@ def test_console_api_errors_become_api_error_and_personas_fall_back(monkeypatch)
|
||||
ok = _client(lambda req: httpx.Response(200, json=[{"token": "tok-andrey", "display_name": "Андрей С."}]))
|
||||
personas, error = personas_or_fallback(ok)
|
||||
assert error is None and personas[0]["display_name"] == "Андрей С."
|
||||
|
||||
|
||||
def test_personas_fall_back_to_doctor_patients_with_hero_first():
|
||||
def handler(req: httpx.Request) -> httpx.Response:
|
||||
if req.url.path.endswith("/demo/personas"):
|
||||
return httpx.Response(200, json=[])
|
||||
return httpx.Response(
|
||||
200, json=[{"token": "h1", "display_name": "Сергей П."}, {"token": "h2", "display_name": "Андрей С."}]
|
||||
)
|
||||
|
||||
personas, error = personas_or_fallback(_client(handler))
|
||||
assert [p["token"] for p in personas] == ["h2", "h1"] and "пациенты врача" in error
|
||||
|
||||
|
||||
def test_scenario_path_guessed_from_name_or_token(tmp_path):
|
||||
(tmp_path / "data" / "synthetic").mkdir(parents=True)
|
||||
(tmp_path / "data" / "synthetic" / "andrey.jsonl").write_text("", encoding="utf-8")
|
||||
assert persona_slug("Андрей С.") == "andrey" and persona_slug("Наталья Ф.") == "natalya"
|
||||
assert default_scenario_path({"token": "h", "display_name": "Андрей С."}, tmp_path) == "data/synthetic/andrey.jsonl"
|
||||
assert default_scenario_path({"token": "tok-andrey"}, tmp_path) == "data/synthetic/andrey.jsonl"
|
||||
assert default_scenario_path({"token": "x", "display_name": "Ольга Н."}, tmp_path) is None
|
||||
assert default_scenario_path({"token": "x", "scenario": "s.jsonl"}, tmp_path) == "s.jsonl"
|
||||
|
||||
Reference in New Issue
Block a user