-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_int_expensetracking.py
More file actions
40 lines (33 loc) · 1.83 KB
/
test_int_expensetracking.py
File metadata and controls
40 lines (33 loc) · 1.83 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
38
39
40
import unittest
from expensetracking import (
Expense,
Employee,
reimburser,
expensetracker,
)
class TestPayouts(unittest.TestCase):
def test_expenses_paid(self):
employee = Employee('Aaron Maxwell', 128)
expensetracker.addExpense(employee, Expense('frisbee', 7.25))
expensetracker.addExpense(employee, Expense('hockey stick', 49.95))
expensetracker.addExpense(employee, Expense('cool sunglasses', 29.99))
# Total of all expenses so far is $87.19.
self.assertEqual(87.19, expensetracker.totalUnpaidExpensesForEmployee(employee))
# And I have not been reimbursed yet at all.
self.assertEqual(0, expensetracker.totalPaidExpensesForEmployee(employee))
self.assertEqual(0, reimburser.totalPaidForEmployee(employee))
# Now the reimburser service starts the reimbursement process.
reimburser.reimburseEmployee(employee)
self.assertEqual(0, expensetracker.totalUnpaidExpensesForEmployee(employee))
self.assertEqual(87.19, expensetracker.totalPaidExpensesForEmployee(employee))
self.assertEqual(87.19, reimburser.totalPaidForEmployee(employee))
# Let's add another expense.
expensetracker.addExpense(employee, Expense('juice boxes', 4.50))
self.assertEqual(4.50, expensetracker.totalUnpaidExpensesForEmployee(employee))
self.assertEqual(87.19, expensetracker.totalPaidExpensesForEmployee(employee))
self.assertEqual(87.19, reimburser.totalPaidForEmployee(employee))
# ... and reimburse that one.
reimburser.reimburseEmployee(employee)
self.assertEqual(0, expensetracker.totalUnpaidExpensesForEmployee(employee))
self.assertEqual(91.69, expensetracker.totalPaidExpensesForEmployee(employee))
self.assertEqual(91.69, reimburser.totalPaidForEmployee(employee))