Skip to content

Commit 40bdfbb

Browse files
fix: event entrypoint incorrectly pointed to request type registry
* There was a copypaste mistake in ext - event type entrypoints were loaded into the request type registry * The fix replaces it with the correct registry and adds tests that demonstrate that correct registries are filled by entrypoints
1 parent eee5a89 commit 40bdfbb

File tree

5 files changed

+97
-1
lines changed

5 files changed

+97
-1
lines changed

invenio_requests/ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def init_registry(self, app):
108108
register_entry_point(
109109
self.request_type_registry, "invenio_requests.types", app=app
110110
)
111-
register_entry_point(self.request_type_registry, "invenio_requests.event_types")
111+
register_entry_point(self.event_type_registry, "invenio_requests.event_types")
112112
register_entry_point(
113113
self.entity_resolvers_registry, "invenio_requests.entity_resolvers"
114114
)

tests/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2025 CERN.
4+
#
5+
# Invenio-Requests is free software; you can redistribute it and/or modify it
6+
# under the terms of the MIT License; see LICENSE file for more details.
7+
8+
"""Tests."""

tests/mock_module/__init__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2025 CERN.
4+
#
5+
# Invenio-Requests is free software; you can redistribute it and/or modify it
6+
# under the terms of the MIT License; see LICENSE file for more details.
7+
8+
"""Mock module for registry tests."""
9+
10+
from invenio_users_resources.entity_resolvers import UserResolver
11+
12+
from invenio_requests.customizations import EventType, RequestType
13+
14+
15+
class MockRequestType(RequestType):
16+
"""Mock request type."""
17+
18+
type_id = "mock"
19+
20+
21+
class MockEventType(EventType):
22+
"""Mock event type."""
23+
24+
type_id = "M"
25+
26+
27+
class MockResolver(UserResolver):
28+
"""Mock entity resolver."""
29+
30+
type_id = "mock"

tests/registry/conftest.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2025 CERN.
4+
#
5+
# Invenio-Requests is free software; you can redistribute it and/or modify it
6+
# under the terms of the MIT License; see LICENSE file for more details.
7+
8+
"""App fixture with test entrypoints."""
9+
10+
import pytest
11+
from invenio_app.factory import create_api
12+
13+
14+
@pytest.fixture(scope="module")
15+
def create_app(instance_path, entry_points):
16+
"""Application factory fixture."""
17+
return create_api
18+
19+
20+
@pytest.fixture(scope="module")
21+
def extra_entry_points():
22+
"""Extra entry points to load the mock_module features."""
23+
return {
24+
"invenio_requests.types": [
25+
"mock_module = tests.mock_module:MockRequestType",
26+
],
27+
"invenio_requests.event_types": [
28+
"mock_module = tests.mock_module:MockEventType",
29+
],
30+
"invenio_requests.entity_resolvers": [
31+
"mock_module = tests.mock_module:MockResolver",
32+
],
33+
}

tests/registry/test_registries.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2025 CERN.
4+
#
5+
# Invenio-Requests is free software; you can redistribute it and/or modify it
6+
# under the terms of the MIT License; see LICENSE file for more details.
7+
8+
"""Test for entrypoint loading."""
9+
10+
from tests.mock_module import MockEventType, MockRequestType, MockResolver
11+
12+
13+
def test_request_type_registry_entrypoints(app):
14+
registry = app.extensions["invenio-requests"].request_type_registry
15+
assert isinstance(registry.lookup("mock"), MockRequestType)
16+
17+
18+
def test_event_type_registry_entrypoints(app):
19+
registry = app.extensions["invenio-requests"].event_type_registry
20+
assert isinstance(registry.lookup("M"), MockEventType)
21+
22+
23+
def test_entity_resolvers_registry_entrypoints(app):
24+
registry = app.extensions["invenio-requests"].entity_resolvers_registry
25+
assert isinstance(registry.lookup("mock"), MockResolver)

0 commit comments

Comments
 (0)