def test_build_custom_minimal_core_config(self):
        default_config = CoreConfig()
        core_config = CoreConfig()
        core_config.clear_packages()
        logger = logging.getLogger('jupyterlab_test_logger')
        logger.setLevel('DEBUG')
        app_dir = self.tempdir()
        options = AppOptions(
            app_dir=app_dir,
            core_config=core_config,
            logger=logger,
            use_sys_dir=False,
        )

        extensions = (
            '@jupyterlab/application-extension',
            '@jupyterlab/apputils-extension',
        )
        singletons = (
            "@jupyterlab/application",
            "@jupyterlab/apputils",
            "@jupyterlab/coreutils",
            "@jupyterlab/services",
        )
        for name in extensions:
            semver = default_config.extensions[name]
            core_config.add(name, semver, extension=True)
        for name in singletons:
            semver = default_config.singletons[name]
            core_config.add(name, semver)

        assert install_extension(self.mock_extension,
                                 app_options=options) is True
        build(app_options=options)

        # check static directory.
        entry = pjoin(app_dir, 'static', 'index.out.js')
        with open(entry) as fid:
            data = fid.read()
        assert self.pkg_names['extension'] in data

        pkg = pjoin(app_dir, 'static', 'package.json')
        with open(pkg) as fid:
            data = json.load(fid)
        assert sorted(data['jupyterlab']['extensions'].keys()) == [
            '@jupyterlab/application-extension',
            '@jupyterlab/apputils-extension',
            '@jupyterlab/mock-extension',
        ]
        assert data['jupyterlab']['mimeExtensions'] == {}
        for pkg in data['jupyterlab']['singletonPackages']:
            if pkg.startswith('@jupyterlab/'):
                assert pkg in singletons
예제 #2
0
 def _default_core_config(self):
     c = CoreConfig()
     orig_extensions = c.extensions
     orig_mimes = c.mime_extensions
     orig_singletons = c.singletons
     c.clear_packages()
     for e in extensions:
         c.add(e, orig_extensions[e], extension=True)
     for e in mime_extensions:
         c.add(e, orig_mimes[e], mime_extension=True)
     for e in singletons:
         c.add(e, orig_singletons[e])
     return c