-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_manager.py
62 lines (47 loc) · 2.16 KB
/
test_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2023 The Foundry Visionmongers Ltd
"""
Test cases for MyAssetManager that make use of the OpenAssetIO
manager test harness.
Note that this file simply wraps the openassetio.test.manager harness in
a pytest test, so that it can be run as part of the project test suite.
It also serves as an example of how to programmatically execute the test
harness, by extending it with additional checks for MyAssetManagers
specific business logic.
It is not required in order to make use of the test harness. The base
API compliance tests can simply be run from a command line with
openassetio available, and the target plugin on
$OPENASSETIO_PLUGIN_PATH:
python -m openassetio.test.manager -f path/to/fixtures.py
"""
import os
import pytest
# pylint: disable=invalid-name,redefined-outer-name
# pylint: disable=missing-class-docstring,missing-function-docstring
from openassetio.test.manager import harness, apiComplianceSuite
from openassetio.pluginSystem import PythonPluginSystemManagerPlugin
#
# Tests
#
# MyAssetManager exposes an entry point, so can be pip installed without
# need to extend OPENASSETIO_PLUGIN_PATH.
# Tests should be invoked from an install
#
# python -m pip install .
# python -m pip install -r tests/requirements.txt
# python -m pytest tests
class Test_MyAssetManager:
def test_passes_apiComplianceSuite(self, harness_fixtures):
assert harness.executeSuite(apiComplianceSuite, harness_fixtures)
def test_passes_my_asset_manager_business_logic_suite(
self, my_asset_manager_business_logic_suite, harness_fixtures
):
assert harness.executeSuite(my_asset_manager_business_logic_suite, harness_fixtures)
class Test_MyAssetManager_Plugin: # pylint: disable=too-few-public-methods
def test_exposes_plugin_attribute_with_correct_type(self):
import my_asset_manager # pylint: disable=import-outside-toplevel
assert issubclass(my_asset_manager.plugin, PythonPluginSystemManagerPlugin)
@pytest.fixture
def my_asset_manager_business_logic_suite(base_dir):
module_path = os.path.join(base_dir, "tests", "business_logic_suite.py")
return harness.moduleFromFile(module_path)