Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding of identifier #116

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading