Skip to content
Open
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
2 changes: 1 addition & 1 deletion invenio_app_rdm/records_ui/views/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ def namespace_url(field):
"""Get custom field namespace url."""
namespace_array = field.split(":")
namespace = namespace_array[0]
namespace_value = namespace_array[1]
namespaces = current_app.config.get("RDM_NAMESPACES")

if not namespaces.get(namespace):
return None

namespace_value = namespace_array[1]
return namespaces[namespace] + namespace_value


Expand Down
4 changes: 4 additions & 0 deletions tests/ui/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def load(self, filepath):
def app_config(app_config):
"""Create test app."""
app_config["WEBPACKEXT_MANIFEST_LOADER"] = MockManifestLoader
app_config["RDM_NAMESPACES"] = {
"test": "https://example.com/terms/#",
"empty": None,
}
return app_config


Expand Down
9 changes: 8 additions & 1 deletion tests/ui/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from invenio_app_rdm.records_ui.views.filters import get_scheme_label
from invenio_app_rdm.records_ui.views.filters import get_scheme_label, namespace_url


def test_get_scheme_label(app):
Expand All @@ -8,3 +8,10 @@ def test_get_scheme_label(app):
assert "arXiv" == get_scheme_label("arxiv")

assert "Bibcode" == get_scheme_label("ads")


def test_namespace_url(app):
"""Test namespace URL filters."""
assert namespace_url("no_namespaced_field") is None
assert namespace_url("empty:field_name") is None
assert namespace_url("test:field_name") == "https://example.com/terms/#field_name"
Loading