def test_dollar_amount_str_adds_commas_to_thousands(): """ Asserts that the returned string includes commas between thousands. """ amount = money.DollarAmount('123456') assert str(amount) == '$123,456.00'
def test_dollar_amount_str(): """ Asserts that the str() of DollarAmount renders a friendly, readable value """ amount = money.DollarAmount('55.2') assert str(amount) == '$55.20'
def test_dollar_amount_repr(): """ Asserts that the repr() of DollarAmount can be used to construct an identical object. """ amount = money.DollarAmount('9.9') expected = "DollarAmount('9.9')" assert repr(amount) == expected
def test_get_balance_returns_the_sum_of_inserted_coins(): """ Given each type of coin is inserted, a dollar amount of 3.40 should be returned. """ machine = VendingMachine() machine.insert_coin(money.Toonie()) machine.insert_coin(money.Loonie()) machine.insert_coin(money.Quarter()) machine.insert_coin(money.TenCent()) machine.insert_coin(money.FiveCent()) assert machine.get_balance() == money.DollarAmount('3.40')
class OneCent(money.Coin): """One cent coin.""" value = money.DollarAmount('0.01')