Test dashboard: full menu system, all-service tests, filtering
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m11s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m11s
- Run tests for all 10 services via per-service pytest subprocesses - Group results by service with section headers - Clickable summary cards filter by outcome (passed/failed/errors/skipped) - Service filter nav using ~nav-link buttons in menu bar - Full menu integration: ~header-row + ~header-child + ~menu-row - Show logo image via cart-mini rendering - Mount full service directories in docker-compose for test access - Add 24 unit test files across 9 services Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
47
cart/tests/test_total.py
Normal file
47
cart/tests/test_total.py
Normal file
@@ -0,0 +1,47 @@
|
||||
"""Unit tests for cart total calculations."""
|
||||
from __future__ import annotations
|
||||
|
||||
from decimal import Decimal
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from cart.bp.cart.services.total import total
|
||||
|
||||
|
||||
def _item(special=None, regular=None, qty=1):
|
||||
return SimpleNamespace(
|
||||
product_special_price=special,
|
||||
product_regular_price=regular,
|
||||
quantity=qty,
|
||||
)
|
||||
|
||||
|
||||
class TestTotal:
|
||||
def test_empty_cart(self):
|
||||
assert total([]) == 0
|
||||
|
||||
def test_regular_price_only(self):
|
||||
result = total([_item(regular=10.0, qty=2)])
|
||||
assert result == Decimal("20.0")
|
||||
|
||||
def test_special_price_preferred(self):
|
||||
result = total([_item(special=5.0, regular=10.0, qty=1)])
|
||||
assert result == Decimal("5.0")
|
||||
|
||||
def test_none_prices_excluded(self):
|
||||
result = total([_item(special=None, regular=None, qty=1)])
|
||||
assert result == 0
|
||||
|
||||
def test_mixed_items(self):
|
||||
items = [
|
||||
_item(special=5.0, qty=2), # 10
|
||||
_item(regular=3.0, qty=3), # 9
|
||||
_item(), # excluded
|
||||
]
|
||||
result = total(items)
|
||||
assert result == Decimal("19.0")
|
||||
|
||||
def test_quantity_multiplication(self):
|
||||
result = total([_item(regular=7.5, qty=4)])
|
||||
assert result == Decimal("30.0")
|
||||
Reference in New Issue
Block a user