diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index dcb3e7d..039be0f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,14 @@ 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. + v1.0.0-alpha.16 --------------- diff --git a/plugin/openassetio_manager_bal/BasicAssetLibraryInterface.py b/plugin/openassetio_manager_bal/BasicAssetLibraryInterface.py index 7ceda15..3d7fe4d 100644 --- a/plugin/openassetio_manager_bal/BasicAssetLibraryInterface.py +++ b/plugin/openassetio_manager_bal/BasicAssetLibraryInterface.py @@ -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" @@ -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 diff --git a/plugin/openassetio_manager_bal/__init__.py b/plugin/openassetio_manager_bal/__init__.py index a9912c9..dd63944 100644 --- a/plugin/openassetio_manager_bal/__init__.py +++ b/plugin/openassetio_manager_bal/__init__.py @@ -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 # @@ -51,6 +52,8 @@ # PythonPluginSystemManagerPlugin's implementation. from openassetio.pluginSystem import PythonPluginSystemManagerPlugin +from .BasicAssetLibraryInterface import ENV_VAR_IDENTIFIER_OVERRIDE, DEFAULT_IDENTIFIER + class BasicAssetLibraryPlugin(PythonPluginSystemManagerPlugin): """ @@ -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): diff --git a/tests/test_bal.py b/tests/test_bal.py index f31993c..67a745f 100644 --- a/tests/test_bal.py +++ b/tests/test_bal.py @@ -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):