Пример #1
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
Пример #2
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
Пример #3
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
Пример #4
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
Пример #5
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
Пример #6
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
Пример #7
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
Пример #8
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
Пример #9
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
Пример #10
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
Пример #11
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
Пример #12
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
Пример #13
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
Пример #14
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
Пример #15
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
Пример #16
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
Пример #17
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
Пример #18
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
Пример #19
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
Пример #20
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
Пример #21
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
Пример #22
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
Пример #23
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
Пример #24
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
Пример #25
0
 def test_update_one_of_two_bun_out_of_range(self):
     burger = Burger()
     burger.add_item(bun1, 1)
     burger.add_item(bun2, 1)
     with pytest.raises(InvalidQuantityException):
         burger.update_qty(bun2, 4)
     assert burger.num_buns == 2
     assert burger.price == 32
     assert len(burger) == 2
Пример #26
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)
Пример #27
0
 def test_update_one_of_two_patties_out_of_range(self):
     burger = Burger()
     burger.add_item(patty1, 1)
     burger.add_item(patty2, 1)
     with pytest.raises(InvalidQuantityException):
         burger.update_qty(patty2, 6)
     assert burger.num_patties == 2
     assert burger.price == 30
     assert len(burger) == 2
Пример #28
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
Пример #29
0
    def test_add_six_different_buns(self):
        burger = Burger()
        burger.add_item(other1, 3)
        with pytest.raises(InvalidQuantityException):
            burger.add_item(other2, 3)

        assert burger._num_others == 3
        assert len(burger) == 3
        assert len(burger.components) == 1
        assert burger.price == 36
 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