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
|
|
@ -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