Files
remnawave-bedolaga-telegram…/tests/utils/test_pricing_utils.py
c0mrade 9a2aea038a chore: add uv package manager and ruff linter configuration
- Add pyproject.toml with uv and ruff configuration
- Pin Python version to 3.13 via .python-version
- Add Makefile commands: lint, format, fix
- Apply ruff formatting to entire codebase
- Remove unused imports (base64 in yookassa/simple_subscription)
- Update .gitignore for new config files
2026-01-24 17:45:27 +03:00

51 lines
2.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Тесты для утилит ценообразования и форматирования цен.
Этот модуль тестирует функции из app/utils/pricing_utils.py и app/localization/texts.py,
особенно функции отображения цен со скидками на кнопках подписки.
"""
from unittest.mock import MagicMock, patch
from app.localization.texts import _build_dynamic_values
# DEPRECATED: format_period_option_label tests removed - function replaced with unified price_display system
class TestBuildDynamicValues:
"""
Тесты для функции _build_dynamic_values из texts.py.
NOTE: PERIOD_*_DAYS константы были удалены из _build_dynamic_values,
так как теперь кнопки периодов генерируются динамически в get_subscription_period_keyboard()
с учетом персональных скидок пользователя.
"""
@patch('app.localization.texts.settings')
def test_returns_empty_dict_for_unknown_language(self, mock_settings: MagicMock) -> None:
"""Неизвестный язык должен возвращать пустой словарь."""
result = _build_dynamic_values('fr-FR') # Французский не поддерживается
assert result == {}
@patch('app.localization.texts.settings')
def test_traffic_keys_also_generated(self, mock_settings: MagicMock) -> None:
"""Должны генерироваться ключи трафика и другие динамические значения."""
# Настройка моков для traffic цен
mock_settings.format_price = lambda x: f'{x // 100}'
mock_settings.PRICE_TRAFFIC_5GB = 10000
mock_settings.PRICE_TRAFFIC_10GB = 20000
mock_settings.PRICE_TRAFFIC_25GB = 30000
mock_settings.PRICE_TRAFFIC_50GB = 40000
mock_settings.PRICE_TRAFFIC_100GB = 50000
mock_settings.PRICE_TRAFFIC_250GB = 60000
mock_settings.PRICE_TRAFFIC_UNLIMITED = 70000
result = _build_dynamic_values('ru-RU')
# Проверяем наличие ключей трафика
assert 'TRAFFIC_5GB' in result
assert 'TRAFFIC_10GB' in result
assert 'TRAFFIC_UNLIMITED' in result
assert 'SUPPORT_INFO' in result