def test_buy_banana(): """ Given that "banana" is purchased, a ValueError should be raised. """ with pytest.raises(ValueError): buy_product('banana', 5) # Random value of 5 balance
def test_drink_with_a_274_should_raise_insufficient_funds(): """ Given that a drink is attempted to be purchased with a balance of 274, an InsufficientFunds exception should be raised. """ with pytest.raises(InsufficientFunds): buy_product('drink', 274)
def test_insufficient_funds_chips(): """ Asserts when the customer has not entered enough funds, the item cannot be purchased. In this test, the product costs 225, the customer has 224. """ with pytest.raises(vending_machine.InsufficientFunds): assert vending_machine.buy_product("chips", 224)
def test_buy_candy(): """ Given that candy is purchased with a balance of 315, 0 should be returned. """ assert buy_product('candy', 315) == 0
def test_buy_chips(): """ Given that chips are purchased with a balance of 225, 0 should be returned. """ assert buy_product('chips', 225) == 0
def test_drink_275(): assert vending_machine.buy_product('drink', 275) == 0
def test_drink_274(): with pytest.raises(InsufficientFunds): vending_machine.buy_product('drink', 274)
def test_buy_chips(): """ Asserts that chips can be purchased """ assert vending_machine.buy_product("chips", 225) == 0
def test_candy_315(): assert vending_machine.buy_product('candy', 315) == 0
def test_chips_225(): assert vending_machine.buy_product('chips', 225) == 0
def test_buy_drink(): """ Asserts that a drink can be purchased """ assert vending_machine.buy_product("drink", 275) == 0
def test_calculate_remaining_funds(): """ Asserts when the customer buys a drink with 300, and the drink costs 275. 25 cents will remain. """ assert vending_machine.buy_product("drink", 300) == 25
def test_buy_candy(): """ Asserts that a drink can be purchased """ assert vending_machine.buy_product("candy", 315) == 0
def test_buy_a_drink_with_remaining_balance(): """ Given that the balance exceeds the cost of a drink, the difference should be returned. """ assert buy_product('drink', 300) == 25
def test_banana(): with pytest.raises(ValueError): vending_machine.buy_product('banana', 275)
def test_buy_a_drink(): """ Given that "drink" is purchased with an exact balance, the balance returned should be 0. """ assert buy_product('drink', 275) == 0
def test_buy_banana(): """ Asserts that a value error is thrown when a banana is attempted to be purchased """ with pytest.raises(ValueError): assert vending_machine.buy_product("banana", 275)