diff 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
line wrap: on
line diff
--- a/Tests/Run.py	Wed Jun 17 12:04:23 2015 +0200
+++ b/Tests/Run.py	Wed Jun 17 13:45:54 2015 +0200
@@ -35,7 +35,7 @@
 
 parser = argparse.ArgumentParser(description = 'Run the integration tests on some instance of Orthanc.')
 parser.add_argument('--server', 
-                    default = GetDockerHostAddress(),
+                    default = 'localhost',
                     help = 'Address of the Orthanc server to test')
 parser.add_argument('--aet',
                     default = 'ORTHANC',
@@ -56,6 +56,8 @@
                     help = 'Password to the REST API')
 parser.add_argument('--force', help = 'Do not warn the user',
                     action = 'store_true')
+parser.add_argument('--docker', help = 'These tests are run from Docker',
+                    action = 'store_true')
 parser.add_argument('options', metavar = 'N', nargs = '*',
                     help='Arguments to Python unittest')
 
@@ -79,27 +81,40 @@
 ## Orthanc
 ##
 
+if args.docker:
+    args.server = GetDockerHostAddress()
+
 CONFIG = '/tmp/Configuration.json'
 subprocess.check_call([ 'Orthanc', '--config=%s' % CONFIG ])
 
-with open(CONFIG, 'r') as f:
+with open(CONFIG, 'rt') as f:
     config = f.read()
 
 config = re.sub(r'("StorageDirectory"\s*:)\s*".*?"', r'\1 "/tmp/OrthancStorage"', config)
 config = re.sub(r'("IndexDirectory"\s*:)\s*".*?"', r'\1 "/tmp/OrthancStorage"', config)
 config = re.sub(r'("DicomAet"\s*:)\s*".*?"', r'\1 "ORTHANCTEST"', config)
+config = re.sub(r'("DicomPort"\s*:)\s*.*?,', r'\1 5001,', config)
+config = re.sub(r'("HttpPort"\s*:)\s*.*?,', r'\1 5000,', config)
 config = re.sub(r'("RemoteAccessAllowed"\s*:)\s*false', r'\1 true', config)
 config = re.sub(r'("AuthenticationEnabled"\s*:)\s*false', r'\1 true', config)
-config = re.sub(r'("RegisteredUsers"\s*:)\s*{', r'\1 { "alice" : [ "orthanctest" ]', config)
+config = re.sub(r'("RegisteredUsers"\s*:)\s*{', r'\1 { "alice" : "orthanctest"', config)
 config = re.sub(r'("DicomModalities"\s*:)\s*{', r'\1 { "orthanc" : [ "%s", "%s", "%s" ]' % 
                 (args.aet, args.server, args.dicom), config)
 
+with open(CONFIG, 'wt') as f:
+    f.write(config)
+
 localOrthanc = ExternalCommandThread([ 
         'Orthanc', CONFIG, #'--verbose'
         ])
 
 
-LOCAL = DefineOrthanc(aet = 'ORTHANCTEST')
+LOCAL = DefineOrthanc(aet = 'ORTHANCTEST',
+                      url = 'http://localhost:5000',
+                      dicomPort = 5001,
+                      username = 'alice',
+                      password = 'orthanctest')
+
 REMOTE = DefineOrthanc(url = 'http://%s:%d/' % (args.server, args.rest),
                        username = args.username,
                        password = args.password,
@@ -108,7 +123,7 @@
 
 
 
-print('Parameters of the instance of Orthanc to test:')
+print('Parameters of the instance of Orthanc being tested:')
 pprint.pprint(REMOTE)
 print('')