def test_app_dir(self): app_dir = self.tempdir() install_extension(self.mock_extension, app_dir) path = pjoin(app_dir, 'extensions', '*.tgz') assert glob.glob(path) extensions = get_app_info(app_dir)['extensions'] ext_name = self.pkg_names['extension'] assert ext_name in extensions assert check_extension(ext_name, app_dir) uninstall_extension(self.pkg_names['extension'], app_dir) path = pjoin(app_dir, 'extensions', '*.tgz') assert not glob.glob(path) extensions = get_app_info(app_dir)['extensions'] assert ext_name not in extensions assert not check_extension(ext_name, app_dir) link_package(self.mock_package, app_dir) linked = get_app_info(app_dir)['linked_packages'] pkg_name = self.pkg_names['package'] assert pkg_name in linked assert check_extension(pkg_name, app_dir) unlink_package(self.mock_package, app_dir) linked = get_app_info(app_dir)['linked_packages'] assert pkg_name not in linked assert not check_extension(pkg_name, app_dir)
def test_app_dir(self): app_dir = self.tempdir() install_extension(self.mock_extension, app_dir) path = pjoin(app_dir, 'extensions', '*.tgz') assert glob.glob(path) extensions = get_app_info(app_dir)['extensions'] ext_name = self.pkg_names['extension'] assert ext_name in extensions assert check_extension(ext_name, app_dir) uninstall_extension(self.pkg_names['extension'], app_dir) path = pjoin(app_dir, 'extensions', '*.tgz') assert not glob.glob(path) extensions = get_app_info(app_dir)['extensions'] assert ext_name not in extensions assert not check_extension(ext_name, app_dir) link_package(self.mock_package, app_dir) linked = get_app_info(app_dir)['linked_packages'] pkg_name = self.pkg_names['package'] assert pkg_name in linked assert check_extension(pkg_name, app_dir) unlink_package(self.mock_package, app_dir) linked = get_app_info(app_dir)['linked_packages'] assert pkg_name not in linked assert not check_extension(pkg_name, app_dir)
def test_install_mime_renderer(self): install_extension(self.mock_mimeextension) name = self.pkg_names['mimeextension'] assert name in get_app_info(self.app_dir)['extensions'] uninstall_extension(name) assert name not in get_app_info(self.app_dir)['extensions']
def test_uninstall_extension(self): install_extension(self.mock_extension) uninstall_extension(self.pkg_names['extension']) path = pjoin(self.app_dir, 'extensions', '*.tgz') assert not glob.glob(path) extensions = get_app_info(self.app_dir)['extensions'] assert self.pkg_names['extension'] not in extensions
def test_app_dir_shadowing(self): app_dir = self.tempdir() sys_dir = self.app_dir if os.path.exists(sys_dir): os.removedirs(sys_dir) assert install_extension(self.mock_extension) is True sys_path = pjoin(sys_dir, 'extensions', '*.tgz') assert glob.glob(sys_path) app_path = pjoin(app_dir, 'extensions', '*.tgz') assert not glob.glob(app_path) extensions = get_app_info(app_dir)['extensions'] ext_name = self.pkg_names['extension'] assert ext_name in extensions assert check_extension(ext_name, app_dir) assert install_extension(self.mock_extension, app_dir) is True assert glob.glob(app_path) extensions = get_app_info(app_dir)['extensions'] assert ext_name in extensions assert check_extension(ext_name, app_dir) assert uninstall_extension(self.pkg_names['extension'], app_dir) is True assert not glob.glob(app_path) assert glob.glob(sys_path) extensions = get_app_info(app_dir)['extensions'] assert ext_name in extensions assert check_extension(ext_name, app_dir) assert uninstall_extension(self.pkg_names['extension'], app_dir) is True assert not glob.glob(app_path) assert not glob.glob(sys_path) extensions = get_app_info(app_dir)['extensions'] assert ext_name not in extensions assert not check_extension(ext_name, app_dir)
def test_app_dir_shadowing(self): app_dir = self.tempdir() sys_dir = self.app_dir if os.path.exists(sys_dir): os.removedirs(sys_dir) install_extension(self.mock_extension) sys_path = pjoin(sys_dir, 'extensions', '*.tgz') assert glob.glob(sys_path) app_path = pjoin(app_dir, 'extensions', '*.tgz') assert not glob.glob(app_path) extensions = get_app_info(app_dir)['extensions'] assert self.pkg_names['extension'] in extensions install_extension(self.mock_extension, app_dir) assert glob.glob(app_path) extensions = get_app_info(app_dir)['extensions'] assert self.pkg_names['extension'] in extensions uninstall_extension(self.pkg_names['extension'], app_dir) assert not glob.glob(app_path) assert glob.glob(sys_path) extensions = get_app_info(app_dir)['extensions'] assert self.pkg_names['extension'] in extensions uninstall_extension(self.pkg_names['extension'], app_dir) assert not glob.glob(app_path) assert not glob.glob(sys_path) extensions = get_app_info(app_dir)['extensions'] assert self.pkg_names['extension'] not in extensions
def test_app_dir_shadowing(self): app_dir = self.tempdir() sys_dir = self.app_dir if os.path.exists(sys_dir): os.removedirs(sys_dir) install_extension(self.source_dir) sys_path = pjoin(sys_dir, 'extensions', '*python-tests*.tgz') assert glob.glob(sys_path) app_path = pjoin(app_dir, 'extensions', '*python-tests*.tgz') assert not glob.glob(app_path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) install_extension(self.source_dir, app_dir) assert glob.glob(app_path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) uninstall_extension('@jupyterlab/python-tests', app_dir) assert not glob.glob(app_path) assert glob.glob(sys_path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) uninstall_extension('@jupyterlab/python-tests', app_dir) assert not glob.glob(app_path) assert not glob.glob(sys_path) assert '@jupyterlab/python-tests' not in _get_extensions(app_dir)
def test_app_dir_shadowing(self): app_dir = self.tempdir() sys_dir = self.app_dir if os.path.exists(sys_dir): os.removedirs(sys_dir) install_extension(self.source_dir) sys_path = pjoin(sys_dir, 'extensions', '*python-tests*.tgz') assert glob.glob(sys_path) app_path = pjoin(app_dir, 'extensions', '*python-tests*.tgz') assert not glob.glob(app_path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) install_extension(self.source_dir, app_dir) assert glob.glob(app_path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) uninstall_extension('@jupyterlab/python-tests', app_dir) assert not glob.glob(app_path) assert glob.glob(sys_path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) uninstall_extension('@jupyterlab/python-tests', app_dir) assert not glob.glob(app_path) assert not glob.glob(sys_path) assert '@jupyterlab/python-tests' not in _get_extensions(app_dir)
def test_uninstall_core_extension(self): uninstall_extension('@jupyterlab/console-extension') app_dir = get_app_dir() _ensure_package(app_dir) with open(pjoin(app_dir, 'staging', 'package.json')) as fid: data = json.load(fid) extensions = data['jupyterlab']['extensions'] assert '@jupyterlab/console-extension' not in extensions
def test_should_build(self): assert not should_build()[0] install_extension(self.source_dir) assert should_build()[0] build() assert not should_build()[0] uninstall_extension('@jupyterlab/python-tests') assert should_build()[0]
def test_uninstall_core_extension(self): uninstall_extension('@jupyterlab/console-extension') app_dir = get_app_dir() _ensure_package(app_dir) with open(pjoin(app_dir, 'staging', 'package.json')) as fid: data = json.load(fid) extensions = data['jupyterlab']['extensions'] assert '@jupyterlab/console-extension' not in extensions
def test_should_build(self): assert not should_build()[0] install_extension(self.source_dir) assert should_build()[0] build() assert not should_build()[0] uninstall_extension('@jupyterlab/python-tests') assert should_build()[0]
def test_install_mime_renderer(self): install_extension(self.mock_mimeextension) assert '@jupyterlab/mime-extension-test' in _get_extensions( self.app_dir) uninstall_extension('@jupyterlab/mime-extension-test') assert '@jupyterlab/mime-extension-test' not in _get_extensions( self.app_dir)
def test_install_mime_renderer(self): install_extension(self.mock_mimeextension) name = self.pkg_names['mimeextension'] assert name in get_app_info(self.app_dir)['extensions'] assert check_extension(name) uninstall_extension(name) assert name not in get_app_info(self.app_dir)['extensions'] assert not check_extension(name)
def test_uninstall_extension(self): install_extension(self.mock_extension) name = self.pkg_names['extension'] assert check_extension(name) uninstall_extension(self.pkg_names['extension']) path = pjoin(self.app_dir, 'extensions', '*.tgz') assert not glob.glob(path) extensions = get_app_info(self.app_dir)['extensions'] assert name not in extensions assert not check_extension(name)
def test_app_dir(self): app_dir = self.tempdir() options = AppOptions(app_dir=app_dir) assert install_extension(self.mock_extension, app_options=options) is True path = pjoin(app_dir, "extensions", "*.tgz") assert glob.glob(path) extensions = get_app_info(app_options=options)["extensions"] ext_name = self.pkg_names["extension"] assert ext_name in extensions assert check_extension(ext_name, app_options=options) assert uninstall_extension(self.pkg_names["extension"], app_options=options) is True path = pjoin(app_dir, "extensions", "*.tgz") assert not glob.glob(path) extensions = get_app_info(app_options=options)["extensions"] assert ext_name not in extensions assert not check_extension(ext_name, app_options=options) assert link_package(self.mock_package, app_options=options) is True linked = get_app_info(app_options=options)["linked_packages"] pkg_name = self.pkg_names["package"] assert pkg_name in linked assert check_extension(pkg_name, app_options=options) assert unlink_package(self.mock_package, app_options=options) is True linked = get_app_info(app_options=options)["linked_packages"] assert pkg_name not in linked assert not check_extension(pkg_name, app_options=options)
def test_uninstall_core_extension(self): uninstall_extension('@jupyterlab/console-extension') app_dir = self.app_dir build(app_dir) with open(pjoin(app_dir, 'staging', 'package.json')) as fid: data = json.load(fid) extensions = data['jupyterlab']['extensions'] assert '@jupyterlab/console-extension' not in extensions assert not check_extension('@jupyterlab/console-extension') install_extension('@jupyterlab/console-extension') build(app_dir) with open(pjoin(app_dir, 'staging', 'package.json')) as fid: data = json.load(fid) extensions = data['jupyterlab']['extensions'] assert '@jupyterlab/console-extension' in extensions assert check_extension('@jupyterlab/console-extension')
def test_uninstall_core_extension(self): uninstall_extension('@jupyterlab/console-extension') app_dir = self.app_dir build(app_dir) with open(pjoin(app_dir, 'staging', 'package.json')) as fid: data = json.load(fid) extensions = data['jupyterlab']['extensions'] assert '@jupyterlab/console-extension' not in extensions assert not check_extension('@jupyterlab/console-extension') install_extension('@jupyterlab/console-extension') build(app_dir) with open(pjoin(app_dir, 'staging', 'package.json')) as fid: data = json.load(fid) extensions = data['jupyterlab']['extensions'] assert '@jupyterlab/console-extension' in extensions assert check_extension('@jupyterlab/console-extension')
def test_build_check(self): # Do the initial build. assert build_check()[0] link_package(self.mock_extension) link_package(self.mock_package) build() assert not build_check()[0] # Check installed extensions. install_extension(self.mock_mimeextension) assert build_check()[0] uninstall_extension('@jupyterlab/mime-extension-test') assert not build_check()[0] # Check linked extensions. pkg_path = pjoin(self.mock_extension, 'package.json') with open(pkg_path) as fid: data = json.load(fid) with open(pkg_path, 'rb') as fid: orig = fid.read() data['foo'] = 'bar' with open(pkg_path, 'w') as fid: json.dump(data, fid) assert build_check()[0] assert build_check()[0] with open(pkg_path, 'wb') as fid: fid.write(orig) assert not build_check()[0] # Check linked packages. pkg_path = pjoin(self.mock_package, 'package.json') with open(pkg_path) as fid: data = json.load(fid) with open(pkg_path, 'rb') as fid: orig = fid.read() data['foo'] = 'bar' with open(pkg_path, 'w') as fid: json.dump(data, fid) assert build_check()[0] assert build_check()[0] with open(pkg_path, 'wb') as fid: fid.write(orig) assert not build_check()[0]
def test_install_mime_renderer(self): install_extension(self.mock_mimeextension) name = self.pkg_names['mimeextension'] assert name in get_app_info()['extensions'] assert check_extension(name) assert uninstall_extension(name) is True assert name not in get_app_info()['extensions'] assert not check_extension(name)
def test_build_check(self): # Do the initial build. assert build_check() install_extension(self.mock_extension) link_package(self.mock_package) build() assert not build_check() # Check installed extensions. install_extension(self.mock_mimeextension) assert build_check() uninstall_extension(self.pkg_names['mimeextension']) assert not build_check() # Check local extensions. pkg_path = pjoin(self.mock_extension, 'package.json') with open(pkg_path) as fid: data = json.load(fid) with open(pkg_path, 'rb') as fid: orig = fid.read() data['foo'] = 'bar' with open(pkg_path, 'w') as fid: json.dump(data, fid) assert build_check() assert build_check() with open(pkg_path, 'wb') as fid: fid.write(orig) assert not build_check() # Check linked packages. pkg_path = pjoin(self.mock_package, 'index.js') with open(pkg_path, 'rb') as fid: orig = fid.read() with open(pkg_path, 'wb') as fid: fid.write(orig + b'\nconsole.log("hello");') assert build_check() assert build_check() with open(pkg_path, 'wb') as fid: fid.write(orig) assert not build_check()
def test_build_check(self): # Do the initial build. assert build_check() install_extension(self.mock_extension) link_package(self.mock_package) build() assert not build_check() # Check installed extensions. install_extension(self.mock_mimeextension) assert build_check() uninstall_extension(self.pkg_names['mimeextension']) assert not build_check() # Check local extensions. pkg_path = pjoin(self.mock_extension, 'package.json') with open(pkg_path) as fid: data = json.load(fid) with open(pkg_path, 'rb') as fid: orig = fid.read() data['foo'] = 'bar' with open(pkg_path, 'w') as fid: json.dump(data, fid) assert build_check() assert build_check() with open(pkg_path, 'wb') as fid: fid.write(orig) assert not build_check() # Check linked packages. pkg_path = pjoin(self.mock_package, 'index.js') with open(pkg_path, 'rb') as fid: orig = fid.read() with open(pkg_path, 'wb') as fid: fid.write(orig + b'\nconsole.log("hello");') assert build_check() assert build_check() with open(pkg_path, 'wb') as fid: fid.write(orig) assert not build_check()
def test_uninstall_extension(self): assert install_extension(self.mock_extension) is True name = self.pkg_names["extension"] assert check_extension(name) assert uninstall_extension(self.pkg_names["extension"]) is True path = pjoin(self.app_dir, "extensions", "*.tgz") assert not glob.glob(path) extensions = get_app_info()["extensions"] assert name not in extensions assert not check_extension(name)
def test_uninstall_extension(self): assert install_extension(self.mock_extension) is True name = self.pkg_names['extension'] assert check_extension(name) assert uninstall_extension(self.pkg_names['extension']) is True path = pjoin(self.app_dir, 'extensions', '*.tgz') assert not glob.glob(path) extensions = get_app_info()['extensions'] assert name not in extensions assert not check_extension(name)
def test_uninstall_all_extensions(self): install_extension(self.mock_extension) install_extension(self.mock_mimeextension) ext_name = self.pkg_names['extension'] mime_ext_name = self.pkg_names['mimeextension'] assert check_extension(ext_name) is True assert check_extension(mime_ext_name) is True assert uninstall_extension(all_=True) is True extensions = get_app_info(self.app_dir)['extensions'] assert ext_name not in extensions assert mime_ext_name not in extensions
def test_app_dir(self): app_dir = self.tempdir() install_extension(self.source_dir, app_dir) path = pjoin(app_dir, 'extensions', '*python-tests*.tgz') assert glob.glob(path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) uninstall_extension('@jupyterlab/python-tests', app_dir) path = pjoin(app_dir, 'extensions', '*python-tests*.tgz') assert not glob.glob(path) assert '@jupyterlab/python-tests' not in _get_extensions(app_dir) link_package(self.source_dir, app_dir) linked = _get_linked_packages(app_dir).keys() assert '@jupyterlab/python-tests' in linked unlink_package(self.source_dir, app_dir) linked = _get_linked_packages(app_dir).keys() assert '@jupyterlab/python-tests' not in linked
def test_uninstall_all_extensions(self): install_extension(self.mock_extension) install_extension(self.mock_mimeextension) ext_name = self.pkg_names['extension'] mime_ext_name = self.pkg_names['mimeextension'] assert check_extension(ext_name) is True assert check_extension(mime_ext_name) is True assert uninstall_extension(all_=True) is True extensions = get_app_info()['extensions'] assert ext_name not in extensions assert mime_ext_name not in extensions
def test_app_dir(self): app_dir = self.tempdir() install_extension(self.source_dir, app_dir) path = pjoin(app_dir, 'extensions', '*python-tests*.tgz') assert glob.glob(path) assert '@jupyterlab/python-tests' in _get_extensions(app_dir) uninstall_extension('@jupyterlab/python-tests', app_dir) path = pjoin(app_dir, 'extensions', '*python-tests*.tgz') assert not glob.glob(path) assert '@jupyterlab/python-tests' not in _get_extensions(app_dir) link_package(self.source_dir, app_dir) linked = _get_linked_packages(app_dir).keys() assert '@jupyterlab/python-tests' in linked unlink_package(self.source_dir, app_dir) linked = _get_linked_packages(app_dir).keys() assert '@jupyterlab/python-tests' not in linked
def test_app_dir_shadowing(self): app_dir = self.tempdir() sys_dir = self.app_dir app_options = AppOptions(app_dir=app_dir) if os.path.exists(sys_dir): os.removedirs(sys_dir) assert install_extension(self.mock_extension) is True sys_path = pjoin(sys_dir, 'extensions', '*.tgz') assert glob.glob(sys_path) app_path = pjoin(app_dir, 'extensions', '*.tgz') assert not glob.glob(app_path) extensions = get_app_info(app_options=app_options)['extensions'] ext_name = self.pkg_names['extension'] assert ext_name in extensions assert check_extension(ext_name, app_options=app_options) assert install_extension(self.mock_extension, app_options=app_options) is True assert glob.glob(app_path) extensions = get_app_info(app_options=app_options)['extensions'] assert ext_name in extensions assert check_extension(ext_name, app_options=app_options) assert uninstall_extension(self.pkg_names['extension'], app_options=app_options) is True assert not glob.glob(app_path) assert glob.glob(sys_path) extensions = get_app_info(app_options=app_options)['extensions'] assert ext_name in extensions assert check_extension(ext_name, app_options=app_options) assert uninstall_extension(self.pkg_names['extension'], app_options=app_options) is True assert not glob.glob(app_path) assert not glob.glob(sys_path) extensions = get_app_info(app_options=app_options)['extensions'] assert ext_name not in extensions assert not check_extension(ext_name, app_options=app_options)
def test_install_and_uninstall_pinned(self): """ You should be able to install different versions of the same extension with different pinned names and uninstall them with those names. """ NAMES = ['test-1', 'test-2'] assert install_extension(self.pinned_packages[0], pin=NAMES[0]) assert install_extension(self.pinned_packages[1], pin=NAMES[1]) extensions = get_app_info()['extensions'] assert NAMES[0] in extensions assert NAMES[1] in extensions assert check_extension(NAMES[0]) assert check_extension(NAMES[1]) # Uninstall assert uninstall_extension(NAMES[0]) assert uninstall_extension(NAMES[1]) extensions = get_app_info()['extensions'] assert NAMES[0] not in extensions assert NAMES[1] not in extensions assert not check_extension(NAMES[0]) assert not check_extension(NAMES[1])
def test_uninstall_core_extension(self): assert uninstall_extension("@jupyterlab/console-extension") is True app_dir = self.app_dir build() with open(pjoin(app_dir, "staging", "package.json")) as fid: data = json.load(fid) extensions = data["jupyterlab"]["extensions"] assert "@jupyterlab/console-extension" not in extensions assert not check_extension("@jupyterlab/console-extension") assert install_extension("@jupyterlab/console-extension") is True build() with open(pjoin(app_dir, "staging", "package.json")) as fid: data = json.load(fid) extensions = data["jupyterlab"]["extensions"] assert "@jupyterlab/console-extension" in extensions assert check_extension("@jupyterlab/console-extension")
def test_build_check(self): # Do the initial build. assert build_check() assert install_extension(self.mock_extension) is True assert link_package(self.mock_package) is True build() assert not build_check() # Check installed extensions. assert install_extension(self.mock_mimeextension) is True assert build_check() assert uninstall_extension(self.pkg_names["mimeextension"]) is True assert not build_check() # Check local extensions. pkg_path = pjoin(self.mock_extension, "package.json") with open(pkg_path) as fid: data = json.load(fid) with open(pkg_path, "rb") as fid: orig = fid.read() data["foo"] = "bar" with open(pkg_path, "w") as fid: json.dump(data, fid) assert build_check() assert build_check() with open(pkg_path, "wb") as fid: fid.write(orig) assert not build_check() # Check linked packages. pkg_path = pjoin(self.mock_package, "index.js") with open(pkg_path, "rb") as fid: orig = fid.read() with open(pkg_path, "wb") as fid: fid.write(orig + b'\nconsole.log("hello");') assert build_check() assert build_check() with open(pkg_path, "wb") as fid: fid.write(orig) assert not build_check()
def test_uninstall_extension(self): install_extension(pjoin(here, 'mockextension')) uninstall_extension('@jupyterlab/python-tests') data = _get_config() exts = data['installed_extensions'] assert '@jupyterlab/python-tests' not in exts
def uninstall(self, extension): """Handle an uninstall request""" did_uninstall = uninstall_extension(extension, app_dir=self.app_dir, logger=self.log) raise gen.Return(dict(status='ok' if did_uninstall else 'error',))
def test_uninstall_extension(self): install_extension(pjoin(here, 'mockextension')) uninstall_extension('@jupyterlab/python-tests') data = _get_config() exts = data['installed_extensions'] assert '@jupyterlab/python-tests' not in exts
def test_uninstall_extension(self): install_extension(self.source_dir) uninstall_extension('@jupyterlab/python-tests') path = pjoin(self.app_dir, 'extensions', '*python_tests*.tgz') assert not glob.glob(path) assert '@jupyterlab/python-tests' not in _get_extensions(self.app_dir)
def test_install_mime_renderer(self): install_extension(self.mime_renderer_dir) assert '@jupyterlab/mime-extension-test' in _get_extensions(self.app_dir) uninstall_extension('@jupyterlab/mime-extension-test') assert '@jupyterlab/mime-extension-test' not in _get_extensions(self.app_dir)
def test_uninstall_extension(self): install_extension(self.source_dir) uninstall_extension('@jupyterlab/python-tests') path = pjoin(self.app_dir, 'extensions', '*python_tests*.tgz') assert not glob.glob(path) assert '@jupyterlab/python-tests' not in _get_extensions(self.app_dir)