changeset 211:a05cc24f84e5

test_series_status
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Feb 2019 11:36:30 +0100
parents 2c50c8f340c2
children dc9682d80d22
files Database/Series/Generate.sh Database/Series/Lena-1.dcm Database/Series/Lena-2.dcm Database/Series/Lena-3.dcm Database/Series/Lena-4.dcm Database/Series/Lena-5.dcm Tests/Tests.py
diffstat 7 files changed, 55 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Database/Series/Generate.sh	Mon Feb 04 11:36:30 2019 +0100
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+set -e
+
+convert -quality 90 -resize 128x128 ../Lena.png /tmp/Lena.jpg
+
+function Generate() {
+    echo $1
+    img2dcm /tmp/Lena.jpg Lena-$1.dcm \
+            -k "ImagesInAcquisition=2" \
+            -k "NumberOfTemporalPositions=2" \
+            -k "InstanceNumber=$1" \
+            -k "StudyInstanceUID=1.2.840.113619.2.176.2025.1499492.7391.1171285944.390" \
+            -k "SeriesInstanceUID=1.2.840.113619.2.176.2025.1499492.7391.1171285944.394"    
+}
+
+Generate 1
+Generate 2
+Generate 3
+Generate 4
+Generate 5
Binary file Database/Series/Lena-1.dcm has changed
Binary file Database/Series/Lena-2.dcm has changed
Binary file Database/Series/Lena-3.dcm has changed
Binary file Database/Series/Lena-4.dcm has changed
Binary file Database/Series/Lena-5.dcm has changed
--- a/Tests/Tests.py	Thu Jan 31 17:39:24 2019 +0100
+++ b/Tests/Tests.py	Mon Feb 04 11:36:30 2019 +0100
@@ -348,6 +348,7 @@
                 self.assertEqual(patient, study['ParentPatient'])
                 for series in DoGet(_REMOTE, '/studies/%s/series' % study['ID']):
                     self.assertEqual(study['ID'], series['ParentStudy'])
+                    self.assertEqual('Unknown', series['Status'])
                     for instance in DoGet(_REMOTE, '/series/%s/instances' % series['ID']):
                         self.assertEqual(series['ID'], instance['ParentSeries'])
 
@@ -4367,3 +4368,36 @@
         a = DoPost(_REMOTE, '/tools/find', { 'Level' : 'Study',
                                              'Query' : { 'ModalitiesInStudy' : 'CT' }})
         self.assertEqual(1, len(a))
+
+
+    def test_series_status(self):
+        def HasCompletedInChanges():
+            for c in DoGet(_REMOTE, '/changes?limit=1000&since=0')['Changes']:
+                if c['ChangeType'] == 'CompletedSeries':
+                    return True;
+
+            return False
+        
+        UploadInstance(_REMOTE, 'Knix/Loc/IM-0001-0001.dcm')
+        series = '8ea120d7-5057d919-837dfbcc-ccd04e0f-7f3a94aa'
+        self.assertEqual('Unknown', DoGet(_REMOTE, '/series/%s' % series)['Status'])
+        self.assertFalse(HasCompletedInChanges())
+
+        series = 'ce25ecb6-ed79d004-5ae43ca7-3fc89bc5-67511614'
+
+        for i in range(3):
+            UploadInstance(_REMOTE, 'Series/Lena-%d.dcm' % (i + 1))
+            self.assertEqual('Missing', DoGet(_REMOTE, '/series/%s' % series)['Status'])
+            self.assertFalse(HasCompletedInChanges())
+
+        UploadInstance(_REMOTE, 'Series/Lena-4.dcm')
+        self.assertEqual('Complete', DoGet(_REMOTE, '/series/%s' % series)['Status'])
+        self.assertTrue(HasCompletedInChanges())
+
+        DoDelete(_REMOTE, '/changes')
+        self.assertFalse(HasCompletedInChanges())
+
+        UploadInstance(_REMOTE, 'Series/Lena-5.dcm')
+        self.assertEqual('Inconsistent', DoGet(_REMOTE, '/series/%s' % series)['Status'])
+        self.assertFalse(HasCompletedInChanges())
+