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