From 0ae2f53c7c371b85f46034683baf7e84fa7764aa Mon Sep 17 00:00:00 2001 From: Zsailer Date: Mon, 17 Aug 2020 16:25:47 -0700 Subject: [PATCH] track linked-extensions in extension manager --- jupyter_server/extension/manager.py | 8 ++++++++ tests/extension/test_manager.py | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/jupyter_server/extension/manager.py b/jupyter_server/extension/manager.py index 586cb39f5d..111e60d7af 100644 --- a/jupyter_server/extension/manager.py +++ b/jupyter_server/extension/manager.py @@ -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 @@ -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) diff --git a/tests/extension/test_manager.py b/tests/extension/test_manager.py index b076c43f25..6e7eaabf2f 100644 --- a/tests/extension/test_manager.py +++ b/tests/extension/test_manager.py @@ -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