OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system
|
Base test case class that all test classes must inherit from. More...
Public Member Functions | |
def | __init__ (self, fixtures, manager, locale, args, kwargs) |
Initializes an instance of this class. More... | |
def | createTestContext (self) |
A convenience method to create a context with the test locale, as provided by the test harness mechanism. More... | |
def | assertIsStringKeyPrimitiveValueDict (self, dictionary) |
Assert that given dictionary is str -keyed with all primitive values. More... | |
def | assertValuesOfType (self, valueList, valueType, allowNone=False) |
Asset that all values in the supplied list are of the desired type, or optionally None. More... | |
def | requireEntityReferencesFixture (self, fixtureName, skipTestIfMissing=False) |
A convenience companion to requireFixture, to construct an entity reference object around each raw string in a list fixture. More... | |
def | requireEntityReferenceFixture (self, fixtureName, skipTestIfMissing=False) |
A convenience companion to requireFixture, to construct an entity reference object around a raw string fixture. More... | |
def | requireFixtures (self, fixtureNames, skipTestIfMissing=False) |
Ensures that the supplied fixtures names are available for a test and returns their values. More... | |
def | collectRequiredFixtures (self, fixtureNames, skipTestIfMissing=False) |
Performs the same checks as requireFixtures, but stores the fixture values on self under variables of the same name. More... | |
def | requireFixture (self, fixtureName, skipTestIfMissing=False) |
A convenience companion to requireFixtures, when only a single fixture is needed. More... | |
def | collectRequiredFixture (self, fixtureName, skipTestIfMissing=False) |
A convenience companion to collectRequiredFixtures, when only a single fixture is needed. More... | |
Static Public Attributes | |
bool | shareManager = True |
Base test case class that all test classes must inherit from.
Expects test harness fixtures and an OpenAssetIO manager to be provided, hence requires that unittest
is provided with the custom ValidatorTestLoader test case loader.
Fixtures, manager and a suitable locale are then provided to subclasses via protected members.
For performance reasons, by default, all test cases will share a single instance of the manager under test. This reduces setup costs, but precludes any testing of initialization behaviour.
If the class variable shareManager
is set to False for any given suite, the harness will instead create a new, uninitializesd manager for each case.
def __init__ | ( | self, | |
fixtures, | |||
manager, | |||
locale, | |||
args, | |||
kwargs | |||
) |
Initializes an instance of this class.
Makes available _fixtures
and _manager
to subclasses.
fixtures | Dict[Any, Any] Dictionary of fixtures specific to the current test case. |
manager | hostApi.Manager.Manager The OpenAssetIO manager to be used by test cases. |
locale | TraitsData The locale to use by test cases. |
args | List[Any] Additional args passed along to the base class. |
kwargs | Dict[str, Any] Additional keyword args passed along to the base class. |
def assertIsStringKeyPrimitiveValueDict | ( | self, | |
dictionary | |||
) |
Assert that given dictionary
is str
-keyed with all primitive values.
dictionary | Dict[Any, Any] Dictionary to check. |
AssertionError | On failure. |
def assertValuesOfType | ( | self, | |
valueList, | |||
valueType, | |||
allowNone = False |
|||
) |
Asset that all values in the supplied list are of the desired type, or optionally None.
An empty list will not fail the check.
@param valueList `List[Any]` The list of values to check. @param valueType `Type` The expected value type, as compatible with `isinstance`. @param allowNone `bool` When True, one or more elements of the list may also be `None`. @exception AssertionError if any of the supplied values are not of the excpected type.
def collectRequiredFixture | ( | self, | |
fixtureName, | |||
skipTestIfMissing = False |
|||
) |
A convenience companion to collectRequiredFixtures, when only a single fixture is needed.
def collectRequiredFixtures | ( | self, | |
fixtureNames, | |||
skipTestIfMissing = False |
|||
) |
Performs the same checks as requireFixtures, but stores the fixture values on self under variables of the same name.
This method is best suited to use in setUp where you wish to skip/fail a whole bunch of tests when fixtures are missing.
def createTestContext | ( | self | ) |
A convenience method to create a context with the test locale, as provided by the test harness mechanism.
def requireEntityReferenceFixture | ( | self, | |
fixtureName, | |||
skipTestIfMissing = False |
|||
) |
A convenience companion to requireFixture, to construct an entity reference object around a raw string fixture.
def requireEntityReferencesFixture | ( | self, | |
fixtureName, | |||
skipTestIfMissing = False |
|||
) |
A convenience companion to requireFixture, to construct an entity reference object around each raw string in a list fixture.
def requireFixture | ( | self, | |
fixtureName, | |||
skipTestIfMissing = False |
|||
) |
A convenience companion to requireFixtures, when only a single fixture is needed.
def requireFixtures | ( | self, | |
fixtureNames, | |||
skipTestIfMissing = False |
|||
) |
Ensures that the supplied fixtures names are available for a test and returns their values.
If any of the named fixtures are missing, the test will be failed or skipped accordingly and test execution aborted. A suitable message is generated by the function to inform observers of the test run as to which fixtures are missing.
fixtureNames | List[str] The required keys in self._fixtures. |
skipTestIfMissing | bool When True, the test will be skipped instead of failing if one or more of the specificed fixtures are missing. |
List[Any]
The values corresponding to each requested fixtures
|
static |
Copyright 2013-2023 The Foundry Visionmongers Ltd. OpenAssetIO is released under the Apache 2.0 License