changeset 349:698898a93a10

test_log_categories
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 03 Nov 2020 14:32:38 +0100
parents bed0ab3a1391
children 8c072000d7ef
files Tests/Tests.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Tests/Tests.py	Sun Nov 01 12:41:52 2020 +0100
+++ b/Tests/Tests.py	Tue Nov 03 14:32:38 2020 +0100
@@ -6059,3 +6059,28 @@
             time.sleep(0.01)
         self.assertEqual(1, len(DoGet(_REMOTE, '/patients')))
             
+
+    def test_log_categories(self):
+        original = DoGet(_REMOTE, '/tools/log-level-rest')
+        
+        DoPut(_REMOTE, '/tools/log-level-rest', 'default')
+        self.assertEqual('default', DoGet(_REMOTE, '/tools/log-level-rest'))
+        DoGet(_REMOTE, '/system')
+
+        DoPut(_REMOTE, '/tools/log-level-rest', 'verbose')
+        self.assertEqual('verbose', DoGet(_REMOTE, '/tools/log-level-rest'))
+        DoGet(_REMOTE, '/system')
+
+        DoPut(_REMOTE, '/tools/log-level-rest', 'trace')
+        self.assertEqual('trace', DoGet(_REMOTE, '/tools/log-level-rest'))
+        DoGet(_REMOTE, '/system')
+
+        self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/log-level-rest', 'nope'))
+        
+        # Switch back to the original log level
+        DoPut(_REMOTE, '/tools/log-level-rest', original)
+
+        for c in [ 'generic', 'rest', 'dicom', 'plugins', 'sqlite' ]:
+            DoPut(_REMOTE, '/tools/log-level-%s' % c, DoGet(_REMOTE, '/tools/log-level-%s' % c))
+
+        self.assertRaises(Exception, lambda: DoPut(_REMOTE, '/tools/log-level-nope', 'default'))