annotate Tests/Tests.py @ 3:2dbba2e6aa4b

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 17 Jun 2015 10:03:49 +0200
parents
children 19eb87a45685
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 # Orthanc - A Lightweight, RESTful DICOM Store
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 # Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Department, University Hospital of Liege, Belgium
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 #
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # This program is free software: you can redistribute it and/or
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 # modify it under the terms of the GNU General Public License as
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # published by the Free Software Foundation, either version 3 of the
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # License, or (at your option) any later version.
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 #
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful, but
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # General Public License for more details.
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 #
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 import unittest
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 from Toolbox import *
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 _LOCAL = None
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 _REMOTE = None
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 def SetOrthancParameters(local, remote):
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 global _LOCAL, _REMOTE
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 _LOCAL = local
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 _REMOTE = remote
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 class Orthanc(unittest.TestCase):
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 def setUp(self):
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 DropOrthanc(_LOCAL)
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 DropOrthanc(_REMOTE)
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 def test_system(self):
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 self.assertTrue('Version' in DoGet(_REMOTE, '/system'))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 def test_upload(self):
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 u = UploadInstance(_REMOTE, 'DummyCT.dcm')
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 self.assertEqual('Success', u['Status'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 u = UploadInstance(_REMOTE, 'DummyCT.dcm')
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 self.assertEqual('AlreadyStored', u['Status'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 self.assertEqual(1, len(DoGet(_REMOTE, '/patients')))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 self.assertEqual(1, len(DoGet(_REMOTE, '/studies')))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 self.assertEqual(1, len(DoGet(_REMOTE, '/series')))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 self.assertEqual(1, len(DoGet(_REMOTE, '/instances')))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 i = DoGet(_REMOTE, '/instances/%s/simplified-tags' % u['ID'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 self.assertEqual('20070101', i['StudyDate'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 def test_rest_grid(self):
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 i = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID']
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 instance = DoGet(_REMOTE, '/instances/%s' % i)
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 self.assertEqual(i, instance['ID'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7040.1171286242.109',
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 instance['MainDicomTags']['SOPInstanceUID'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 series = DoGet(_REMOTE, '/series/%s' % instance['ParentSeries'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.394',
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 series['MainDicomTags']['SeriesInstanceUID'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 study = DoGet(_REMOTE, '/studies/%s' % series['ParentStudy'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 self.assertEqual('1.2.840.113619.2.176.2025.1499492.7391.1171285944.390',
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 study['MainDicomTags']['StudyInstanceUID'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 patient = DoGet(_REMOTE, '/patients/%s' % study['ParentPatient'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 self.assertEqual('ozp00SjY2xG',
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 patient['MainDicomTags']['PatientID'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 dicom = DoGet(_REMOTE, '/instances/%s/file' % instance['ID'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 self.assertEqual(2472, len(dicom))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 self.assertEqual('3e29b869978b6db4886355a2b1132124', ComputeMD5(dicom))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 self.assertEqual(1, len(DoGet(_REMOTE, '/instances/%s/frames' % i)))
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/simplified-tags' % i)['StationName'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 self.assertEqual('TWINOW', DoGet(_REMOTE, '/instances/%s/tags' % i)['0008,1010']['Value'])
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
2dbba2e6aa4b reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84