def test_serve_max_body(monkeypatch, tmpdir): def check_max_body(app, host, port, threads, max_request_body_size): assert max_request_body_size == 42 monkeypatch.setattr("waitress.serve", check_max_body) from devpi_server.main import main main(["devpi-server", "--max-request-body-size", "42"])
def test_serve_threads(monkeypatch, tmpdir): def check_threads(app, host, port, threads, max_request_body_size): assert threads == 100 monkeypatch.setattr("waitress.serve", check_threads) from devpi_server.main import main main(["devpi-server", "--threads", "100"])
def test_invalidate_is_called(monkeypatch, tmpdir): monkeypatch.setattr(devpi_server.main, "bottle_run", lambda *args: None) def record(basedir): assert tmpdir.join("root", "pypi") == basedir 0/0 monkeypatch.setattr(devpi_server.extpypi, "invalidate_on_version_change", lambda xom: 0/0) with pytest.raises(ZeroDivisionError): main(["devpi-server", "--serverdir", str(tmpdir)])
def test_invalidate_is_called(monkeypatch, tmpdir): monkeypatch.setattr(devpi_server.main, "bottle_run", lambda *args: None) def record(basedir): assert tmpdir.join("root", "pypi") == basedir 0 / 0 monkeypatch.setattr(devpi_server.extpypi, "invalidate_on_version_change", lambda xom: 0 / 0) with pytest.raises(ZeroDivisionError): main(["devpi-server", "--serverdir", str(tmpdir)])
def test_startup_fails_on_initial_setup_nonetwork(tmpdir, monkeypatch): import bottle monkeypatch.setattr(bottle, "run", lambda **kw: 0 / 0) monkeypatch.setattr(devpi_server.main, "PYPIURL_XMLRPC", "http://qwqwlekjqwlekqwe.notexists") ret = main(["devpi-server", "--serverdir", str(tmpdir)]) assert ret
def test_startup_fails_on_initial_setup_nonetwork(tmpdir, monkeypatch): import bottle monkeypatch.setattr(bottle, "run", lambda **kw: 0/0) monkeypatch.setattr(devpi_server.main, "PYPIURL_XMLRPC", "http://qwqwlekjqwlekqwe.notexists") ret = main(["devpi-server", "--serverdir", str(tmpdir)]) assert ret
def test_version(capfd): main(["devpi-server", "--version"]) out, err = capfd.readouterr() assert not err # not logging output assert devpi_server.__version__ in out.strip()
def test_startup_fails_on_initial_setup_nonetwork(tmpdir, monkeypatch): monkeypatch.setattr(devpi_server.main, "wsgi_run", lambda **kw: 0 / 0) monkeypatch.setattr(devpi_server.main, "PYPIURL_XMLRPC", "http://localhost:1") ret = main(["devpi-server", "--serverdir", str(tmpdir)]) assert ret
def test_startup_fails_on_initial_setup_nonetwork(tmpdir, monkeypatch): monkeypatch.setattr(devpi_server.main, "wsgi_run", lambda **kw: 0/0) monkeypatch.setattr(devpi_server.main, "PYPIURL_XMLRPC", "http://localhost:1") ret = main(["devpi-server", "--serverdir", str(tmpdir)]) assert ret