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

Track linked extensions in extension manager #275

Merged
merged 1 commit into from
Aug 18, 2020
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
8 changes: 8 additions & 0 deletions jupyter_server/extension/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ def extension_points(self):
for name, point in value.extension_points.items()
}

@property
def linked_extensions(self):
"""Dictionary with extension names as keys; values are
True if the extension is linked, False if not."""
return self._linked_extensions

def from_config_manager(self, config_manager):
"""Add extensions found by an ExtensionConfigManager"""
self._config_manager = config_manager
Expand All @@ -281,7 +287,9 @@ def link_extension(self, name, serverapp):
extension = self.extensions[name]
if not linked and extension.enabled:
try:
# Link extension and store links
extension.link_all_points(serverapp)
self._linked_extensions[name] = True
self.log.info("{name} | extension was successfully linked.".format(name=name))
except Exception as e:
self.log.warning(e)
Expand Down
7 changes: 7 additions & 0 deletions tests/extension/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@ def test_extension_manager_api():
assert len(manager.extensions) == 1
assert "tests.extension.mockextensions" in manager.extensions


def test_extension_manager_linked_extensions(serverapp):
name = "tests.extension.mockextensions"
manager = ExtensionManager()
manager.add_extension(name, enabled=True)
manager.link_extension(name, serverapp)
assert name in manager.linked_extensions