kin: BATON-008-backend_dev
This commit is contained in:
parent
e21bcb1eb4
commit
4c9fec17de
11 changed files with 651 additions and 4 deletions
|
|
@ -73,13 +73,15 @@ def make_app_client():
|
|||
"""
|
||||
Async context manager that:
|
||||
1. Assigns a fresh temp-file DB path
|
||||
2. Mocks Telegram setWebhook and sendMessage
|
||||
2. Mocks Telegram setWebhook, sendMessage, answerCallbackQuery, editMessageText
|
||||
3. Runs the FastAPI lifespan (startup → test → shutdown)
|
||||
4. Yields an httpx.AsyncClient wired to the app
|
||||
"""
|
||||
tg_set_url = f"https://api.telegram.org/bot{config.BOT_TOKEN}/setWebhook"
|
||||
send_url = f"https://api.telegram.org/bot{config.BOT_TOKEN}/sendMessage"
|
||||
get_me_url = f"https://api.telegram.org/bot{config.BOT_TOKEN}/getMe"
|
||||
answer_cb_url = f"https://api.telegram.org/bot{config.BOT_TOKEN}/answerCallbackQuery"
|
||||
edit_msg_url = f"https://api.telegram.org/bot{config.BOT_TOKEN}/editMessageText"
|
||||
|
||||
@contextlib.asynccontextmanager
|
||||
async def _ctx():
|
||||
|
|
@ -96,6 +98,12 @@ def make_app_client():
|
|||
mock_router.post(send_url).mock(
|
||||
return_value=httpx.Response(200, json={"ok": True})
|
||||
)
|
||||
mock_router.post(answer_cb_url).mock(
|
||||
return_value=httpx.Response(200, json={"ok": True})
|
||||
)
|
||||
mock_router.post(edit_msg_url).mock(
|
||||
return_value=httpx.Response(200, json={"ok": True})
|
||||
)
|
||||
|
||||
with mock_router:
|
||||
async with app.router.lifespan_context(app):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue