-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
34 lines (28 loc) · 787 Bytes
/
Copy pathtest.py
File metadata and controls
34 lines (28 loc) · 787 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
34
def calculate_total(products):
total = 0
for product in products:
total += product["price"]
return total
def test_calculate_total_with_empty_list():
assert calculate_total([]) == 0
def test_calculate_total_with_single_product():
products = [
{
"name": "Notebook", "price": 5
}
]
assert calculate_total(products) == 5
def test_calculate_total_with_multiple_product():
products = [
{
"name": "Book", "price": 10
},
{
"name": "Pen", "price": 2
}
]
assert calculate_total(products) == 12
if __name__ == "__main__":
test_calculate_total_with_empty_list()
test_calculate_total_with_single_product()
test_calculate_total_with_multiple_product()