Example #1
0
    def test_refund(self):
        machine = VendingMachine()
        machine.treat_coin(Coin(500))
        machine.treat_coin(Coin(100))
        machine.treat_coin(Coin(50))

        assert [Coin(500).amount,
                Coin(100).amount,
                Coin(50).amount] == [coin.amount for coin in machine.refund()]
        assert [] == [coin.amount for coin in machine.contained]
Example #2
0
 def test_coin_total(self):
     machine = VendingMachine()
     machine.treat_coin(Coin(500))
     machine.treat_coin(Coin(100))
     machine.treat_coin(Coin(50))
     assert 500 + 100 + 50 == machine.coin_total()
Example #3
0
    def test_treat_coin(self):
        machine = VendingMachine()
        machine.treat_coin(Coin(50))
        assert machine.contained[0].amount == Coin(50).amount

        assert machine.treat_coin(Coin(20)).amount == 20