Mercurial > hg > orthanc-tests
changeset 521:8114f67e0f7f
labels: doc
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 07 Apr 2023 15:04:59 +0200 |
parents | a06d0a45c62f |
children | fce9e90acdc2 |
files | Tests/Tests.py |
diffstat | 1 files changed, 39 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Tests/Tests.py Fri Apr 07 10:48:04 2023 +0200 +++ b/Tests/Tests.py Fri Apr 07 15:04:59 2023 +0200 @@ -9342,17 +9342,53 @@ '/series/%s' % series, '/studies/%s' % study, '/patients/%s' % patient ]: + + # no tags by default self.assertEqual(0, len(DoGet(_REMOTE, base) ['Labels'])) + + # 404 if requesting a tag that does apply for a resource self.assertRaises(Exception, lambda: DoGet(_REMOTE, '%s/labels/hello' % base)) + + # delete a non existing tag does not generate an error self.assertEqual('', DoDelete(_REMOTE, '%s/labels/hello' % base)) self.assertEqual(0, len(DoGet(_REMOTE, base) ['Labels'])) - self.assertRaises(Exception, lambda: DoPut(_REMOTE, '%s/labels/@' % base)) # Not an alphanumeric label + + # Not an alphanumeric label -> 400 + self.assertRaises(Exception, lambda: DoPut(_REMOTE, '%s/labels/@' % base)) + + # add a tag self.assertEqual('', DoPut(_REMOTE, '%s/labels/hello' % base)) - self.assertEqual('', DoPut(_REMOTE, '%s/labels/hello' % base)) # Ignore double tagging + self.assertEqual(1, len(DoGet(_REMOTE, base) ['Labels'])) + self.assertEqual('hello', DoGet(_REMOTE, base) ['Labels'][0]) + + # double tagging does not generate any error + self.assertEqual('', DoPut(_REMOTE, '%s/labels/hello' % base)) + self.assertEqual('', DoGet(_REMOTE, '%s/labels/hello' % base)) + self.assertEqual(1, len(DoGet(_REMOTE, base) ['Labels'])) + self.assertEqual('hello', DoGet(_REMOTE, base) ['Labels'][0]) + + # add a second tag + self.assertEqual('', DoPut(_REMOTE, '%s/labels/world' % base)) + self.assertEqual('', DoGet(_REMOTE, '%s/labels/world' % base)) self.assertEqual('', DoGet(_REMOTE, '%s/labels/hello' % base)) + self.assertEqual(2, len(DoGet(_REMOTE, base) ['Labels'])) + self.assertIn(DoGet(_REMOTE, base) ['Labels'][0], ['hello', 'world']) + self.assertIn(DoGet(_REMOTE, base) ['Labels'][1], ['hello', 'world']) + + # list all tags defined in the system (not only on this resource) + + # delete the first tag self.assertEqual('', DoDelete(_REMOTE, '%s/labels/hello' % base)) + self.assertEqual(1, len(DoGet(_REMOTE, base) ['Labels'])) + self.assertEqual('world', DoGet(_REMOTE, base) ['Labels'][0]) + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '%s/labels/hello' % base)) + + # delete the second tag + self.assertEqual('', DoDelete(_REMOTE, '%s/labels/world' % base)) self.assertEqual(0, len(DoGet(_REMOTE, base) ['Labels'])) - self.assertRaises(Exception, lambda: DoGet(_REMOTE, '%s/labels/hello' % base)) + self.assertRaises(Exception, lambda: DoGet(_REMOTE, '%s/labels/world' % base)) + + # test all valid chars self.assertEqual('', DoPut(_REMOTE, '%s/labels/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.' % base)) else: print("Your database backend doesn't support labels")