Example #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
Example #2
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
Example #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
Example #4
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
Example #5
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
Example #6
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
Example #7
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
Example #8
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
Example #9
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
Example #10
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
Example #11
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
Example #12
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
Example #13
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
Example #14
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
Example #15
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
Example #16
0
 def test_update_to_one_bun(self):
     burger = Burger()
     burger.add_item(bun1, 2)
     with pytest.raises(ValueError):
         burger.update_qty(bun1, 1)