Exemple #1
0
 def test_add_six_others(self):
     burger = Burger()
     with pytest.raises(InvalidQuantityException):
         burger.add_item(other1, 6)
     assert len(burger.components) == 0
     assert len(burger) == 0
     assert burger.price == 0
Exemple #2
0
 def test_add_five_other(self):
     burger = Burger()
     burger.add_item(other1, 5)
     assert burger._num_others == 5
     assert len(burger) == 5
     assert len(burger.components) == 1
     assert burger.price == 60
Exemple #3
0
 def test_add_four_buns(self):
     burger = Burger()
     burger.add_item(bun1, 4)
     assert burger._num_buns == 4
     assert len(burger) == 4
     assert len(burger.components) == 1
     assert burger.price == 44
Exemple #4
0
 def test_add_one_bun_success(self):
     burger = Burger()
     burger.add_item(bun1, 1)
     assert burger._num_buns == 1
     assert len(burger) == 1
     assert len(burger.components) == 1
     assert burger.price == 11
Exemple #5
0
 def test_add_five_buns(self):
     burger = Burger()
     with pytest.raises(InvalidQuantityException):
         burger.add_item(bun1, 5)
     assert len(burger.components) == 0
     assert len(burger) == 0
     assert burger.price == 0
Exemple #6
0
 def test_add_one_other_success(self):
     burger = Burger()
     burger.add_item(other1, 1)
     assert burger._num_others == 1
     assert len(burger) == 1
     assert len(burger.components) == 1
     assert burger.price == 12
Exemple #7
0
 def test_add_different_buns(self):
     burger = Burger()
     burger.add_item(bun1, 1)
     burger.add_item(bun2, 3)
     assert burger._num_buns == 4
     assert len(burger) == 4
     assert len(burger.components) == 2
     assert burger.price == 74
Exemple #8
0
 def test_add_different_others(self):
     burger = Burger()
     burger.add_item(other1, 2)
     burger.add_item(other2, 3)
     assert burger._num_others == 5
     assert len(burger) == 5
     assert len(burger.components) == 2
     assert burger.price == 90
 def test_checkout_all(self, restaurant_fixture):
     order = Order()
     #adding a burger
     burger = Burger()
     bun = restaurant_fixture.menu.get_item("Bun")
     patty = restaurant_fixture.menu.get_item("Patty")
     cheese = restaurant_fixture.menu.get_item("Cheese")
     burger.add_item(bun, 2)
     burger.add_item(patty, 1)
     burger.add_item(cheese, 1)
     order.add_main(burger)
     #adding sides and drinks
     coke = restaurant_fixture.menu.get_item("Canned Coke")
     nugget = restaurant_fixture.menu.get_item("Small Chicken Nugget")
     order.add_others(coke, 1)
     order.add_others(nugget, 1)
     #placing the order and checking out
     restaurant_fixture.place_order(order)
     restaurant_fixture.checkout(1)
     assert restaurant_fixture.inventory.items[0].quantity == 98
     assert restaurant_fixture.inventory.items[1].quantity == 99
     assert restaurant_fixture.inventory.items[2].quantity == 99
     assert restaurant_fixture.inventory.items[3].quantity == 99
     assert restaurant_fixture.inventory.items[4].quantity == 94
     assert len(restaurant_fixture.orders) == 1
 def test_display_burger(self, restaurant_fixture, capsys):
     burger = Burger()
     bun = restaurant_fixture.menu.get_item("Bun")
     patty = restaurant_fixture.menu.get_item("Patty")
     cheese = restaurant_fixture.menu.get_item("Cheese")
     burger.add_item(bun, 2)
     burger.add_item(patty, 1)
     burger.add_item(cheese, 1)
     burger.show_content(restaurant_fixture.menu)
     expected_output = ("Name\t\tQuantity\tPrice\n"
                        "Bun\t\t2\t\t$10 * 2\n"
                        "Patty\t\t1\t\t$10 * 1\n"
                        "Cheese\t\t1\t\t$10 * 1\n"
                        "Total: $40\n")
     assert capsys.readouterr().out == expected_output
Exemple #11
0
def test_burger():
    b = Burger()
    b.add_item(patty1, 1)
    b.add_item(patty2, 1)
    b.add_item(bun1, 2)
    b.add_item(bun2, 1)
    b.add_item(other1, 1)

    return b
Exemple #12
0
 def test_add_too_many_different_patties(self):
     burger = Burger()
     burger.add_item(bun1, 2)
     burger.add_item(patty1, 2)
     with pytest.raises(InvalidQuantityException):
         burger.add_item(patty2, 5)
     assert burger.num_patties == 2
     assert len(burger) == 4
     assert burger.price == 42
Exemple #13
0
 def test_update_invalid_others(self):
     burger = Burger()
     burger.add_item(other1, 1)
     with pytest.raises(ValueError):
         burger.update_qty(other2, 1)
     assert burger.num_others == 1
     assert len(burger) == 1
Exemple #14
0
 def test_update_other(self):
     burger = Burger()
     burger.add_item(other1, 1)
     burger.update_qty(other1, 2)
     assert burger.num_others == 2
     assert burger.price == 24
     assert len(burger) == 2
Exemple #15
0
 def test_update_patty(self):
     burger = Burger()
     burger.add_item(patty1, 1)
     burger.update_qty(patty1, 2)
     assert burger.num_patties == 2
     assert burger.price == 20
     assert len(burger) == 2
Exemple #16
0
 def test_add_different_patties(self):
     burger = Burger()
     burger.add_item(bun1, 3)
     burger.add_item(patty1, 3)
     assert burger.num_patties == 3
     assert len(burger) == 6
     assert burger.price == 63
Exemple #17
0
 def test_update_bun(self):
     burger = Burger()
     burger.add_item(bun1, 1)
     burger.update_qty(bun1, 2)
     assert burger.num_buns == 2
     assert burger.price == 22
     assert len(burger) == 2
Exemple #18
0
 def test_add_one_patty(self):
     burger = Burger()
     burger.add_item(bun1, 2)
     burger.add_item(patty1, 1)
     assert burger._num_patties == 1
     assert len(burger) == 3
     assert len(burger.components) == 2
     assert burger.price == 32
Exemple #19
0
 def test_add_too_many_patties_in_one_go(self):
     burger = Burger()
     burger.add_item(bun1, 2)
     with pytest.raises(InvalidQuantityException):
         burger.add_item(patty1, 7)
     assert burger.num_patties == 0
     assert len(burger) == 2
     assert burger.price == 22
Exemple #20
0
 def test_update_other_out_of_stock(self):
     burger = Burger()
     burger.add_item(other1, 1)
     with pytest.raises(InvalidQuantityException):
         burger.update_qty(other1, 101)
     assert burger.num_others == 1
     assert len(burger) == 1
     assert burger.price == 12
Exemple #21
0
 def test_update_one_of_two_patties(self):
     burger = Burger()
     burger.add_item(patty1, 1)
     burger.add_item(patty2, 1)
     burger.update_qty(patty2, 2)
     assert burger.num_patties == 3
     assert burger.price == 50
     assert len(burger) == 3
Exemple #22
0
 def test_update_one_of_two_other(self):
     burger = Burger()
     burger.add_item(other1, 1)
     burger.add_item(other2, 1)
     burger.update_qty(other2, 2)
     assert burger.num_others == 3
     assert burger.price == 56
     assert len(burger) == 3
Exemple #23
0
 def test_update_one_of_two_bun(self):
     burger = Burger()
     burger.add_item(bun1, 1)
     burger.add_item(bun2, 1)
     burger.update_qty(bun2, 2)
     assert burger.num_buns == 3
     assert burger.price == 53
     assert len(burger) == 3
Exemple #24
0
 def test_add_zero_patty(self):
     burger = Burger()
     burger.add_item(bun1, 2)
     with pytest.raises(InvalidQuantityException):
         burger.add_item(patty2, 0)
     assert burger.num_patties == 0
     assert len(burger) == 2
     assert burger.price == 22
Exemple #25
0
 def test_update_invalid_patties(self):
     burger = Burger()
     burger.add_item(patty1, 1)
     with pytest.raises(ValueError):
         burger.update_qty(patty2, 1)
     assert burger.num_patties == 1
     assert len(burger) == 1
     assert burger.price == 10
Exemple #26
0
 def test_update_bun_zero(self):
     burger = Burger()
     burger.add_item(bun1, 1)
     with pytest.raises(InvalidQuantityException):
         burger.update_qty(bun1, 0)
     assert burger.num_buns == 1
     assert burger.price == 11
     assert len(burger) == 1
Exemple #27
0
 def test_update_patty_zero(self):
     burger = Burger()
     burger.add_item(patty1, 1)
     with pytest.raises(InvalidQuantityException):
         burger.update_qty(patty1, 0)
     assert burger.num_patties == 1
     assert burger.price == 10
     assert len(burger) == 1
Exemple #28
0
 def test_update_invalid_bun(self):
     burger = Burger()
     burger.add_item(bun1, 1)
     with pytest.raises(ValueError):
         burger.update_qty(bun2, 1)
     assert burger.num_buns == 1
     assert len(burger) == 1
     assert burger.price == 11
Exemple #29
0
 def test_update_one_of_two_other_exceeds_limit(self):
     burger = Burger()
     burger.add_item(other1, 1)
     burger.add_item(other2, 1)
     with pytest.raises(InvalidQuantityException):
         burger.update_qty(other2, 5)
     assert burger.num_others == 2
     assert burger.price == 34
     assert len(burger) == 2
Exemple #30
0
 def test_add_five_different_buns(self):
     burger = Burger()
     burger.add_item(bun1, 2)
     assert burger._num_buns == 2
     assert len(burger) == 2
     assert len(burger.components) == 1
     assert burger.price == 22
     with pytest.raises(InvalidQuantityException):
         burger.add_item(bun2, 3)