swap Money for MoneyAmount, fix a couple of things along the way
This commit is contained in:
parent
ab2ac1ec6a
commit
0947b34ebf
6 changed files with 26 additions and 27 deletions
|
|
@ -108,11 +108,10 @@ def test_get_rates_dry_run_always_returns_42_as_rates():
|
|||
# Check that all rows have the expected rate of 42, 1/42 or 1 and the correct dates
|
||||
for row in rows:
|
||||
assert row["rate"] in (
|
||||
"42",
|
||||
"0.024",
|
||||
"0.02",
|
||||
"0",
|
||||
"1",
|
||||
"42.00000000",
|
||||
"0.02380952",
|
||||
"0.00000000",
|
||||
"1.00000000",
|
||||
), f"Expected rate to be 42, 1/42 or 1, but got {row['rate']}"
|
||||
assert row["rate_date"] in [
|
||||
(some_random_date + datetime.timedelta(days=i)).strftime("%Y-%m-%d")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from decimal import Decimal
|
|||
import pytest
|
||||
from money.currency import Currency
|
||||
|
||||
from xexe.money_amount import DEFAULT_MAX_DECIMALS, MoneyAmount
|
||||
from xexe.money_amount import DEFAULT_MONEY_PRECISION, MoneyAmount
|
||||
|
||||
|
||||
def test_money_amount_simple_creation_works():
|
||||
|
|
@ -23,13 +23,13 @@ def test_money_amount_takes_integer_amounts():
|
|||
def test_money_amount_takes_decimal_amounts():
|
||||
an_amount = MoneyAmount(amount=Decimal(10.5), currency=Currency.USD)
|
||||
|
||||
assert an_amount.amount == Decimal(10.5).quantize(DEFAULT_MAX_DECIMALS)
|
||||
assert an_amount.amount == Decimal(10.5).quantize(DEFAULT_MONEY_PRECISION)
|
||||
|
||||
|
||||
def test_money_amount_takes_proper_strings_amounts():
|
||||
an_amount = MoneyAmount(amount="10.55", currency=Currency.USD)
|
||||
|
||||
assert an_amount.amount == Decimal(10.55).quantize(DEFAULT_MAX_DECIMALS)
|
||||
assert an_amount.amount == Decimal(10.55).quantize(DEFAULT_MONEY_PRECISION)
|
||||
|
||||
|
||||
def test_money_amount_fails_with_ugly_strings():
|
||||
|
|
@ -46,4 +46,4 @@ def test_money_amount_takes_string_for_currency():
|
|||
def test_money_amount_works_with_8_decimal_positions():
|
||||
an_amount = MoneyAmount(amount="1.12345678", currency="USD")
|
||||
|
||||
assert an_amount.amount == Decimal(1.12345678).quantize(DEFAULT_MAX_DECIMALS)
|
||||
assert an_amount.amount == Decimal(1.12345678).quantize(DEFAULT_MONEY_PRECISION)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue