forked from DiUS/coding-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_jw_dius_shopping.py
More file actions
37 lines (29 loc) · 1.15 KB
/
Copy pathtest_jw_dius_shopping.py
File metadata and controls
37 lines (29 loc) · 1.15 KB
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
34
35
36
37
import unittest
from decimal import Decimal
from jw_dius_shopping import PricingRules, Checkout
class CorrectTotals(unittest.TestCase):
def setUp(self):
self.pricing_rules = PricingRules()
def test_correct_total_1(self):
"""SKUs Scanned: atv, atv, atv, vga Total expected: $249.00"""
co = Checkout(self.pricing_rules)
skus = ["atv", "atv", "atv", "vga"]
for sku in skus:
co.scan(sku)
self.assertEqual(co.total(), Decimal("249.00"))
def test_correct_total_2(self):
"""SKUs Scanned: atv, ipd, ipd, atv, ipd, ipd, ipd Total expected: $2718.95"""
co = Checkout(self.pricing_rules)
skus = ["atv", "ipd", "ipd", "atv", "ipd", "ipd", "ipd"]
for sku in skus:
co.scan(sku)
self.assertEqual(co.total(), Decimal("2718.95"))
def test_correct_total_3(self):
"""SKUs Scanned: mbp, vga, ipd Total expected: $1949.98"""
co = Checkout(self.pricing_rules)
skus = ["mbp", "vga", "ipd"]
for sku in skus:
co.scan(sku)
self.assertEqual(co.total(), Decimal("1949.98"))
if __name__ == "__main__":
unittest.main()