forked from jamesremuscat/TNTFL-web
-
Notifications
You must be signed in to change notification settings - Fork 4
/
run_tests.py
75 lines (61 loc) · 2.78 KB
/
run_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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import argparse
import sys
import unittest
import tntfl.test.test_achievements as test_achievements
import tntfl.test.test_game_store as test_game_store
import tntfl.test.test_json as test_json
import tntfl.test.test_ladder as test_ladder
import tntfl.test.test_pundit as test_pundit
import tntfl.test.transforms.test_achievement as test_achievement
import tntfl.test.transforms.test_belt as test_belt
import tntfl.test.transforms.test_elo as test_elo
import tntfl.test.transforms.test_rank as test_rank
from tntfl.constants import config
from tntfl.test import test_add, test_delete
from tntfl.test.blueprints import test_entry
from tntfl.test.blueprints import test_game_api
from tntfl.test.blueprints import test_ladder_api
from tntfl.test.blueprints import test_pages
from tntfl.test.blueprints import test_player_api
def unitTestSuite():
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.findTestCases(test_achievements))
test_suite.addTest(unittest.findTestCases(test_game_store))
test_suite.addTest(unittest.findTestCases(test_ladder))
test_suite.addTest(unittest.findTestCases(test_pundit))
test_suite.addTest(unittest.findTestCases(test_json))
test_suite.addTest(unittest.findTestCases(test_achievement))
test_suite.addTest(unittest.findTestCases(test_belt))
test_suite.addTest(unittest.findTestCases(test_elo))
test_suite.addTest(unittest.findTestCases(test_rank))
return test_suite
def functionalTestSuite():
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.findTestCases(test_entry))
test_suite.addTest(unittest.findTestCases(test_game_api))
test_suite.addTest(unittest.findTestCases(test_ladder_api))
test_suite.addTest(unittest.findTestCases(test_pages))
test_suite.addTest(unittest.findTestCases(test_player_api))
return test_suite
def integration_test_suite():
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.findTestCases(test_add))
test_suite.addTest(unittest.findTestCases(test_delete))
return test_suite
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--integration', dest='integration', action='store_true')
parser.set_defaults(integration=False)
args = parser.parse_args()
runner = unittest.TextTestRunner()
print('Running unit tests:')
result = runner.run(unitTestSuite())
if len(result.errors) == 0 and len(result.failures) == 0:
print('Running functional tests:')
result = runner.run(functionalTestSuite())
if len(result.errors) == 0 and len(result.failures) == 0 and args.integration:
config.reset()
print('Running integration tests:')
result = runner.run(integration_test_suite())
ok = len(result.errors) == 0 and len(result.failures) == 0
sys.exit(not ok)