This directory contains unit tests for the Telegram LLM Bot application.
test_telegram_utils.py: Tests for utility functions intelegram_utils.pytest_handlers.py: Tests for command and message handlers inhandlers.pytest_app.py: Tests for the main application inapp.pytest_config.py: Tests for configuration settings inconfig.pyconftest.py: Common fixtures for tests
To run all tests:
# Using make (from project root)
make test
# Using pytest directly
pytestTo run tests with coverage:
# Using make (from project root)
make test-cov
# Using pytest directly
pytest --cov=.To run tests in Docker:
# Using make (from project root)
make docker-test
make docker-test-covTo run a specific test file:
pytest tests/test_telegram_utils.pyThe tests require the following packages:
- pytest
- pytest-asyncio
- pytest-cov
- unittest.mock (part of the Python standard library)
You can install them with:
# Using poetry
poetry install --with dev
# Using pip
pip install pytest pytest-asyncio pytest-cov- The tests use mocking extensively to avoid making actual API calls or database operations.
- Async functions are tested using the
pytest-asyncioplugin. - The
@restricteddecorator is mocked to allow testing protected functions without authentication.