Skip to content

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

Description

@YaronZaki

Problem Statement

Zero test files exist in quantara/web_app/telegram/. The Telegram bot handles notification delivery for liquidation alerts — critical for user position safety — but has no test coverage for message formatting, notification delivery, or subscription management.

Evidence

  • quantara/web_app/telegram/ directory has no test_ files
  • No tests for notifications.py, texts.py, markups.py, config.py, __main__.py
  • quantara/web_app/tests/ has no Telegram-related test files

Impact

High — untested critical path. Telegram bot failures (missed liquidation alerts, incorrect notifications) go undetected. Users may miss critical position warnings. Notification delivery is a core safety feature for leveraged positions.

Proposed Solution

Add unit tests for: message formatting (texts.py, markups.py), notification delivery logic (notifications.py). Add integration tests for subscription/unsubscription flow with mocked Telegram Bot API.

Acceptance Criteria

  • Unit tests cover message formatting functions in texts.py and markups.py
  • Unit tests cover notification dispatch logic in notifications.py
  • Integration tests cover subscription and unsubscription flow
  • Tests mock Telegram Bot API using aioresponses or httpx mock
  • All tests pass in CI

File Map

  • quantara/web_app/tests/test_telegram.pyNew: unit tests
  • quantara/web_app/test_integration/test_telegram.pyNew: integration tests

Testing Strategy

  • Unit: Test texts.py message templates, markups.py keyboard generation, notifications.py send logic with mocked bot
  • Integration: Test Telegram webhook handling and user subscription flow

Security Considerations

Ensure tests don't send real Telegram messages. Use mocked bot API.

Definition of Done

  • Code implemented and peer-reviewed
  • Tests written and passing
  • PR linked and merged

Labels: testing
Priority: High
Difficulty: Intermediate
Estimated Effort: 1d

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions