feat(bot): /start without a code on the demo stand opens a private copy of veteran Andrey
CI / ruff · pytest (pull_request) Successful in 2m45s
CI / ruff · pytest (pull_request) Successful in 2m45s
Refs #108 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+17
-1
@@ -22,6 +22,7 @@ from app.channels.telegram import (
|
||||
render_markup,
|
||||
split_text,
|
||||
)
|
||||
from app.config import get_settings
|
||||
from app.db import identity_repo, session
|
||||
from app.db.bootstrap import init_db
|
||||
from app.dialog.contracts import Button, Event, Reply
|
||||
@@ -163,7 +164,10 @@ async def test_verified_token_without_identity_record(dbs: None, engine: Recordi
|
||||
assert sender.texts == [load_texts().code_invalid]
|
||||
|
||||
|
||||
async def test_unbound_chat_gets_not_connected(dbs: None, engine: RecordingEngine) -> None:
|
||||
async def test_unbound_chat_gets_not_connected(
|
||||
dbs: None, engine: RecordingEngine, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.setattr(get_settings(), "demo_clock", False)
|
||||
sender = FakeSender()
|
||||
channel = TelegramChannel(sender)
|
||||
await channel.on_start(CHAT, None)
|
||||
@@ -251,6 +255,18 @@ async def test_outbox_pushes_to_bound_chat_and_falls_back(dbs: None, engine: Rec
|
||||
assert [r.text for r in fallback.drain(TOKEN2)] == ["Как вы сегодня?"]
|
||||
|
||||
|
||||
async def test_start_without_code_on_demo_stand_binds_a_demo_copy(
|
||||
dbs: None, engine: RecordingEngine, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.setattr(get_settings(), "demo_clock", True)
|
||||
sender = FakeSender()
|
||||
channel = TelegramChannel(sender)
|
||||
await channel.on_start(CHAT, None)
|
||||
token = await channel.directory.token_for(CHAT)
|
||||
assert token is not None and token.startswith("tok-andrey-")
|
||||
assert [c[1].type for c in engine.calls] == ["start"]
|
||||
|
||||
|
||||
async def test_start_is_noop_without_token(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(telegram, "get_settings", lambda: type("S", (), {"tg_bot_token": ""})())
|
||||
before = integrations.outbox
|
||||
|
||||
Reference in New Issue
Block a user