-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
37 lines (28 loc) · 830 Bytes
/
tests.py
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
from __future__ import division, print_function, unicode_literals
import unittest
from buyer import do_calculation
TEST_OFFER = [
{
"Quantity": 12.00000000,
"Rate": 0.02525000
},
{
"Quantity": 15.37000000,
"Rate": 0.02515000
},
{
"Quantity": 11.37000000,
"Rate": 0.02505000
},
]
class TestCalculation(unittest.TestCase):
def test_example(self):
total_get, amount_left = do_calculation(TEST_OFFER, 16)
self.assertAlmostEqual(total_get, 0.4036)
self.assertEqual(amount_left, 0)
def test_too_many(self):
total_get, amount_left = do_calculation(TEST_OFFER, 160)
self.assertAlmostEqual(total_get, 0.974374)
self.assertAlmostEqual(amount_left, 121.26)
if __name__ == '__main__':
unittest.main()