Mercurial > hg > orthanc-tests
comparison Tests/Tests.py @ 522:fce9e90acdc2
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Apr 2023 22:18:53 +0200 |
parents | 8114f67e0f7f |
children | 767840cb4d3f |
comparison
equal
deleted
inserted
replaced
521:8114f67e0f7f | 522:fce9e90acdc2 |
---|---|
9392 self.assertEqual('', DoPut(_REMOTE, '%s/labels/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.' % base)) | 9392 self.assertEqual('', DoPut(_REMOTE, '%s/labels/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.' % base)) |
9393 else: | 9393 else: |
9394 print("Your database backend doesn't support labels") | 9394 print("Your database backend doesn't support labels") |
9395 | 9395 |
9396 def test_find_labels(self): | 9396 def test_find_labels(self): |
9397 def Execute(withLabels, withoutLabels): | 9397 def Execute(labels, constraint): |
9398 return DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', | 9398 return DoPost(_REMOTE, '/tools/find', { 'Level' : 'Instance', |
9399 'Query' : { }, | 9399 'Query' : { }, |
9400 'WithLabels' : withLabels, | 9400 'Labels' : labels, |
9401 'WithoutLabels' : withoutLabels, }) | 9401 'LabelsConstraint' : constraint, }) |
9402 | 9402 |
9403 if (IsOrthancVersionAbove(_REMOTE, 1, 12, 0) and | 9403 if (IsOrthancVersionAbove(_REMOTE, 1, 12, 0) and |
9404 DoGet(_REMOTE, '/system') ['HasLabels']): | 9404 DoGet(_REMOTE, '/system') ['HasLabels']): |
9405 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] | 9405 u = UploadInstance(_REMOTE, 'DummyCT.dcm')['ID'] |
9406 | 9406 |
9407 self.assertEqual(1, len(Execute([], []))) | 9407 # The instance has no label |
9408 self.assertEqual(0, len(Execute([ 'a' ], []))) | 9408 self.assertEqual(1, len(Execute([], 'All'))) |
9409 self.assertEqual(0, len(Execute([ 'a', 'b' ], []))) | 9409 self.assertEqual(1, len(Execute([], 'Any'))) |
9410 self.assertEqual(1, len(Execute([], [ 'c' ]))) | 9410 self.assertEqual(1, len(Execute([], 'None'))) |
9411 self.assertEqual(1, len(Execute([], [ 'c', 'd' ]))) | 9411 self.assertEqual(0, len(Execute([ 'a' ], 'All'))) |
9412 self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ]))) | 9412 self.assertEqual(0, len(Execute([ 'a' ], 'Any'))) |
9413 self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ]))) | 9413 self.assertEqual(1, len(Execute([ 'a' ], 'None'))) |
9414 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ]))) | 9414 self.assertEqual(0, len(Execute([ 'b' ], 'All'))) |
9415 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ]))) | 9415 self.assertEqual(0, len(Execute([ 'b' ], 'Any'))) |
9416 self.assertEqual(1, len(Execute([ 'b' ], 'None'))) | |
9417 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All'))) | |
9418 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'Any'))) | |
9419 self.assertEqual(1, len(Execute([ 'a', 'b' ], 'None'))) | |
9416 | 9420 |
9417 DoPut(_REMOTE, '/instances/%s/labels/a' % u) | 9421 DoPut(_REMOTE, '/instances/%s/labels/a' % u) |
9418 self.assertEqual(1, len(Execute([], []))) | 9422 # The instance has label "a" |
9419 self.assertEqual(1, len(Execute([ 'a' ], []))) | 9423 self.assertEqual(1, len(Execute([], 'All'))) |
9420 self.assertEqual(0, len(Execute([ 'a', 'b' ], []))) | 9424 self.assertEqual(1, len(Execute([], 'Any'))) |
9421 self.assertEqual(1, len(Execute([], [ 'c' ]))) | 9425 self.assertEqual(1, len(Execute([], 'None'))) |
9422 self.assertEqual(1, len(Execute([], [ 'c', 'd' ]))) | 9426 self.assertEqual(1, len(Execute([ 'a' ], 'All'))) |
9423 self.assertEqual(1, len(Execute([ 'a' ], [ 'c' ]))) | 9427 self.assertEqual(1, len(Execute([ 'a' ], 'Any'))) |
9424 self.assertEqual(1, len(Execute([ 'a' ], [ 'c', 'd' ]))) | 9428 self.assertEqual(0, len(Execute([ 'a' ], 'None'))) |
9425 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ]))) | 9429 self.assertEqual(0, len(Execute([ 'b' ], 'All'))) |
9426 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ]))) | 9430 self.assertEqual(0, len(Execute([ 'b' ], 'Any'))) |
9431 self.assertEqual(1, len(Execute([ 'b' ], 'None'))) | |
9432 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All'))) | |
9433 self.assertEqual(1, len(Execute([ 'a', 'b' ], 'Any'))) | |
9434 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'None'))) | |
9427 | 9435 |
9428 DoPut(_REMOTE, '/instances/%s/labels/b' % u) | 9436 DoPut(_REMOTE, '/instances/%s/labels/b' % u) |
9429 self.assertEqual(1, len(Execute([], []))) | 9437 # The instance has labels "a" and "b" |
9430 self.assertEqual(1, len(Execute([ 'a' ], []))) | 9438 self.assertEqual(1, len(Execute([], 'All'))) |
9431 self.assertEqual(1, len(Execute([ 'a', 'b' ], []))) | 9439 self.assertEqual(1, len(Execute([], 'Any'))) |
9432 self.assertEqual(1, len(Execute([], [ 'c' ]))) | 9440 self.assertEqual(1, len(Execute([], 'None'))) |
9433 self.assertEqual(1, len(Execute([], [ 'c', 'd' ]))) | 9441 self.assertEqual(1, len(Execute([ 'a' ], 'All'))) |
9434 self.assertEqual(1, len(Execute([ 'a' ], [ 'c' ]))) | 9442 self.assertEqual(1, len(Execute([ 'a' ], 'Any'))) |
9435 self.assertEqual(1, len(Execute([ 'a' ], [ 'c', 'd' ]))) | 9443 self.assertEqual(0, len(Execute([ 'a' ], 'None'))) |
9436 self.assertEqual(1, len(Execute([ 'a', 'b' ], [ 'c' ]))) | 9444 self.assertEqual(1, len(Execute([ 'b' ], 'All'))) |
9437 self.assertEqual(1, len(Execute([ 'a', 'b' ], [ 'c', 'd' ]))) | 9445 self.assertEqual(1, len(Execute([ 'b' ], 'Any'))) |
9438 | 9446 self.assertEqual(0, len(Execute([ 'b' ], 'None'))) |
9439 DoPut(_REMOTE, '/instances/%s/labels/d' % u) | 9447 self.assertEqual(1, len(Execute([ 'a', 'b' ], 'All'))) |
9440 self.assertEqual(1, len(Execute([], []))) | 9448 self.assertEqual(1, len(Execute([ 'a', 'b' ], 'Any'))) |
9441 self.assertEqual(1, len(Execute([ 'a' ], []))) | 9449 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'None'))) |
9442 self.assertEqual(1, len(Execute([ 'a', 'b' ], []))) | |
9443 self.assertEqual(1, len(Execute([], [ 'c' ]))) | |
9444 self.assertEqual(0, len(Execute([], [ 'c', 'd' ]))) | |
9445 self.assertEqual(1, len(Execute([ 'a' ], [ 'c' ]))) | |
9446 self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ]))) | |
9447 self.assertEqual(1, len(Execute([ 'a', 'b' ], [ 'c' ]))) | |
9448 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ]))) | |
9449 | |
9450 DoPut(_REMOTE, '/instances/%s/labels/c' % u) | |
9451 self.assertEqual(1, len(Execute([], []))) | |
9452 self.assertEqual(1, len(Execute([ 'a' ], []))) | |
9453 self.assertEqual(1, len(Execute([ 'a', 'b' ], []))) | |
9454 self.assertEqual(0, len(Execute([], [ 'c' ]))) | |
9455 self.assertEqual(0, len(Execute([], [ 'c', 'd' ]))) | |
9456 self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ]))) | |
9457 self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ]))) | |
9458 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ]))) | |
9459 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ]))) | |
9460 | |
9461 DoDelete(_REMOTE, '/instances/%s/labels/b' % u) | |
9462 self.assertEqual(1, len(Execute([], []))) | |
9463 self.assertEqual(1, len(Execute([ 'a' ], []))) | |
9464 self.assertEqual(0, len(Execute([ 'a', 'b' ], []))) | |
9465 self.assertEqual(0, len(Execute([], [ 'c' ]))) | |
9466 self.assertEqual(0, len(Execute([], [ 'c', 'd' ]))) | |
9467 self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ]))) | |
9468 self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ]))) | |
9469 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ]))) | |
9470 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ]))) | |
9471 | 9450 |
9472 DoDelete(_REMOTE, '/instances/%s/labels/a' % u) | 9451 DoDelete(_REMOTE, '/instances/%s/labels/a' % u) |
9473 self.assertEqual(1, len(Execute([], []))) | 9452 # The instance has label "b" |
9474 self.assertEqual(0, len(Execute([ 'a' ], []))) | 9453 self.assertEqual(1, len(Execute([], 'All'))) |
9475 self.assertEqual(0, len(Execute([ 'a', 'b' ], []))) | 9454 self.assertEqual(1, len(Execute([], 'Any'))) |
9476 self.assertEqual(0, len(Execute([], [ 'c' ]))) | 9455 self.assertEqual(1, len(Execute([], 'None'))) |
9477 self.assertEqual(0, len(Execute([], [ 'c', 'd' ]))) | 9456 self.assertEqual(0, len(Execute([ 'a' ], 'All'))) |
9478 self.assertEqual(0, len(Execute([ 'a' ], [ 'c' ]))) | 9457 self.assertEqual(0, len(Execute([ 'a' ], 'Any'))) |
9479 self.assertEqual(0, len(Execute([ 'a' ], [ 'c', 'd' ]))) | 9458 self.assertEqual(1, len(Execute([ 'a' ], 'None'))) |
9480 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c' ]))) | 9459 self.assertEqual(1, len(Execute([ 'b' ], 'All'))) |
9481 self.assertEqual(0, len(Execute([ 'a', 'b' ], [ 'c', 'd' ]))) | 9460 self.assertEqual(1, len(Execute([ 'b' ], 'Any'))) |
9482 | 9461 self.assertEqual(0, len(Execute([ 'b' ], 'None'))) |
9462 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All'))) | |
9463 self.assertEqual(1, len(Execute([ 'a', 'b' ], 'Any'))) | |
9464 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'None'))) | |
9465 | |
9466 DoDelete(_REMOTE, '/instances/%s/labels/b' % u) | |
9467 # The instance has no more label | |
9468 self.assertEqual(1, len(Execute([], 'All'))) | |
9469 self.assertEqual(1, len(Execute([], 'Any'))) | |
9470 self.assertEqual(1, len(Execute([], 'None'))) | |
9471 self.assertEqual(0, len(Execute([ 'a' ], 'All'))) | |
9472 self.assertEqual(0, len(Execute([ 'a' ], 'Any'))) | |
9473 self.assertEqual(1, len(Execute([ 'a' ], 'None'))) | |
9474 self.assertEqual(0, len(Execute([ 'b' ], 'All'))) | |
9475 self.assertEqual(0, len(Execute([ 'b' ], 'Any'))) | |
9476 self.assertEqual(1, len(Execute([ 'b' ], 'None'))) | |
9477 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'All'))) | |
9478 self.assertEqual(0, len(Execute([ 'a', 'b' ], 'Any'))) | |
9479 self.assertEqual(1, len(Execute([ 'a', 'b' ], 'None'))) | |
9480 | |
9483 else: | 9481 else: |
9484 print("Your database backend doesn't support labels") | 9482 print("Your database backend doesn't support labels") |