コード例 #1
0
ファイル: test_US-8-9.py プロジェクト: SinghArshdeep/COMP1531
class TestItemQuantityUpdate():
    def setup_method(self):
        self.ing1 = Ingredient("Cheese", 5, 40)
        self.side1 = Side("Wedges", 2, 50)
        self.drink1 = Drink("Cola", 3, 50)

    def test_add_to_item(self):
        self.ing1.update_quantity(10)
        assert self.ing1.total_quantity == 50
        self.side1.update_quantity(10)
        assert self.side1.total_quantity == 60
        self.drink1.update_quantity(10)
        assert self.drink1.total_quantity == 60
コード例 #2
0
class TestUpdateQuantity():
    def setup_method(self):
        self.ing1 = Ingredient("Cheese", 5, 40)
        self.side1 = Side("Wedges", 2, 50)
        self.drink1 = Drink("Cola", 3, 50)

    def test_subtract_from_item(self):
        self.ing1.update_quantity(-10)
        self.side1.update_quantity(-10)
        self.drink1.update_quantity(-10)
        assert self.ing1.total_quantity == 30
        assert self.side1.total_quantity == 40
        assert self.drink1.total_quantity == 40

    def test_subtract_too_much_from_item(self):
        with pytest.raises(QuantityError):
            self.ing1.update_quantity(-70)
            self.side1.update_quantity(-70)
            self.drink1.update_quantity(-70)