-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests
executable file
·39 lines (33 loc) · 1.07 KB
/
run_tests
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
#!/bin/python2.7
import sys
from run import mocks
import unittest
from savingCalculator.TeevityAPI import TeevityAPI
from savingCalculator.SavingCalculator import SavingCalculator
from savingChecking import SavingChecking
class TestMocks(unittest.TestCase):
def computeMock(self, mockName):
files = mocks[mockName]
api = TeevityAPI(files[0], files[1])
costs = api.GetCostDatas()
events = api.GetEvents()
calculator = SavingCalculator(costs, events)
return {'raw': calculator.getSavings()}
def generateTestFunc(mockName):
def test(self):
datas = self.computeMock(mockName)
checking = SavingChecking(datas)
result = checking.run()
self.assertEqual(result, 0)
return test
def appendNewMockTest(mockName):
test_func = generateTestFunc(mockName)
test_name = "test_{}".format(mockName)
setattr(TestMocks, test_name, test_func)
def main():
for mockName in mocks:
appendNewMockTest(mockName)
unittest.main()
return 0
if __name__ == "__main__":
sys.exit(main())