Mercurial > hg > orthanc-tests
annotate Plugins/WebDav/Run.py @ 620:8ba9b20ae95f debug-pg-transactions
debug pg transactions tests
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 05 Feb 2024 22:32:39 +0100 |
parents | 61e8cf2d78fd |
children | 9f8276ac1cdd |
rev | line source |
---|---|
610
ec657d1a62a6
fix compatibility with python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
511
diff
changeset
|
1 #!/usr/bin/python3 |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 # Orthanc - A Lightweight, RESTful DICOM Store |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 # Department, University Hospital of Liege, Belgium |
511
933fe1bbce4f
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
449
diff
changeset
|
6 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
933fe1bbce4f
upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
449
diff
changeset
|
7 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 # |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 # This program is free software: you can redistribute it and/or |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 # modify it under the terms of the GNU General Public License as |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 # published by the Free Software Foundation, either version 3 of the |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 # License, or (at your option) any later version. |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 # |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 # This program is distributed in the hope that it will be useful, but |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 # WITHOUT ANY WARRANTY; without even the implied warranty of |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 # General Public License for more details. |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 # |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 # You should have received a copy of the GNU General Public License |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
614 | 23 # Note about easywebdav: This test is compatible with version 1.2.0 of |
24 # the "python3-easywebdav" package in Ubuntu/Debian. Beware that this | |
25 # package includes a patch that is not available in the upstream | |
26 # version of easywebdav: | |
27 # https://salsa.debian.org/python-team/packages/python-easywebdav/-/blob/master/debian/patches/python3.patch | |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 import argparse |
614 | 30 import easywebdav |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 import io |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 import os |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 import pprint |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 import re |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 import sys |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 import unittest |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
339 | 38 # https://stackoverflow.com/a/49336105/881731 |
39 if ((3, 0) <= sys.version_info <= (3, 9)): | |
40 from urllib.parse import unquote | |
41 elif ((2, 0) <= sys.version_info <= (2, 9)): | |
42 from urlparse import unquote | |
43 | |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests')) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 from Toolbox import * |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 ## |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 ## Parse the command-line arguments |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 ## |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
375 | 52 parser = argparse.ArgumentParser(description = 'Run the integration tests for the WebDAV server.') |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 parser.add_argument('--server', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 default = 'localhost', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 help = 'Address of the Orthanc server to test') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 parser.add_argument('--rest', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 type = int, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 default = 8042, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 help = 'Port to the REST API') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 parser.add_argument('--username', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 default = 'alice', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 help = 'Username to the REST API') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 parser.add_argument('--password', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 default = 'orthanctest', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 help = 'Password to the REST API') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 parser.add_argument('--force', help = 'Do not warn the user', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 action = 'store_true') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 parser.add_argument('options', metavar = 'N', nargs = '*', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 help='Arguments to Python unittest') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 args = parser.parse_args() |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 ## |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 ## Configure the testing context |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 ## |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 if not args.force: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 print(""" |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 WARNING: This test will remove all the content of your |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 Orthanc instance running on %s! |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 Are you sure ["yes" to go on]?""" % args.server) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 if sys.stdin.readline().strip() != 'yes': |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 print('Aborting...') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 exit(0) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 ORTHANC = DefineOrthanc(server = args.server, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 username = args.username, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 password = args.password, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 restPort = args.rest) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 WEBDAV = easywebdav.connect(args.server, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 port = args.rest, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 username = args.username, |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 password = args.password) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 ## |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 ## The tests |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 ## |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 def ListFiles(path, recursive): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 result = [ ] |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 for i in WEBDAV.ls(path): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 if i.name == path: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 pass |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 elif i.contenttype == '': |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 if recursive: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 result += ListFiles(i.name + '/', True) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 else: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 result.append(i.name) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 return result |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 def GetFileInfo(path): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 for i in WEBDAV.ls(path[0 : path.rfind('/')]): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 if i.name == path: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 return i |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 raise Exception('Cannot find: %s' % path) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 def DownloadFile(path): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 with tempfile.NamedTemporaryFile(delete = False) as f: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 f.close() |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 WEBDAV.download(path, f.name) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 with open(f.name, 'rb') as g: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 result = g.read() |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 os.unlink(f.name) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 return result |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 class Orthanc(unittest.TestCase): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 def setUp(self): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 if (sys.version_info >= (3, 0)): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 # Remove annoying warnings about unclosed socket in Python 3 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 import warnings |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 warnings.simplefilter("ignore", ResourceWarning) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 DropOrthanc(ORTHANC) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 def test_root(self): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 self.assertEqual(6, len(WEBDAV.ls('/webdav/'))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 for i in WEBDAV.ls('/webdav/'): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 self.assertTrue(i.name in [ |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 '/webdav/', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 '/webdav/by-dates', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 '/webdav/by-patients', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 '/webdav/by-studies', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 '/webdav/by-uids', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 '/webdav/uploads' |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 ]) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 self.assertEqual(0, i.size) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 self.assertEqual('', i.contenttype) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 patients = WEBDAV.ls('/webdav/by-patients/') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 self.assertEqual(1, len(patients)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 self.assertEqual(patients[0].name, '/webdav/by-patients/') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 self.assertEqual(0, patients[0].size) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 self.assertEqual('', patients[0].contenttype) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
342
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
167 self.assertRaises(Exception, lambda: WEBDAV.delete('/webdav/nope')) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
168 self.assertRaises(Exception, lambda: WEBDAV.delete('/webdav/by-uids')) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
169 |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 def test_upload(self): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 self.assertEqual(0, len(ListFiles('/webdav/uploads/', True))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 uploads = WEBDAV.ls('/webdav/uploads/') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 for i in uploads: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 self.assertEqual(i.contenttype, '') # Only folders are allowed |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 self.assertEqual(0, len(DoGet(ORTHANC, '/studies'))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 WEBDAV.upload(GetDatabasePath('DummyCT.dcm'), '/webdav/uploads/DummyCT.dcm') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 while len(ListFiles('/webdav/uploads/', True)) > 1: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 time.sleep(0.1) |
343 | 183 time.sleep(0.1) # Give some more delay to be sure that the store has succeeded (necessary for Wine) |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 instances = DoGet(ORTHANC, '/instances?expand') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 self.assertEqual(1, len(instances)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109', |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 instances[0]['MainDicomTags']['SOPInstanceUID']) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 def test_upload_folders(self): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 self.assertEqual(0, len(ListFiles('/webdav/uploads/', True))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 self.assertEqual(0, len(DoGet(ORTHANC, '/studies'))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 try: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 WEBDAV.mkdir('/webdav/uploads/a') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 except: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 pass |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 try: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 WEBDAV.mkdir('/webdav/uploads/b') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 except: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 pass |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 WEBDAV.upload(GetDatabasePath('DummyCT.dcm'), '/webdav/uploads/a/DummyCT.dcm') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 WEBDAV.upload(GetDatabasePath('ColorTestMalaterre.dcm'), '/webdav/uploads/b/ColorTestMalaterre.dcm') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 while len(ListFiles('/webdav/uploads/', True)) > 1: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 time.sleep(0.1) |
343 | 209 time.sleep(0.1) # Give some more delay to be sure that the store has succeeded (necessary for Wine) |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 self.assertEqual(2, len(DoGet(ORTHANC, '/instances'))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 def test_by_uids(self): |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 self.assertEqual(1, len(WEBDAV.ls('/webdav/by-uids/'))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 self.assertEqual(0, len(ListFiles('/webdav/by-uids/', True))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
339 | 220 tags = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) |
221 studyUid = tags['StudyInstanceUID'] | |
222 seriesUid = tags['SeriesInstanceUID'] | |
223 sopUid = tags['SOPInstanceUID'] | |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 self.assertEqual(0, len(ListFiles('/webdav/by-uids/', False))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 self.assertEqual(1, len(ListFiles('/webdav/by-uids/%s/' % studyUid, False))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 self.assertEqual(2, len(ListFiles('/webdav/by-uids/%s/%s/' % (studyUid, seriesUid), False))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 content = ListFiles('/webdav/by-uids/', True) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 self.assertEqual(3, len(content)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 self.assertTrue(('/webdav/by-uids/%s/study.json' % studyUid) in content) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 self.assertTrue(('/webdav/by-uids/%s/%s/series.json' % (studyUid, seriesUid)) in content) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 self.assertTrue(('/webdav/by-uids/%s/%s/%s.dcm' % (studyUid, seriesUid, sopUid)) in content) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 |
342
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
235 # Deleting the virtual files "study|series.json" has no |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
236 # effect, but is needed for recursive DELETE in some file explorers |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
237 WEBDAV.delete('/webdav/by-uids/%s/study.json' % studyUid) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
238 WEBDAV.delete('/webdav/by-uids/%s/%s/series.json' % (studyUid, seriesUid)) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
239 |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 info = GetFileInfo('/webdav/by-uids/%s/study.json' % studyUid) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 self.assertEqual(info.contenttype, 'application/json') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 info = GetFileInfo('/webdav/by-uids/%s/%s/series.json' % (studyUid, seriesUid)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 self.assertEqual(info.contenttype, 'application/json') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 info = GetFileInfo('/webdav/by-uids/%s/%s/%s.dcm' % (studyUid, seriesUid, sopUid)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 self.assertEqual(info.contenttype, 'application/dicom') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 self.assertEqual(info.size, os.stat(GetDatabasePath('DummyCT.dcm')).st_size) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 a = DownloadFile('/webdav/by-uids/%s/%s/%s.dcm' % (studyUid, seriesUid, sopUid)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 self.assertEqual(len(a), info.size) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 self.assertEqual(a, f.read()) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 self.assertEqual(studyUid, json.loads(DownloadFile('/webdav/by-uids/%s/study.json' % studyUid)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 ['MainDicomTags']['StudyInstanceUID']) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 self.assertEqual(seriesUid, json.loads(DownloadFile('/webdav/by-uids/%s/%s/series.json' % (studyUid, seriesUid))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 ['MainDicomTags']['SeriesInstanceUID']) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 WEBDAV.delete('/webdav/by-uids/%s/%s/%s.dcm' % (studyUid, seriesUid, sopUid)) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) |
339 | 265 self.assertEqual(0, len(ListFiles('/webdav/by-uids/', True))) |
266 | |
267 | |
268 def test_by_patients(self): | |
269 self.assertEqual(0, len(ListFiles('/webdav/by-dates/', True))) | |
270 self.assertEqual(0, len(ListFiles('/webdav/by-patients/', True))) | |
271 self.assertEqual(0, len(ListFiles('/webdav/by-studies/', True))) | |
272 self.assertEqual(0, len(ListFiles('/webdav/by-uids/', True))) | |
273 | |
274 self.assertEqual(1, len(WEBDAV.ls('/webdav/by-patients/'))) | |
275 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) | |
276 | |
277 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] | |
278 tags = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) | |
279 patient = '%s - %s' % (tags['PatientID'], tags['PatientName']) | |
280 study = '%s - %s' % (tags['StudyDate'], tags['StudyDescription']) | |
281 series = '%s - %s' % (tags['Modality'], tags['SeriesDescription']) | |
282 self.assertEqual('ozp00SjY2xG - KNIX', patient) | |
283 self.assertEqual('20070101 - Knee (R)', study) | |
284 self.assertEqual('MR - AX. FSE PD', series) | |
285 | |
286 self.assertEqual(1, len(ListFiles('/webdav/by-dates/', True))) | |
287 self.assertEqual(1, len(ListFiles('/webdav/by-patients/', True))) | |
288 self.assertEqual(1, len(ListFiles('/webdav/by-studies/', True))) | |
289 self.assertEqual(3, len(ListFiles('/webdav/by-uids/', True))) | |
290 | |
291 self.assertEqual(0, len(ListFiles('/webdav/by-patients/', False))) | |
292 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-patients/'))) | |
293 self.assertEqual(0, len(ListFiles('/webdav/by-patients/%s' % patient, False))) | |
294 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-patients/%s' % patient))) | |
295 self.assertEqual(0, len(ListFiles('/webdav/by-patients/%s/%s' % (patient, study), False))) | |
296 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-patients/%s/%s' % (patient, study)))) | |
297 | |
298 folder = '/webdav/by-patients/%s/%s/%s' % (patient, study, series) | |
299 self.assertEqual(1, len(ListFiles(folder, False))) | |
300 self.assertEqual(2, len(WEBDAV.ls(folder))) | |
301 self.assertEqual('%s/%s.dcm' % (folder, i), unquote(ListFiles(folder, False) [0])) | |
302 | |
340
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
303 files = ListFiles('/webdav/by-patients/', True) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
304 self.assertEqual(1, len(files)) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
305 self.assertEqual('%s/%s.dcm' % (folder, i), unquote(files[0])) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
306 |
339 | 307 a = DownloadFile('%s/%s.dcm' % (folder, i)) |
308 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: | |
309 self.assertEqual(a, f.read()) | |
310 | |
311 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) | |
312 WEBDAV.delete('%s/%s.dcm' % (folder, i)) | |
313 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) | |
314 | |
315 self.assertEqual(0, len(ListFiles('/webdav/by-dates/', True))) | |
316 self.assertEqual(0, len(ListFiles('/webdav/by-patients/', True))) | |
317 self.assertEqual(0, len(ListFiles('/webdav/by-studies/', True))) | |
318 self.assertEqual(0, len(ListFiles('/webdav/by-uids/', True))) | |
319 | |
320 | |
321 def test_by_studies(self): | |
322 self.assertEqual(0, len(ListFiles('/webdav/by-studies/', True))) | |
323 self.assertEqual(1, len(WEBDAV.ls('/webdav/by-patients/'))) | |
324 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) | |
325 | |
326 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] | |
327 tags = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) | |
328 study = '%s - %s - %s' % (tags['PatientID'], tags['PatientName'], tags['StudyDescription']) | |
329 series = '%s - %s' % (tags['Modality'], tags['SeriesDescription']) | |
330 self.assertEqual('ozp00SjY2xG - KNIX - Knee (R)', study) | |
331 self.assertEqual('MR - AX. FSE PD', series) | |
332 | |
333 self.assertEqual(0, len(ListFiles('/webdav/by-studies/', False))) | |
334 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-studies/'))) | |
335 self.assertEqual(0, len(ListFiles('/webdav/by-studies/%s' % study, False))) | |
336 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-studies/%s' % study))) | |
337 | |
338 folder = '/webdav/by-studies/%s/%s' % (study, series) | |
339 self.assertEqual(1, len(ListFiles(folder, False))) | |
340 self.assertEqual(2, len(WEBDAV.ls(folder))) | |
341 self.assertEqual('%s/%s.dcm' % (folder, i), unquote(ListFiles(folder, False) [0])) | |
342 | |
340
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
343 files = ListFiles('/webdav/by-studies/', True) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
344 self.assertEqual(1, len(files)) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
345 self.assertEqual('%s/%s.dcm' % (folder, i), unquote(files[0])) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
346 |
339 | 347 a = DownloadFile('%s/%s.dcm' % (folder, i)) |
348 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: | |
349 self.assertEqual(a, f.read()) | |
350 | |
351 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) | |
352 WEBDAV.delete('%s/%s.dcm' % (folder, i)) | |
353 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) | |
354 self.assertEqual(0, len(ListFiles('/webdav/by-studies/', True))) | |
355 | |
356 | |
340
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
357 def test_by_dates(self): |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
358 self.assertEqual(0, len(ListFiles('/webdav/by-dates/', True))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
359 self.assertEqual(1, len(WEBDAV.ls('/webdav/by-patients/'))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
360 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
361 |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
362 i = UploadInstance(ORTHANC, 'DummyCT.dcm')['ID'] |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
363 tags = DoGet(ORTHANC, '/instances/%s/tags?simplify' % i) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
364 year = tags['StudyDate'][0:4] |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
365 month = tags['StudyDate'][4:6] |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
366 study = '%s - %s - %s' % (tags['PatientID'], tags['PatientName'], tags['StudyDescription']) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
367 series = '%s - %s' % (tags['Modality'], tags['SeriesDescription']) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
368 self.assertEqual('ozp00SjY2xG - KNIX - Knee (R)', study) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
369 self.assertEqual('MR - AX. FSE PD', series) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
370 |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
371 self.assertEqual(0, len(ListFiles('/webdav/by-dates/', False))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
372 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-dates/'))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
373 self.assertEqual(0, len(ListFiles('/webdav/by-dates/%s' % year, False))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
374 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-dates/%s' % year))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
375 self.assertEqual(0, len(ListFiles('/webdav/by-dates/%s/%s-%s' % (year, year, month), False))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
376 self.assertEqual(2, len(WEBDAV.ls('/webdav/by-dates/%s/%s-%s' % (year, year, month)))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
377 |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
378 folder = '/webdav/by-dates/%s/%s-%s/%s/%s' % (year, year, month, study, series) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
379 self.assertEqual(1, len(ListFiles(folder, False))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
380 self.assertEqual(2, len(WEBDAV.ls(folder))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
381 self.assertEqual('%s/%s.dcm' % (folder, i), unquote(ListFiles(folder, False) [0])) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
382 |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
383 files = ListFiles('/webdav/by-dates/', True) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
384 self.assertEqual(1, len(files)) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
385 self.assertEqual('%s/%s.dcm' % (folder, i), unquote(files[0])) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
386 |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
387 a = DownloadFile('%s/%s.dcm' % (folder, i)) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
388 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as f: |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
389 self.assertEqual(a, f.read()) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
390 |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
391 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
392 WEBDAV.delete('%s/%s.dcm' % (folder, i)) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
393 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) |
60775134a406
finalized webdav standalone tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
339
diff
changeset
|
394 self.assertEqual(0, len(ListFiles('/webdav/by-dates/', True))) |
339 | 395 |
342
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
396 |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
397 def test_delete_folder(self): |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
398 # These deletes should have no effect |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
399 UploadInstance(ORTHANC, 'DummyCT.dcm') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
400 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
401 WEBDAV.delete('/webdav/by-uids/1.2.840.113619.2.176.2025.1499492.7391.1171285944.390/study.json') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
402 WEBDAV.delete('/webdav/by-uids/1.2.840.113619.2.176.2025.1499492.7391.1171285944.390/1.2.840.113619.2.176.2025.1499492.7391.1171285944.394/series.json') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
403 WEBDAV.delete('/webdav/by-dates/2007/2007-02') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
404 WEBDAV.delete('/webdav/by-dates/2006') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
405 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
406 |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
407 for path in [ |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
408 '/webdav/by-uids/1.2.840.113619.2.176.2025.1499492.7391.1171285944.390/1.2.840.113619.2.176.2025.1499492.7391.1171285944.394/1.2.840.113619.2.176.2025.1499492.7040.1171286242.109.dcm', |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
409 '/webdav/by-patients/ozp00SjY2xG - KNIX/20070101 - Knee (R)/MR - AX. FSE PD/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d.dcm', |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
410 '/webdav/by-studies/ozp00SjY2xG - KNIX - Knee (R)/MR - AX. FSE PD/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d.dcm', |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
411 '/webdav/by-dates/2007/2007-01/ozp00SjY2xG - KNIX - Knee (R)/MR - AX. FSE PD/66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d.dcm', |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
412 ]: |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
413 tokens = path.split('/') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
414 for i in range(4, len(tokens) + 1): |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
415 p = '/'.join(tokens[0:i]) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
416 UploadInstance(ORTHANC, 'DummyCT.dcm') |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
417 self.assertEqual(1, len(DoGet(ORTHANC, '/instances'))) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
418 WEBDAV.delete(p) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
419 self.assertEqual(0, len(DoGet(ORTHANC, '/instances'))) |
bf8369ea3ff1
more tests of webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
340
diff
changeset
|
420 |
358
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
421 |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
422 def test_upload_zip(self): |
610
ec657d1a62a6
fix compatibility with python3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
511
diff
changeset
|
423 f = BytesIO() |
358
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
424 with zipfile.ZipFile(f, 'w') as z: |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
425 z.writestr('hello/world/invalid.txt', 'Hello world') |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
426 with open(GetDatabasePath('DummyCT.dcm'), 'rb') as g: |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
427 c = g.read() |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
428 z.writestr('hello/world/dicom1.dcm', c) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
429 z.writestr('hello/world/dicom2.dcm', c) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
430 |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
431 f.seek(0) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
432 archive = f.read() |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
433 |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
434 self.assertEqual(0, len(DoGet(ORTHANC, '/studies'))) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
435 |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
436 with tempfile.NamedTemporaryFile(delete = True) as f: |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
437 f.close() |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
438 with open(f.name, 'wb') as g: |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
439 g.write(archive) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
440 WEBDAV.upload(f.name, '/webdav/uploads/DummyCT.zip') |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
441 os.unlink(f.name) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
442 |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
443 while len(ListFiles('/webdav/uploads/', True)) > 1: |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
444 time.sleep(0.1) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
445 time.sleep(0.1) # Give some more delay to be sure that the store has succeeded (necessary for Wine) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
446 |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
447 instances = DoGet(ORTHANC, '/instances') |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
448 self.assertEqual(1, len(instances)) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
449 self.assertEqual('66a662ce-7430e543-bad44d47-0dc5a943-ec7a538d', instances[0]) |
458b2d887ea0
WebDAV: test_upload_zip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
343
diff
changeset
|
450 |
339 | 451 |
338
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 try: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 print('\nStarting the tests...') |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 unittest.main(argv = [ sys.argv[0] ] + args.options) |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 finally: |
edaeb57bf01f
creating tests for webdav
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 print('\nDone') |