Mercurial > hg > orthanc-tests
annotate Plugins/Transfers/Run.py @ 422:91170313187c
worklists: test_format
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Jun 2021 10:37:53 +0200 |
parents | 79ce0f7a9714 |
children | e769bcf2b94f |
rev | line source |
---|---|
232
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/python |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 # Orthanc - A Lightweight, RESTful DICOM Store |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 # Department, University Hospital of Liege, Belgium |
363
79ce0f7a9714
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
330
diff
changeset
|
8 # Copyright (C) 2017-2021 Osimis S.A., Belgium |
232
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # This program is free software: you can redistribute it and/or |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # modify it under the terms of the GNU General Public License as |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # published by the Free Software Foundation, either version 3 of the |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # License, or (at your option) any later version. |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 # This program is distributed in the hope that it will be useful, but |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # WITHOUT ANY WARRANTY; without even the implied warranty of |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # General Public License for more details. |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 # You should have received a copy of the GNU General Public License |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 import os |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 import pprint |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import sys |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 import argparse |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 import unittest |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 import re |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests')) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 from Toolbox import * |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 ## Parse the command-line arguments |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 parser = argparse.ArgumentParser(description = 'Run the integration tests for the DICOMweb plugin.') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 parser.add_argument('--server', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 default = 'localhost', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 help = 'Address of the Orthanc server to test') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 parser.add_argument('--rest', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 type = int, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 default = 8042, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 help = 'Port to the REST API') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 parser.add_argument('--username', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 default = 'alice', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 help = 'Username to the REST API') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 parser.add_argument('--password', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 default = 'orthanctest', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 help = 'Password to the REST API') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 parser.add_argument('--force', help = 'Do not warn the user', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 action = 'store_true') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 parser.add_argument('options', metavar = 'N', nargs = '*', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 help='Arguments to Python unittest') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 args = parser.parse_args() |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 ## Configure the testing context |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 if not args.force: |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 print(""" |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 WARNING: This test will remove all the content of your |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 Orthanc instance running on %s! |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 Are you sure ["yes" to go on]?""" % args.server) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 if sys.stdin.readline().strip() != 'yes': |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 print('Aborting...') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 exit(0) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 ORTHANC = DefineOrthanc(server = args.server, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 username = args.username, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 password = args.password, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 restPort = args.rest) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 ## The tests |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 class Orthanc(unittest.TestCase): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 def setUp(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 if (sys.version_info >= (3, 0)): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 # Remove annoying warnings about unclosed socket in Python 3 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 import warnings |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 warnings.simplefilter("ignore", ResourceWarning) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 DropOrthanc(ORTHANC) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 def test_list_peers(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 peers = DoGet(ORTHANC, '/transfers/peers') |
330 | 101 self.assertEqual(4, len(peers)) # "self" peer was added in Orthanc 1.7.3 |
232
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 self.assertEqual('disabled', peers['peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 self.assertEqual('installed', peers['transfers-simple']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 self.assertEqual('bidirectional', peers['transfers-bidirectional']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 def test_pull(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 a = DoPost(ORTHANC, '/transfers/pull', { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 'Compression' : 'gzip', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 'Peer' : 'transfers-simple', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 'Resources' : [ |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 'Level' : 'Instance', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 'ID' : i |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 }, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 ], |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 'Priority' : 10, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 }) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 WaitJobDone(ORTHANC, a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 b = DoGet(ORTHANC, '/jobs/%s' % a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 self.assertEqual('PullTransfer', b['Type']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 self.assertEqual('Success', b['State']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 self.assertEqual(a['ID'], b['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 self.assertEqual(10, b['Priority']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 self.assertEqual('gzip', b['Content']['Compression']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 self.assertEqual(1, b['Content']['CompletedHttpQueries']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 self.assertEqual('transfers-simple', b['Content']['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 self.assertEqual(1, b['Content']['TotalInstances']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 def test_send_push(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 a = DoPost(ORTHANC, '/transfers/send', { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 'Compression' : 'gzip', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 'Peer' : 'transfers-simple', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 'Resources' : [ |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 'Level' : 'Instance', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 'ID' : i |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 }, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 ], |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 'Priority' : -10, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 }) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 WaitJobDone(ORTHANC, a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 b = DoGet(ORTHANC, '/jobs/%s' % a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 self.assertEqual('PushTransfer', b['Type']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 self.assertEqual('Success', b['State']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 self.assertEqual(a['ID'], b['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 self.assertEqual(-10, b['Priority']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 self.assertEqual('gzip', b['Content']['Compression']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 self.assertEqual(1, b['Content']['CompletedHttpQueries']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 self.assertEqual('transfers-simple', b['Content']['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 self.assertEqual(1, b['Content']['TotalInstances']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 def test_send_bidirectional(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 a = DoPost(ORTHANC, '/transfers/send', { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 'Compression' : 'gzip', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 'Peer' : 'transfers-bidirectional', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 'Resources' : [ |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 'Level' : 'Instance', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 'ID' : i |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 }, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 ], |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 'Priority' : 42, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 }) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 self.assertEqual(3, len(a)) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 self.assertEqual('transfers-bidirectional', a['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 self.assertTrue('RemoteJob' in a) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 self.assertTrue('URL' in a) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 # In this integration test, the remote peer is the same as the local peer |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 WaitJobDone(ORTHANC, a['RemoteJob']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 b = DoGet(ORTHANC, '/jobs/%s' % a['RemoteJob']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 self.assertEqual('PullTransfer', b['Type']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 self.assertEqual('Success', b['State']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 self.assertEqual(a['RemoteJob'], b['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 self.assertEqual(0, b['Priority']) # Priority is chosen by the remote peer |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 self.assertEqual('gzip', b['Content']['Compression']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 self.assertEqual(1, b['Content']['CompletedHttpQueries']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 self.assertEqual('transfers-bidirectional', b['Content']['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 self.assertEqual(1, b['Content']['TotalInstances']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 try: |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 print('\nStarting the tests...') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 unittest.main(argv = [ sys.argv[0] ] + args.options) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 finally: |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 print('\nDone') |