comparison Tests/Run.py @ 8:f8d781d1d267

test_changes, test_archive, test_media_archive
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Jun 2015 13:45:54 +0200
parents 6d645b3011e1
children 7b69a561f4d3
comparison
equal deleted inserted replaced
7:302f06f3bba2 8:f8d781d1d267
33 ## Parse the command-line arguments 33 ## Parse the command-line arguments
34 ## 34 ##
35 35
36 parser = argparse.ArgumentParser(description = 'Run the integration tests on some instance of Orthanc.') 36 parser = argparse.ArgumentParser(description = 'Run the integration tests on some instance of Orthanc.')
37 parser.add_argument('--server', 37 parser.add_argument('--server',
38 default = GetDockerHostAddress(), 38 default = 'localhost',
39 help = 'Address of the Orthanc server to test') 39 help = 'Address of the Orthanc server to test')
40 parser.add_argument('--aet', 40 parser.add_argument('--aet',
41 default = 'ORTHANC', 41 default = 'ORTHANC',
42 help = 'AET of the Orthanc instance to test') 42 help = 'AET of the Orthanc instance to test')
43 parser.add_argument('--dicom', 43 parser.add_argument('--dicom',
53 help = 'Username to the REST API') 53 help = 'Username to the REST API')
54 parser.add_argument('--password', 54 parser.add_argument('--password',
55 default = 'orthanctest', 55 default = 'orthanctest',
56 help = 'Password to the REST API') 56 help = 'Password to the REST API')
57 parser.add_argument('--force', help = 'Do not warn the user', 57 parser.add_argument('--force', help = 'Do not warn the user',
58 action = 'store_true')
59 parser.add_argument('--docker', help = 'These tests are run from Docker',
58 action = 'store_true') 60 action = 'store_true')
59 parser.add_argument('options', metavar = 'N', nargs = '*', 61 parser.add_argument('options', metavar = 'N', nargs = '*',
60 help='Arguments to Python unittest') 62 help='Arguments to Python unittest')
61 63
62 args = parser.parse_args() 64 args = parser.parse_args()
77 ## 79 ##
78 ## Generate the configuration file for the anciliary instance of 80 ## Generate the configuration file for the anciliary instance of
79 ## Orthanc 81 ## Orthanc
80 ## 82 ##
81 83
84 if args.docker:
85 args.server = GetDockerHostAddress()
86
82 CONFIG = '/tmp/Configuration.json' 87 CONFIG = '/tmp/Configuration.json'
83 subprocess.check_call([ 'Orthanc', '--config=%s' % CONFIG ]) 88 subprocess.check_call([ 'Orthanc', '--config=%s' % CONFIG ])
84 89
85 with open(CONFIG, 'r') as f: 90 with open(CONFIG, 'rt') as f:
86 config = f.read() 91 config = f.read()
87 92
88 config = re.sub(r'("StorageDirectory"\s*:)\s*".*?"', r'\1 "/tmp/OrthancStorage"', config) 93 config = re.sub(r'("StorageDirectory"\s*:)\s*".*?"', r'\1 "/tmp/OrthancStorage"', config)
89 config = re.sub(r'("IndexDirectory"\s*:)\s*".*?"', r'\1 "/tmp/OrthancStorage"', config) 94 config = re.sub(r'("IndexDirectory"\s*:)\s*".*?"', r'\1 "/tmp/OrthancStorage"', config)
90 config = re.sub(r'("DicomAet"\s*:)\s*".*?"', r'\1 "ORTHANCTEST"', config) 95 config = re.sub(r'("DicomAet"\s*:)\s*".*?"', r'\1 "ORTHANCTEST"', config)
96 config = re.sub(r'("DicomPort"\s*:)\s*.*?,', r'\1 5001,', config)
97 config = re.sub(r'("HttpPort"\s*:)\s*.*?,', r'\1 5000,', config)
91 config = re.sub(r'("RemoteAccessAllowed"\s*:)\s*false', r'\1 true', config) 98 config = re.sub(r'("RemoteAccessAllowed"\s*:)\s*false', r'\1 true', config)
92 config = re.sub(r'("AuthenticationEnabled"\s*:)\s*false', r'\1 true', config) 99 config = re.sub(r'("AuthenticationEnabled"\s*:)\s*false', r'\1 true', config)
93 config = re.sub(r'("RegisteredUsers"\s*:)\s*{', r'\1 { "alice" : [ "orthanctest" ]', config) 100 config = re.sub(r'("RegisteredUsers"\s*:)\s*{', r'\1 { "alice" : "orthanctest"', config)
94 config = re.sub(r'("DicomModalities"\s*:)\s*{', r'\1 { "orthanc" : [ "%s", "%s", "%s" ]' % 101 config = re.sub(r'("DicomModalities"\s*:)\s*{', r'\1 { "orthanc" : [ "%s", "%s", "%s" ]' %
95 (args.aet, args.server, args.dicom), config) 102 (args.aet, args.server, args.dicom), config)
103
104 with open(CONFIG, 'wt') as f:
105 f.write(config)
96 106
97 localOrthanc = ExternalCommandThread([ 107 localOrthanc = ExternalCommandThread([
98 'Orthanc', CONFIG, #'--verbose' 108 'Orthanc', CONFIG, #'--verbose'
99 ]) 109 ])
100 110
101 111
102 LOCAL = DefineOrthanc(aet = 'ORTHANCTEST') 112 LOCAL = DefineOrthanc(aet = 'ORTHANCTEST',
113 url = 'http://localhost:5000',
114 dicomPort = 5001,
115 username = 'alice',
116 password = 'orthanctest')
117
103 REMOTE = DefineOrthanc(url = 'http://%s:%d/' % (args.server, args.rest), 118 REMOTE = DefineOrthanc(url = 'http://%s:%d/' % (args.server, args.rest),
104 username = args.username, 119 username = args.username,
105 password = args.password, 120 password = args.password,
106 aet = args.aet, 121 aet = args.aet,
107 dicomPort = args.dicom) 122 dicomPort = args.dicom)
108 123
109 124
110 125
111 print('Parameters of the instance of Orthanc to test:') 126 print('Parameters of the instance of Orthanc being tested:')
112 pprint.pprint(REMOTE) 127 pprint.pprint(REMOTE)
113 print('') 128 print('')
114 129
115 130
116 print('Waiting for the internal Orthanc to start...') 131 print('Waiting for the internal Orthanc to start...')