Skip to content

Commit

Permalink
Merge pull request #116 from feltech/work/OpenAssetIO/1202-configurab…
Browse files Browse the repository at this point in the history
…leIdentifier

Allow overriding of identifier
  • Loading branch information
feltech authored Jul 18, 2024
2 parents 79765b8 + 4040321 commit fb8456c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
9 changes: 9 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
Release Notes
=============

v1.0.0-alpha.x
---------------

### New features

- Added support for `OPENASSETIO_BAL_IDENTIFIER` environment variable,
for overriding the identifier advertised by the BAL plugin/manager.
[#116](https://github.com/OpenAssetIO/OpenAssetIO-Manager-BAL/pull/116)

v1.0.0-alpha.16
---------------

Expand Down
5 changes: 4 additions & 1 deletion plugin/openassetio_manager_bal/BasicAssetLibraryInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"BasicAssetLibraryInterface",
]


DEFAULT_IDENTIFIER = "org.openassetio.examples.manager.bal"
ENV_VAR_IDENTIFIER_OVERRIDE = "OPENASSETIO_BAL_IDENTIFIER"
SETTINGS_KEY_LIBRARY_PATH = "library_path"
SETTINGS_KEY_SIMULATED_QUERY_LATENCY = "simulated_query_latency_ms"
SETTINGS_KEY_ENTITY_REFERENCE_URL_SCHEME = "entity_reference_url_scheme"
Expand Down Expand Up @@ -105,7 +108,7 @@ def __init__(self):
self.__library = {}

def identifier(self):
return "org.openassetio.examples.manager.bal"
return os.environ.get(ENV_VAR_IDENTIFIER_OVERRIDE, DEFAULT_IDENTIFIER)

def displayName(self):
# Deliberately includes unicode chars to test string handling
Expand Down
5 changes: 4 additions & 1 deletion plugin/openassetio_manager_bal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
need to be on `$PYTHONPATH` directly, the plugin system takes care
of extending Python's runtime paths accordingly.
"""
import os

# pylint: disable=import-outside-toplevel, invalid-name
#
Expand All @@ -51,6 +52,8 @@
# PythonPluginSystemManagerPlugin's implementation.
from openassetio.pluginSystem import PythonPluginSystemManagerPlugin

from .BasicAssetLibraryInterface import ENV_VAR_IDENTIFIER_OVERRIDE, DEFAULT_IDENTIFIER


class BasicAssetLibraryPlugin(PythonPluginSystemManagerPlugin):
"""
Expand All @@ -61,7 +64,7 @@ class BasicAssetLibraryPlugin(PythonPluginSystemManagerPlugin):

@staticmethod
def identifier():
return "org.openassetio.examples.manager.bal"
return os.getenv(ENV_VAR_IDENTIFIER_OVERRIDE, DEFAULT_IDENTIFIER)

@classmethod
def interface(cls):
Expand Down
19 changes: 19 additions & 0 deletions tests/test_bal.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ def test_exposes_plugin_attribute_with_correct_type(self):

assert issubclass(openassetio_manager_bal.plugin, PythonPluginSystemManagerPlugin)

def test_when_not_overridden_by_env_var_then_identifier_matches_default(self):
import openassetio_manager_bal # pylint: disable=import-outside-toplevel

assert (
openassetio_manager_bal.plugin.identifier() == "org.openassetio.examples.manager.bal"
)
assert (
openassetio_manager_bal.plugin.interface().identifier()
== "org.openassetio.examples.manager.bal"
)

def test_when_overridden_by_env_var_then_identifier_matches_env_var(self, monkeypatch):
import openassetio_manager_bal # pylint: disable=import-outside-toplevel

monkeypatch.setenv("OPENASSETIO_BAL_IDENTIFIER", "foo")

assert openassetio_manager_bal.plugin.identifier() == "foo"
assert openassetio_manager_bal.plugin.interface().identifier() == "foo"


@pytest.fixture
def bal_business_logic_suite(bal_base_dir):
Expand Down

0 comments on commit fb8456c

Please sign in to comment.