-
Notifications
You must be signed in to change notification settings - Fork 0
/
unittests.py
48 lines (40 loc) · 1.52 KB
/
unittests.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
38
39
40
41
42
43
44
45
46
47
48
''' unittests.py
'''
import sys
import json
import unittest
from server import app
from tests import MerchantTests as M
from tests import InvoiceTests as I
from tests import VisaFundsPushTests as V
class ServerTests(unittest.TestCase):
def setUp(self):
self.tester = app.test_client(self)
def test_hello_world(self):
def should_receive_success():
response = self.tester.get('/', content_type='html/text')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, b'Hello, World!')
should_receive_success()
def test_visa_api(self):
def should_receive_success():
response = self.tester.get('/visa-api-test')
self.assertEqual(response.status_code, 200)
self.assertEqual(json.loads(response.data.decode('utf-8'))['message'],'helloworld')
should_receive_success()
def test_get(self):
self.assertEqual(200, 200)
if __name__ == '__main__':
test_classes_to_run = [ServerTests, I.InvoiceTests, M.MerchantTests, V.VisaFundsPushTests]
loader = unittest.TestLoader()
suites_list = []
for test_class in test_classes_to_run:
suite = loader.loadTestsFromTestCase(test_class)
suites_list.append(suite)
big_suite = unittest.TestSuite(suites_list)
runner = unittest.TextTestRunner()
results = runner.run(big_suite)
'''
suite = unittest.TestLoader().loadTestsFromModule( sys.modules[__name__] )
unittest.TextTestRunner(verbosity=3).run( suite )
'''