Skip to content

Commit fb8456c

Browse files
authored
Merge pull request #116 from feltech/work/OpenAssetIO/1202-configurableIdentifier
Allow overriding of identifier
2 parents 79765b8 + 4040321 commit fb8456c

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

RELEASE_NOTES.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Release Notes
22
=============
33

4+
v1.0.0-alpha.x
5+
---------------
6+
7+
### New features
8+
9+
- Added support for `OPENASSETIO_BAL_IDENTIFIER` environment variable,
10+
for overriding the identifier advertised by the BAL plugin/manager.
11+
[#116](https://github.com/OpenAssetIO/OpenAssetIO-Manager-BAL/pull/116)
12+
413
v1.0.0-alpha.16
514
---------------
615

plugin/openassetio_manager_bal/BasicAssetLibraryInterface.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
"BasicAssetLibraryInterface",
5454
]
5555

56+
57+
DEFAULT_IDENTIFIER = "org.openassetio.examples.manager.bal"
58+
ENV_VAR_IDENTIFIER_OVERRIDE = "OPENASSETIO_BAL_IDENTIFIER"
5659
SETTINGS_KEY_LIBRARY_PATH = "library_path"
5760
SETTINGS_KEY_SIMULATED_QUERY_LATENCY = "simulated_query_latency_ms"
5861
SETTINGS_KEY_ENTITY_REFERENCE_URL_SCHEME = "entity_reference_url_scheme"
@@ -105,7 +108,7 @@ def __init__(self):
105108
self.__library = {}
106109

107110
def identifier(self):
108-
return "org.openassetio.examples.manager.bal"
111+
return os.environ.get(ENV_VAR_IDENTIFIER_OVERRIDE, DEFAULT_IDENTIFIER)
109112

110113
def displayName(self):
111114
# Deliberately includes unicode chars to test string handling

plugin/openassetio_manager_bal/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
need to be on `$PYTHONPATH` directly, the plugin system takes care
4343
of extending Python's runtime paths accordingly.
4444
"""
45+
import os
4546

4647
# pylint: disable=import-outside-toplevel, invalid-name
4748
#
@@ -51,6 +52,8 @@
5152
# PythonPluginSystemManagerPlugin's implementation.
5253
from openassetio.pluginSystem import PythonPluginSystemManagerPlugin
5354

55+
from .BasicAssetLibraryInterface import ENV_VAR_IDENTIFIER_OVERRIDE, DEFAULT_IDENTIFIER
56+
5457

5558
class BasicAssetLibraryPlugin(PythonPluginSystemManagerPlugin):
5659
"""
@@ -61,7 +64,7 @@ class BasicAssetLibraryPlugin(PythonPluginSystemManagerPlugin):
6164

6265
@staticmethod
6366
def identifier():
64-
return "org.openassetio.examples.manager.bal"
67+
return os.getenv(ENV_VAR_IDENTIFIER_OVERRIDE, DEFAULT_IDENTIFIER)
6568

6669
@classmethod
6770
def interface(cls):

tests/test_bal.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ def test_exposes_plugin_attribute_with_correct_type(self):
7474

7575
assert issubclass(openassetio_manager_bal.plugin, PythonPluginSystemManagerPlugin)
7676

77+
def test_when_not_overridden_by_env_var_then_identifier_matches_default(self):
78+
import openassetio_manager_bal # pylint: disable=import-outside-toplevel
79+
80+
assert (
81+
openassetio_manager_bal.plugin.identifier() == "org.openassetio.examples.manager.bal"
82+
)
83+
assert (
84+
openassetio_manager_bal.plugin.interface().identifier()
85+
== "org.openassetio.examples.manager.bal"
86+
)
87+
88+
def test_when_overridden_by_env_var_then_identifier_matches_env_var(self, monkeypatch):
89+
import openassetio_manager_bal # pylint: disable=import-outside-toplevel
90+
91+
monkeypatch.setenv("OPENASSETIO_BAL_IDENTIFIER", "foo")
92+
93+
assert openassetio_manager_bal.plugin.identifier() == "foo"
94+
assert openassetio_manager_bal.plugin.interface().identifier() == "foo"
95+
7796

7897
@pytest.fixture
7998
def bal_business_logic_suite(bal_base_dir):

0 commit comments

Comments
 (0)