Skip to content

test: add unit tests for Telegram bot (HMAC, retry recursion, /start flows)#175

Merged
YaronZaki merged 1 commit into
Quantarq:mainfrom
Alqku:fix/issue-62-telegram-tests
Jun 28, 2026
Merged

test: add unit tests for Telegram bot (HMAC, retry recursion, /start flows)#175
YaronZaki merged 1 commit into
Quantarq:mainfrom
Alqku:fix/issue-62-telegram-tests

Conversation

@Alqku

@Alqku Alqku commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds quantara/web_app/tests/test_telegram.py covering the Telegram bot's critical logic (HMAC initData verification, retry recursion on TelegramRetryAfter, both /start flows, plus the except Exception branch in send_health_ratio_notification). Uses deterministic mocking of aiogram Bot calls so the suite is hermetic and CI-friendly.

Changes

  • tests/test_telegram.py covers six scenarios for utils.check_telegram_authorization, five scenarios for notifications.send_health_ratio_notification (including the non-retry exception path), and both the basic and deep-link /start flows from handlers/command.py.
  • autouse=True fixture snapshots and restores notifications.bot to prevent cross-test pollution.
  • Tighter assertion on the formatted HEALTH_RATIO_WARNING_MESSAGE so future refactors that drop the warning template are caught.

Testing

  • python -m py_compile clean on the new test file.
  • pytest-asyncio is configured with asyncio_mode = "strict" in quantara/pyproject.toml so every async test method is explicitly marked.
  • Mocks at the bot.send_message boundary; no network calls or bot token required.

Closes #62

@Alqku

Alqku commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@github-actions re-run ci

@Alqku Alqku force-pushed the fix/issue-62-telegram-tests branch from 14d0b58 to 3857e41 Compare June 27, 2026 09:13

@YaronZaki YaronZaki left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@YaronZaki YaronZaki merged commit 079b04e into Quantarq:main Jun 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Add unit and integration tests for Telegram bot notification system

2 participants