def test_get_change_when_balance_is_one_dollar(): """ Given a balance of $1, a loonie should be returned. """ machine = VendingMachine() for _ in range(4): # Repeat 4 times machine.insert_coin(money.Quarter()) assert machine.get_change() == [money.Loonie()]
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')
def test_get_change_balance_is_all_coins(): """ Asserts that different coins are returned to complete balance. """ machine = VendingMachine() coins = [ money.Toonie(), money.Loonie(), money.Quarter(), money.TenCent(), money.FiveCent() ] for coin in coins: machine.insert_coin(coin) assert machine.get_change() == coins
def test_get_change_balance_is_multiple_coins(): """ Asserts that duplicate coins are returned when there is a leftover balance. """ machine = VendingMachine() coins = [ money.Loonie(), money.Quarter(), money.Quarter(), money.TenCent(), money.TenCent() ] for coin in coins: machine.insert_coin(coin) assert machine.get_change() == coins
def test_insert_loonie(): """ Given a loonie, no error should be raised. """ machine = VendingMachine() machine.insert_coin(money.Loonie())