changeset 213:eba6b8c38eee

added a delete_cascade test to reproduce an issue in our MSSQL plugin
author amazy
date Tue, 05 Feb 2019 11:26:58 +0100
parents dc9682d80d22
children 13fa120c54a0
files Tests/Tests.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Mon Feb 04 16:02:34 2019 +0100
+++ b/Tests/Tests.py	Tue Feb 05 11:26:58 2019 +0100
@@ -390,6 +390,23 @@
         self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalDiskSize'])
         self.assertEqual('0', DoGet(_REMOTE, '/statistics')['TotalUncompressedSize'])
 
+    def test_delete_cascade(self):
+        # make sure deleting the last instance of a study deletes the series, study and patient
+
+        self.assertEqual(0, len(DoGet(_REMOTE, '/instances')))  # make sure orthanc is empty when starting the test
+        a = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID']
+        self.assertEqual(1, len(DoGet(_REMOTE, '/instances')))
+        self.assertEqual(1, len(DoGet(_REMOTE, '/series')))
+        self.assertEqual(1, len(DoGet(_REMOTE, '/studies')))
+        self.assertEqual(1, len(DoGet(_REMOTE, '/patients')))
+
+        DoDelete(_REMOTE, '/instances/%s' % a)        
+
+        self.assertEqual(0, len(DoGet(_REMOTE, '/instances')))
+        self.assertEqual(0, len(DoGet(_REMOTE, '/series')))
+        self.assertEqual(0, len(DoGet(_REMOTE, '/studies')))
+        self.assertEqual(0, len(DoGet(_REMOTE, '/patients')))
+
 
     def test_multiframe(self):
         i = UploadInstance(_REMOTE, 'Multiframe.dcm')['ID']