Mercurial > hg > orthanc-tests
annotate Plugins/Transfers/Run.py @ 669:36c00333f6ef default tip
fix test
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Jul 2024 14:07:49 +0200 |
parents | 5d7b6e43ab7d |
children |
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 |
649
5d7b6e43ab7d
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
640
diff
changeset
|
8 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
5d7b6e43ab7d
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
640
diff
changeset
|
9 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
640
9f8276ac1cdd
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
511
diff
changeset
|
10 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
232
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # 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
|
13 # 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
|
14 # 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
|
15 # License, or (at your option) any later version. |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # 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
|
18 # WITHOUT ANY WARRANTY; without even the implied warranty of |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 # General Public License for more details. |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 # |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 # 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
|
23 # 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
|
24 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 import os |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 import pprint |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 import sys |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 import argparse |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 import unittest |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 import re |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 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
|
35 from Toolbox import * |
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 |
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 ## Parse the command-line arguments |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 ## |
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 = 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
|
43 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 parser.add_argument('--server', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 default = 'localhost', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 help = 'Address of the Orthanc server to test') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 parser.add_argument('--rest', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 type = int, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 default = 8042, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 help = 'Port to the REST API') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 parser.add_argument('--username', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 default = 'alice', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 help = 'Username to the REST API') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 parser.add_argument('--password', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 default = 'orthanctest', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 help = 'Password to the REST API') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 parser.add_argument('--force', help = 'Do not warn the user', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 action = 'store_true') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 parser.add_argument('options', metavar = 'N', nargs = '*', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 help='Arguments to Python unittest') |
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 args = parser.parse_args() |
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 |
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 ## Configure the testing context |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 if not args.force: |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 print(""" |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 WARNING: This test will remove all the content of your |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 Orthanc instance running on %s! |
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 Are you sure ["yes" to go on]?""" % args.server) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 if sys.stdin.readline().strip() != 'yes': |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 print('Aborting...') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 exit(0) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 ORTHANC = DefineOrthanc(server = args.server, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 username = args.username, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 password = args.password, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 restPort = args.rest) |
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 |
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 ## The tests |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 ## |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 class Orthanc(unittest.TestCase): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 def setUp(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 if (sys.version_info >= (3, 0)): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 # Remove annoying warnings about unclosed socket in Python 3 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 import warnings |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 warnings.simplefilter("ignore", ResourceWarning) |
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 DropOrthanc(ORTHANC) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 def test_list_peers(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 peers = DoGet(ORTHANC, '/transfers/peers') |
330 | 103 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
|
104 self.assertEqual('disabled', peers['peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 self.assertEqual('installed', peers['transfers-simple']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 self.assertEqual('bidirectional', peers['transfers-bidirectional']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 def test_pull(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 a = DoPost(ORTHANC, '/transfers/pull', { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 'Compression' : 'gzip', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 'Peer' : 'transfers-simple', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 'Resources' : [ |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 'Level' : 'Instance', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 'ID' : i |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 }, |
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 'Priority' : 10, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 }) |
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 WaitJobDone(ORTHANC, a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 b = DoGet(ORTHANC, '/jobs/%s' % a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 self.assertEqual('PullTransfer', b['Type']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 self.assertEqual('Success', b['State']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 self.assertEqual(a['ID'], b['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 self.assertEqual(10, b['Priority']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 self.assertEqual('gzip', b['Content']['Compression']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 self.assertEqual(1, b['Content']['CompletedHttpQueries']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 self.assertEqual('transfers-simple', b['Content']['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 self.assertEqual(1, b['Content']['TotalInstances']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 def test_send_push(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 a = DoPost(ORTHANC, '/transfers/send', { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 'Compression' : 'gzip', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 'Peer' : 'transfers-simple', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 'Resources' : [ |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 'Level' : 'Instance', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 'ID' : i |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 }, |
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 'Priority' : -10, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 }) |
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 WaitJobDone(ORTHANC, a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 b = DoGet(ORTHANC, '/jobs/%s' % a['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 self.assertEqual('PushTransfer', b['Type']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 self.assertEqual('Success', b['State']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 self.assertEqual(a['ID'], b['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 self.assertEqual(-10, b['Priority']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 self.assertEqual('gzip', b['Content']['Compression']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 self.assertEqual(1, b['Content']['CompletedHttpQueries']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 self.assertEqual('transfers-simple', b['Content']['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 self.assertEqual(1, b['Content']['TotalInstances']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 def test_send_bidirectional(self): |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 a = DoPost(ORTHANC, '/transfers/send', { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 'Compression' : 'gzip', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 'Peer' : 'transfers-bidirectional', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 'Resources' : [ |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 { |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 'Level' : 'Instance', |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 'ID' : i |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 }, |
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 'Priority' : 42, |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 }) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 self.assertEqual(3, len(a)) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 self.assertEqual('transfers-bidirectional', a['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 self.assertTrue('RemoteJob' in a) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 self.assertTrue('URL' in a) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 # 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
|
188 WaitJobDone(ORTHANC, a['RemoteJob']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 b = DoGet(ORTHANC, '/jobs/%s' % a['RemoteJob']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 self.assertEqual('PullTransfer', b['Type']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 self.assertEqual('Success', b['State']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 self.assertEqual(a['RemoteJob'], b['ID']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 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
|
195 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 self.assertEqual('gzip', b['Content']['Compression']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 self.assertEqual(1, b['Content']['CompletedHttpQueries']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 self.assertEqual('transfers-bidirectional', b['Content']['Peer']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 self.assertEqual(1, b['Content']['TotalInstances']) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 try: |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 print('\nStarting the tests...') |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 unittest.main(argv = [ sys.argv[0] ] + args.options) |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 finally: |
f2af7bdc9bf8
tests for transfers accelerator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 print('\nDone') |