Beispiel #1
0
    def test_indexer_backend_yaml_options(self, make_yaml_config):
        from devpi_web import main
        from pluggy import HookimplMarker
        hookimpl = HookimplMarker("devpiweb")

        class Index(object):
            def __init__(self, config, settings):
                self.settings = settings

        class Plugin:
            @hookimpl
            def devpiweb_indexer_backend(self):
                return dict(indexer=Index,
                            name="foo",
                            description="Foo backend")

        yaml_path = make_yaml_config(
            textwrap.dedent("""\
            devpi-server:
              indexer-backend:
                name: foo
                bar: ham"""))
        options = ("-c", yaml_path)
        config = make_config(("devpi-server", ) + options)
        assert isinstance(config.args.indexer_backend, dict)
        plugin = Plugin()
        main.get_pluginmanager(config).register(plugin)
        indexer = main.get_indexer_from_config(config)
        assert isinstance(indexer, Index)
        assert indexer.settings == {"bar": "ham"}
Beispiel #2
0
    def test_indexer_backend_options(self):
        from devpi_web import main
        from pluggy import HookimplMarker
        hookimpl = HookimplMarker("devpiweb")

        class Index(object):
            def __init__(self, config, settings):
                self.settings = settings

        class Plugin:
            @hookimpl
            def devpiweb_indexer_backend(self):
                return dict(indexer=Index,
                            name="foo",
                            description="Foo backend")

        options = ("--indexer-backend", "foo:bar=ham")
        config = make_config(("devpi-server", ) + options)
        assert config.args.indexer_backend == "foo:bar=ham"
        plugin = Plugin()
        main.get_pluginmanager(config).register(plugin)
        indexer = main.get_indexer_from_config(config)
        assert isinstance(indexer, Index)
        assert indexer.settings == {"bar": "ham"}
Beispiel #3
0
def test_main_starts_server_if_run_commands_returns_none(monkeypatch, tmpdir):
    from devpi_server.main import _main, get_pluginmanager
    l = []
    class Plugin:
        def devpiserver_cmdline_run(self, xom):
            l.append(xom)
    monkeypatch.setattr(devpi_server.extpypi.PyPIMirror, "init_pypi_mirror",
                        lambda self, proxy: None)
    pm = get_pluginmanager()
    pm.register(Plugin())
    with pytest.raises(ZeroDivisionError):
        _main(
            argv=["devpi-server", "--serverdir", str(tmpdir)],
            pluginmanager=pm)
    assert len(l) == 1
    assert isinstance(l[0], XOM)
def test_main_starts_server_if_run_commands_returns_none(tmpdir):
    from devpi_server.main import _main, get_pluginmanager
    l = []
    class Plugin:
        def devpiserver_cmdline_run(self, xom):
            l.append(xom)
    pm = get_pluginmanager()
    pm.register(Plugin())
    _main(
        argv=["devpi-server", "--init", "--serverdir", str(tmpdir)],
        pluginmanager=pm)
    with pytest.raises(ZeroDivisionError):
        _main(
            argv=["devpi-server", "--serverdir", str(tmpdir)],
            pluginmanager=pm)
    assert len(l) == 1
    assert isinstance(l[0], XOM)
Beispiel #5
0
def test_run_commands_called(monkeypatch, tmpdir):
    from devpi_server.main import _main, get_pluginmanager
    l = []
    class Plugin:
        def devpiserver_cmdline_run(self, xom):
            l.append(xom)
            return 1
    monkeypatch.setattr(devpi_server.extpypi.PyPIMirror, "init_pypi_mirror",
                        lambda self, proxy: None)
    pm = get_pluginmanager()
    pm.register(Plugin())
    result = _main(
        argv=["devpi-server", "--serverdir", str(tmpdir)],
        pluginmanager=pm)
    assert result == 1
    assert len(l) == 1
    assert isinstance(l[0], XOM)
def test_run_commands_called(tmpdir):
    from devpi_server.main import _main, get_pluginmanager
    l = []
    class Plugin:
        def devpiserver_cmdline_run(self, xom):
            l.append(xom)
            return 1
    pm = get_pluginmanager()
    pm.register(Plugin())
    result = _main(
        argv=["devpi-server", "--init", "--serverdir", str(tmpdir)],
        pluginmanager=pm)
    result = _main(
        argv=["devpi-server", "--serverdir", str(tmpdir)],
        pluginmanager=pm)
    assert result == 1
    assert len(l) == 1
    assert isinstance(l[0], XOM)