annotate Plugins/Worklists/Run.py @ 90:afbac3eb28a5

integration tests of worklists
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 Dec 2016 11:59:35 +0100
parents
children ba5619c3941d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Orthanc - A Lightweight, RESTful DICOM Store
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Department, University Hospital of Liege, Belgium
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # modify it under the terms of the GNU General Public License as
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # published by the Free Software Foundation, either version 3 of the
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # License, or (at your option) any later version.
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 #
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful, but
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # General Public License for more details.
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 #
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # You should have received a copy of the GNU General Public License
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 import argparse
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 import os
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 import pprint
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 import re
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 import subprocess
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 import sys
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 import tempfile
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 import unittest
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'Tests'))
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 from Toolbox import *
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 ##
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 ## Parse the command-line arguments
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 ##
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 parser = argparse.ArgumentParser(description = 'Run the integration tests for the DICOM worklist plugin.')
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 parser.add_argument('--server',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 default = 'localhost',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 help = 'Address of the Orthanc server to test')
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 parser.add_argument('--dicom',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 type = int,
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 default = 4242,
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 help = 'DICOM port of the Orthanc instance to test')
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 parser.add_argument('options', metavar = 'N', nargs = '*',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 help='Arguments to Python unittest')
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 args = parser.parse_args()
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 ##
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ## Toolbox
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 ##
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 DATABASE = os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), '..', '..', 'Database', 'Worklists')))
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 WORKING = os.path.join(DATABASE, 'Working')
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 try:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 os.mkdir(WORKING)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 except Exception as e:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 # The working folder has already been created
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 pass
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 def ClearDatabase():
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 for f in os.listdir(WORKING):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 if f != 'lockfile':
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 os.remove(os.path.join(WORKING, f))
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 def AddToDatabase(source):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 subprocess.check_call([ 'dump2dcm', '-g', '--write-xfer-little',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 os.path.join(DATABASE, source),
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 os.path.join(WORKING, os.path.basename(source) + '.wl') ])
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 def RunQuery(source, ignoreTags):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 with tempfile.NamedTemporaryFile() as f:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 subprocess.check_call([ 'dump2dcm', '-g', '--write-xfer-little',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 os.path.join(DATABASE, source), f.name ])
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 a = subprocess.check_output([ 'findscu', '-v', '--call', 'ORTHANC', '-aet', 'ORTHANCTEST',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 args.server, str(args.dicom), f.name ],
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 stderr = subprocess.STDOUT).splitlines()
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 if len(filter(lambda x: x.startswith('E:'), a)) > 0:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 raise Exception('Error while running findscu')
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 b = map(lambda x: x[3:], filter(lambda x: x.startswith('W: ---') or x.startswith('W: ('), a))
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 b = map(lambda x: re.sub(r'\s*#.*', '', x), b)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 answers = []
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 current = []
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 for l in b:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 if l[0] == '-':
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 # This is a separator between DICOM datasets
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 if len(current) > 0:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 answers.append(current)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 current = []
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 else:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 tag = l[1:10].lower()
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 if not tag in ignoreTags:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 current.append(l)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 if len(current) > 0:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 answers.append(current)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 return answers
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 def CompareAnswers(expected, actual):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 if len(expected) != len(actual):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 return False
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 if len(expected) == 0:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 return True
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 for i in range(len(expected)):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 for j in range(len(actual)):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 if expected[i] == actual[j]:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 return True
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 return False
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 ##
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 ## The tests
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 ##
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 class Orthanc(unittest.TestCase):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 def setUp(self):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 if (sys.version_info >= (3, 0)):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 # Remove annoying warnings about unclosed socket in Python 3
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 import warnings
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 warnings.simplefilter("ignore", ResourceWarning)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 ClearDatabase()
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 def test_single(self):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 for db in range(1, 11):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 ClearDatabase()
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 AddToDatabase('DcmtkDatabase/wklist%d.dump' % db)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 for query in range(0, 13):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 answers = RunQuery('DcmtkQueries/wlistqry%d.dump' % query, [
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 '0008,0005',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 '0040,0004',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 '0040,0005',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 '0040,0020',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 ])
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 with open(os.path.join('%s/DcmtkExpected/single-%d-%d.json' % (DATABASE, db, query)), 'r') as f:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 expected = json.loads(f.read())
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 self.assertTrue(CompareAnswers(expected, answers))
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 def test_all(self):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 ClearDatabase()
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 for db in range(1, 11):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 AddToDatabase('DcmtkDatabase/wklist%d.dump' % db)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 for query in range(0, 13):
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 answers = RunQuery('DcmtkQueries/wlistqry%d.dump' % query, [
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 '0008,0005',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 '0040,0004',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 '0040,0005',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 '0040,0020',
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 ])
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 with open(os.path.join('%s/DcmtkExpected/all-%d.json' % (DATABASE, query)), 'r') as f:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 expected = json.loads(f.read())
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 self.assertTrue(CompareAnswers(expected, answers))
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 try:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 print('\nStarting the tests...')
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 unittest.main(argv = [ sys.argv[0] ] + args.options)
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 finally:
afbac3eb28a5 integration tests of worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 print('\nDone')