OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system
FixtureAugmentedTestCase Class Reference

Base test case class that all test classes must inherit from. More...

Inheritance diagram for FixtureAugmentedTestCase:

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
 

Detailed Description

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.

Warning
The supplied locale should always be used for interactions with the manager under test, the createTestContext convenience method will create a new context pre-configured with this locale.

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.

Constructor & Destructor Documentation

def __init__ (   self,
  fixtures,
  manager,
  locale,
  args,
  kwargs 
)

Initializes an instance of this class.

Makes available _fixtures and _manager to subclasses.

Parameters
fixturesDict[Any, Any] Dictionary of fixtures specific to the current test case.
managerhostApi.Manager.Manager The OpenAssetIO manager to be used by test cases.
localeTraitsData The locale to use by test cases.
argsList[Any] Additional args passed along to the base class.
kwargsDict[str, Any] Additional keyword args passed along to the base class.

Member Function Documentation

def assertIsStringKeyPrimitiveValueDict (   self,
  dictionary 
)

Assert that given dictionary is str-keyed with all primitive values.

Parameters
dictionaryDict[Any, Any] Dictionary to check.
Exceptions
AssertionErrorOn 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.

Parameters
fixtureNamesList[str] The required keys in self._fixtures.
skipTestIfMissingbool When True, the test will be skipped instead of failing if one or more of the specificed fixtures are missing.
Returns
List[Any] The values corresponding to each requested fixtures

Member Data Documentation

bool shareManager = True
static

The documentation for this class was generated from the following file:
  • /src/src/openassetio-python/package/openassetio/test/manager/harness.py