33
33
from openassetio .access import (
34
34
PolicyAccess ,
35
35
PublishingAccess ,
36
+ DefaultEntityAccess ,
36
37
RelationsAccess ,
37
38
ResolveAccess ,
38
39
EntityTraitsAccess ,
41
42
BatchElementError ,
42
43
BatchElementException ,
43
44
ConfigurationException ,
45
+ NotImplementedException ,
44
46
)
45
47
from openassetio .test .manager .harness import FixtureAugmentedTestCase
46
48
from openassetio .trait import TraitsData
@@ -83,8 +85,8 @@ def setUp(self):
83
85
"resources" ,
84
86
self ._library ,
85
87
)
86
- self ._manager .initialize (new_settings )
87
88
self .addCleanup (self .cleanUp )
89
+ self ._manager .initialize (new_settings )
88
90
89
91
def cleanUp (self ):
90
92
self ._manager .initialize (self .__old_settings )
@@ -370,7 +372,7 @@ def test_returns_expected_policy_for_managerDriven_for_all_trait_sets(self):
370
372
self .assertListEqual (actual , expected )
371
373
372
374
373
- class Test_hasCapability (FixtureAugmentedTestCase ):
375
+ class Test_hasCapability_default (FixtureAugmentedTestCase ):
374
376
"""
375
377
Tests that BAL reports expected capabilities
376
378
"""
@@ -395,6 +397,96 @@ def test_when_hasCapability_called_on_managerInterface_then_has_mandatory_capabi
395
397
)
396
398
397
399
400
+ class Test_hasCapability_override_none (LibraryOverrideTestCase ):
401
+ _library = "library_business_logic_suite_capabilities_none.json"
402
+
403
+ def setUp (self ):
404
+ # Override base class because otherwise it'll raise. The setUp
405
+ # in this case _is_ the test.
406
+ pass
407
+
408
+ def test_when_when_library_lists_no_capabilities_then_raises (self ):
409
+ with self .assertRaises (ConfigurationException ) as exc :
410
+ # Call base class setup, which will re-initialize the
411
+ # manager with the alternative self._library JSON file.
412
+ super ().setUp ()
413
+
414
+ self .assertEqual (
415
+ str (exc .exception ),
416
+ "Manager implementation for 'org.openassetio.examples.manager.bal' does not"
417
+ " support the required capabilities: entityReferenceIdentification,"
418
+ " managementPolicyQueries, entityTraitIntrospection" ,
419
+ )
420
+
421
+
422
+ class Test_hasCapability_override_all (LibraryOverrideTestCase ):
423
+ _library = "library_business_logic_suite_capabilities_all.json"
424
+
425
+ def test_when_library_lists_all_capabilities_then_hasCapability_is_true_for_all (self ):
426
+ self .assertTrue (self ._manager .hasCapability (Manager .Capability .kStatefulContexts ))
427
+ self .assertTrue (self ._manager .hasCapability (Manager .Capability .kCustomTerminology ))
428
+ self .assertTrue (self ._manager .hasCapability (Manager .Capability .kDefaultEntityReferences ))
429
+ self .assertTrue (self ._manager .hasCapability (Manager .Capability .kResolution ))
430
+ self .assertTrue (self ._manager .hasCapability (Manager .Capability .kPublishing ))
431
+ self .assertTrue (self ._manager .hasCapability (Manager .Capability .kRelationshipQueries ))
432
+ self .assertTrue (self ._manager .hasCapability (Manager .Capability .kExistenceQueries ))
433
+
434
+
435
+ class Test_hasCapability_override_minimal (LibraryOverrideTestCase ):
436
+ _library = "library_business_logic_suite_capabilities_minimal.json"
437
+
438
+ def test_when_library_lists_minimal_capabilities_then_hasCapability_is_false_for_all (self ):
439
+ self .assertFalse (self ._manager .hasCapability (Manager .Capability .kStatefulContexts ))
440
+ self .assertFalse (self ._manager .hasCapability (Manager .Capability .kCustomTerminology ))
441
+ self .assertFalse (self ._manager .hasCapability (Manager .Capability .kDefaultEntityReferences ))
442
+ self .assertFalse (self ._manager .hasCapability (Manager .Capability .kResolution ))
443
+ self .assertFalse (self ._manager .hasCapability (Manager .Capability .kPublishing ))
444
+ self .assertFalse (self ._manager .hasCapability (Manager .Capability .kRelationshipQueries ))
445
+ self .assertFalse (self ._manager .hasCapability (Manager .Capability .kExistenceQueries ))
446
+
447
+ def test_when_capability_not_supported_then_methods_raise_NotImplementedException (self ):
448
+ context = self .createTestContext ()
449
+
450
+ with self .assertRaises (NotImplementedException ):
451
+ self ._manager .defaultEntityReference (
452
+ [],
453
+ DefaultEntityAccess .kRead ,
454
+ context ,
455
+ lambda * a : self .fail ("Unexpected success" ),
456
+ lambda * a : self .fail ("Unexpected element error" ),
457
+ )
458
+
459
+ with self .assertRaises (NotImplementedException ):
460
+ self ._manager .updateTerminology ({})
461
+
462
+ with self .assertRaises (NotImplementedException ):
463
+ self ._manager .resolve ([], set (), ResolveAccess .kRead , context )
464
+
465
+ with self .assertRaises (NotImplementedException ):
466
+ self ._manager .preflight ([], [], PublishingAccess .kWrite , context )
467
+
468
+ with self .assertRaises (NotImplementedException ):
469
+ self ._manager .register ([], [], PublishingAccess .kWrite , context )
470
+
471
+ with self .assertRaises (NotImplementedException ):
472
+ self ._manager .getWithRelationship (
473
+ [], TraitsData (), 1 , RelationsAccess .kRead , context , set ()
474
+ )
475
+
476
+ with self .assertRaises (NotImplementedException ):
477
+ self ._manager .getWithRelationships (
478
+ self ._manager .createEntityReference ("bal:///" ),
479
+ [],
480
+ 1 ,
481
+ RelationsAccess .kRead ,
482
+ context ,
483
+ set (),
484
+ )
485
+
486
+ with self .assertRaises (NotImplementedException ):
487
+ self ._manager .entityExists ([], context )
488
+
489
+
398
490
class Test_entityTraits (FixtureAugmentedTestCase ):
399
491
def test_when_missing_entity_queried_for_write_then_empty_trait_set_returned (self ):
400
492
# Missing entities are writable with unrestricted trait set.
0 commit comments