Skip to content

Commit

Permalink
Merge pull request jupyter-server#275 from Zsailer/linked-extensions
Browse files Browse the repository at this point in the history
Track linked extensions in extension manager
  • Loading branch information
blink1073 authored Aug 18, 2020
2 parents c732757 + 35f02c1 commit 4af0115
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit 4af0115

Please sign in to comment.