Files
smeta-web/tests/test_balance_golden.py
T

30 lines
870 B
Python

"""P3.1a: копейки и ROUND_HALF_UP — golden из плана."""
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(ROOT))
import balance # noqa: E402
def test_golden_1_ruble_minus_71_kopecks():
st = balance.compose(100, 0.71, 0.0, 0)
assert st["balance_kop"] == 29
assert st["balance_rub"] == 0.29
def test_golden_half_kopeck_rounds_up_not_even():
st = balance.compose(100, 0.125 + 0.25, 0.0, 0)
assert st["balance_kop"] == 63
assert st["balance_rub"] == 0.63
def test_zero_entries_still_none():
assert balance.compose(0, 0.0, 0.0, 0) is None
def test_dust_charge_does_not_create_account_and_low_is_not_truncated():
assert balance.compose(0, 0.0008, 0.0, 0) is None
st = balance.compose(29, 0.27, 0.0, 0)
assert st["balance_kop"] == 2 and st["low"] is True