Mercurial > hg > orthanc-tests
comparison NewTests/main.py @ 473:4ee85b016a40
added NewTests framework - only the Housekeeper tests right now
author | Alain Mazy <am@osimis.io> |
---|---|
date | Sat, 30 Apr 2022 19:38:34 +0200 |
parents | |
children | 6917a26881ed |
comparison
equal
deleted
inserted
replaced
472:d9ceb0fd5995 | 473:4ee85b016a40 |
---|---|
1 import argparse | |
2 import unittest | |
3 import os | |
4 import sys | |
5 import argparse | |
6 from helpers import Helpers | |
7 import pathlib | |
8 # python3 main.py --orthanc_under_tests_exe=/home/alain/o/build/orthanc/Orthanc --pattern=Housekeeper.test_housekeeper.TestHousekeeper.*test_is* --plugin=/home/alain/o/build/orthanc/libHousekeeper.so | |
9 | |
10 here = pathlib.Path(__file__).parent.resolve() | |
11 | |
12 | |
13 def load_tests(loader=None, tests=None, pattern='test_*.py'): | |
14 this_dir = os.path.dirname(__file__) | |
15 package_tests = loader.discover(start_dir=this_dir, pattern=pattern) | |
16 return package_tests | |
17 | |
18 if __name__ == '__main__': | |
19 | |
20 parser = argparse.ArgumentParser(description='Executes Orthanc integration tests.') | |
21 parser.add_argument('-k', '--pattern', dest='test_name_patterns', action='append', type=str, help='a test pattern (ex: Housekeeper.toto') | |
22 parser.add_argument('--orthanc_under_tests_hostname', type=str, default="localhost", help="orthanc under tests hostname") | |
23 parser.add_argument('--orthanc_under_tests_http_port', type=int, default=8042, help="orthanc under tests HTTP port") | |
24 parser.add_argument('--orthanc_under_tests_exe', type=str, default=None, help="path to the orthanc executable (if it must be launched by this script)") | |
25 parser.add_argument('--orthanc_previous_version_exe', type=str, default=None, help="path to the orthanc executable used to prepare previous version of storage/db (if it must be launched by this script and if different from orthanc_under_tests_exe)") | |
26 parser.add_argument('--orthanc_under_tests_docker_image', type=str, default=None, help="tag of the Docker image of the orthanc under tests (if it must be launched by this script)") | |
27 parser.add_argument('--skip_preparation', action='store_true', help="if this is a multi stage tests with preparations, skip the preparation") | |
28 parser.add_argument('--break_after_preparation', action='store_true', help="if this is a multi stage tests with preparations, pause after the preparation (such that you can start your own orthanc-under-tests in your debugger)") | |
29 parser.add_argument('-p', '--plugin', dest='plugins', action='append', type=str, help='path to a plugin to add to configuration') | |
30 | |
31 | |
32 args = parser.parse_args() | |
33 | |
34 loader = unittest.TestLoader() | |
35 loader.testNamePatterns = args.test_name_patterns | |
36 | |
37 Helpers.orthanc_under_tests_hostname = args.orthanc_under_tests_hostname | |
38 Helpers.orthanc_under_tests_http_port = args.orthanc_under_tests_http_port | |
39 Helpers.orthanc_under_tests_exe = args.orthanc_under_tests_exe | |
40 Helpers.plugins = args.plugins | |
41 if args.orthanc_previous_version_exe: | |
42 Helpers.orthanc_previous_version_exe = args.orthanc_previous_version_exe | |
43 else: | |
44 Helpers.orthanc_previous_version_exe = args.orthanc_under_tests_exe | |
45 | |
46 Helpers.orthanc_under_tests_docker_image = args.orthanc_under_tests_docker_image | |
47 if args.skip_preparation: | |
48 Helpers.skip_preparation = True | |
49 if args.break_after_preparation: | |
50 Helpers.break_after_preparation = True | |
51 | |
52 result = unittest.TextTestRunner(verbosity=2).run(load_tests(loader=loader)) | |
53 if not result.wasSuccessful(): | |
54 sys.exit(1) |