CI / ruff · pytest (pull_request) Successful in 2m33s
- CRISIS_BLOCKING (default off for the demo): a crisis no longer locks the dialog; the message and the doctor's acute alert still happen. The clinical protocol (blocking, immediate stop) stays behind the flag and keeps its tests. - Crisis signals inside a questionnaire (intake red flags, high C-SSRS, PHQ-9 item 9) no longer stop it: the test is finished and the crisis message comes at the end; the doctor's alert is raised at once/at the end. - Weapon access: asked and stored, triggers nothing (rule disabled, no red flag, no safety block). - ЕМИАС demo persona is «Никита В.»; the one-click demo stays «Андрей С.». Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.8 KiB
Python
37 lines
1.8 KiB
Python
"""Demo mode (crisis_blocking off): a crisis signal inside a questionnaire does not stop it; the crisis message
|
|
comes at the end and blocks nothing; the weapon question triggers nothing."""
|
|
|
|
import pytest
|
|
|
|
from app.db.clinical import Alert
|
|
from tests.test_dialog_intake import answer_button, complete_existing, press, released, rows # noqa: F401
|
|
|
|
|
|
@pytest.fixture
|
|
def non_blocking(monkeypatch):
|
|
from app.config import get_settings
|
|
|
|
monkeypatch.setattr(get_settings(), "crisis_blocking", False)
|
|
|
|
|
|
async def test_red_flag_does_not_stop_the_questionnaire(released, non_blocking): # noqa: F811
|
|
replies = await press(released, "intake:start")
|
|
replies = await press(released, answer_button(replies, {"rf_psychosis": 0})) # «Да» on a red flag
|
|
assert not any(r.kind == "crisis" for r in replies), "no crisis window in the middle of the test"
|
|
assert any(r.buttons for r in replies), "the next question is asked"
|
|
(row,) = await rows()
|
|
assert row.status != "interrupted" and row.details["pending_urgent"]["code"] == "red_flag_psychosis"
|
|
replies = await complete_existing(released, replies, {})
|
|
assert any(r.kind == "crisis" for r in replies), "the crisis message comes at the end"
|
|
assert any(a.code == "red_flag_psychosis" and a.level == "acute" for a in await rows(Alert))
|
|
|
|
|
|
async def test_weapon_answer_triggers_nothing(released, non_blocking): # noqa: F811
|
|
replies = await press(released, "intake:start")
|
|
for _ in range(2): # psychosis, harm to others: «Нет»
|
|
replies = await press(released, answer_button(replies))
|
|
replies = await press(released, answer_button(replies, {"rf_weapons": 0})) # «Да» on weapons
|
|
assert not any(r.kind == "crisis" for r in replies)
|
|
(row,) = await rows()
|
|
assert not row.details.get("pending_urgent")
|