Mercurial > hg > orthanc-tests
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NewTests/main.py Sat Apr 30 19:38:34 2022 +0200 @@ -0,0 +1,54 @@ +import argparse +import unittest +import os +import sys +import argparse +from helpers import Helpers +import pathlib +# 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 + +here = pathlib.Path(__file__).parent.resolve() + + +def load_tests(loader=None, tests=None, pattern='test_*.py'): + this_dir = os.path.dirname(__file__) + package_tests = loader.discover(start_dir=this_dir, pattern=pattern) + return package_tests + +if __name__ == '__main__': + + parser = argparse.ArgumentParser(description='Executes Orthanc integration tests.') + parser.add_argument('-k', '--pattern', dest='test_name_patterns', action='append', type=str, help='a test pattern (ex: Housekeeper.toto') + parser.add_argument('--orthanc_under_tests_hostname', type=str, default="localhost", help="orthanc under tests hostname") + parser.add_argument('--orthanc_under_tests_http_port', type=int, default=8042, help="orthanc under tests HTTP port") + 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)") + 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)") + 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)") + parser.add_argument('--skip_preparation', action='store_true', help="if this is a multi stage tests with preparations, skip the preparation") + 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)") + parser.add_argument('-p', '--plugin', dest='plugins', action='append', type=str, help='path to a plugin to add to configuration') + + + args = parser.parse_args() + + loader = unittest.TestLoader() + loader.testNamePatterns = args.test_name_patterns + + Helpers.orthanc_under_tests_hostname = args.orthanc_under_tests_hostname + Helpers.orthanc_under_tests_http_port = args.orthanc_under_tests_http_port + Helpers.orthanc_under_tests_exe = args.orthanc_under_tests_exe + Helpers.plugins = args.plugins + if args.orthanc_previous_version_exe: + Helpers.orthanc_previous_version_exe = args.orthanc_previous_version_exe + else: + Helpers.orthanc_previous_version_exe = args.orthanc_under_tests_exe + + Helpers.orthanc_under_tests_docker_image = args.orthanc_under_tests_docker_image + if args.skip_preparation: + Helpers.skip_preparation = True + if args.break_after_preparation: + Helpers.break_after_preparation = True + + result = unittest.TextTestRunner(verbosity=2).run(load_tests(loader=loader)) + if not result.wasSuccessful(): + sys.exit(1)