-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCheckout.py
More file actions
33 lines (26 loc) · 830 Bytes
/
TestCheckout.py
File metadata and controls
33 lines (26 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pytest
from Checkout import Checkout
@pytest.fixture()
def checkout():
checkout = Checkout()
checkout.addItemPrice("a", 1)
checkout.addItemPrice("b", 2)
return checkout
def test_CanCalculateTotal(checkout):
checkout.addItem("a")
assert checkout.calculateTotal() == 1
def test_GetCorrectTotalWithMultipleItems(checkout):
checkout.addItem("a")
checkout.addItem("b")
assert checkout.calculateTotal() == 3
def test_CanAddDiscountRule(checkout):
checkout.addDiscount("a", 3, 2)
def test_CanApplyDiscountRule(checkout):
checkout.addDiscount("a", 3, 2)
checkout.addItem("a")
checkout.addItem("a")
checkout.addItem("a")
assert checkout.calculateTotal() == 2
def test_ExceptionWithBadItem(checkout):
with pytest.raises(Exception):
checkout.addItem("c")