示例#1
0
    def test_catch_coin(self):
        machine = VendingMachine()
        machine.catch_coin(Coin(50))
        assert Coin(50).amount == machine.contained[0].amount

        machine_invalid = VendingMachine()
        coin30 = Coin(30)
        result = machine_invalid.catch_coin(coin30)
        assert result == coin30
        assert machine_invalid.contained == []
示例#2
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]
示例#3
0
    def test_refund(self):
        machine = VendingMachine()
        coin500 = Coin(500)
        coin100 = Coin(100)
        coin50 = Coin(50)
        machine.catch_coin(coin500)
        machine.catch_coin(coin100)
        machine.catch_coin(coin50)

        assert [coin500, coin100, coin50] == machine.refund()
        assert [] == machine.contained
示例#4
0
 def test_coin_total(self):
     machine = VendingMachine()
     machine.catch_coin(Coin(500))
     machine.catch_coin(Coin(100))
     machine.catch_coin(Coin(50))
     assert 500 + 100 + 50 == machine.coin_total()
示例#5
0
 def test_check_coin(self):
     machine = VendingMachine()
     assert machine.check_coin(Coin(50)) == True
     assert machine.check_coin(Coin(40)) == False
示例#6
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