9a2aea038a
- 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
27 lines
1015 B
Python
27 lines
1015 B
Python
import pytest
|
|
|
|
from app.config import settings
|
|
from app.database.models import PromoGroup
|
|
|
|
|
|
@pytest.fixture
|
|
def base_discount_settings(monkeypatch):
|
|
monkeypatch.setattr(settings, 'BASE_PROMO_GROUP_PERIOD_DISCOUNTS_ENABLED', True)
|
|
monkeypatch.setattr(settings, 'BASE_PROMO_GROUP_PERIOD_DISCOUNTS', '60:15')
|
|
|
|
|
|
def test_base_promo_discount_applies_to_all_categories(base_discount_settings):
|
|
promo_group = PromoGroup(name='Default', is_default=True)
|
|
|
|
assert promo_group.get_discount_percent('period', 60) == 15
|
|
assert promo_group.get_discount_percent('servers', 60) == 15
|
|
assert promo_group.get_discount_percent('traffic', 60) == 15
|
|
assert promo_group.get_discount_percent('devices', 60) == 15
|
|
|
|
|
|
def test_specific_category_discount_overrides_base(base_discount_settings):
|
|
promo_group = PromoGroup(name='Default', is_default=True, server_discount_percent=5)
|
|
|
|
assert promo_group.get_discount_percent('servers', 60) == 5
|
|
assert promo_group.get_discount_percent('devices', 60) == 15
|