Пример #1
0
 def makexom(opts=(), httpget=httpget, proxy=None, mocking=True,
             plugins=()):
     hook = PluginManager(plugins)
     serverdir = gentmp()
     fullopts = ["devpi-server", "--serverdir", serverdir] + list(opts)
     fullopts = [str(x) for x in fullopts]
     config = parseoptions(fullopts, hook=hook)
     if mocking:
         if proxy is None:
             proxy = mock.create_autospec(XMLProxy)
             proxy.list_packages_with_serial.return_value = {}
         xom = XOM(config, proxy=proxy, httpget=httpget)
         add_pypistage_mocks(monkeypatch, httpget)
     else:
         xom = XOM(config)
     # initialize default indexes
     from devpi_server.main import set_default_indexes
     if not xom.config.args.master_url:
         with xom.keyfs.transaction(write=True):
             set_default_indexes(xom.model)
     if mocking:
         xom.pypimirror.init_pypi_mirror(proxy)
     if request.node.get_marker("start_threads"):
         xom.thread_pool.start()
     elif request.node.get_marker("with_notifier"):
         xom.thread_pool.start_one(xom.keyfs.notifier)
     request.addfinalizer(xom.thread_pool.shutdown)
     return xom
Пример #2
0
 def makexom(opts=(), httpget=httpget, plugins=()):
     from devpi_server import auth_basic
     from devpi_server import auth_devpi
     plugins = [
         plugin[0] if isinstance(plugin, tuple) else plugin
         for plugin in plugins
     ]
     for plugin in [auth_basic, auth_devpi, storage_info["_test_plugin"]]:
         if plugin not in plugins:
             plugins.append(plugin)
     pm = get_pluginmanager(load_entrypoints=False)
     for plugin in plugins:
         pm.register(plugin)
     serverdir = gentmp()
     fullopts = ["devpi-server", "--serverdir", serverdir] + list(opts)
     if request.node.get_marker("with_replica_thread"):
         fullopts.append("--master=http://localhost")
     if not request.node.get_marker("no_storage_option"):
         if storage_info["name"] != "sqlite":
             fullopts.append("--storage=%s" % storage_info["name"])
     fullopts = [str(x) for x in fullopts]
     config = parseoptions(pm, fullopts)
     config.init_nodeinfo()
     for marker in ("storage_with_filesystem", ):
         if request.node.get_marker(marker):
             info = config._storage_info()
             markers = info.get("_test_markers", [])
             if marker not in markers:
                 pytest.skip("The storage doesn't have marker '%s'." %
                             marker)
     if not request.node.get_marker("no_storage_option"):
         assert storage_info["storage"] is config.storage
     if request.node.get_marker("nomocking"):
         xom = XOM(config)
     else:
         xom = XOM(config, httpget=httpget)
         if not request.node.get_marker("nomockprojectsremote"):
             monkeypatch.setattr(extpypi.PyPIStage, "_get_remote_projects",
                                 lambda self: set())
         add_pypistage_mocks(monkeypatch, httpget)
     # initialize default indexes
     from devpi_server.main import set_default_indexes
     if not xom.config.args.master_url:
         with xom.keyfs.transaction(write=True):
             set_default_indexes(xom.model)
     if request.node.get_marker("with_replica_thread"):
         from devpi_server.replica import ReplicaThread
         rt = ReplicaThread(xom)
         xom.replica_thread = rt
         xom.thread_pool.register(rt)
         xom.thread_pool.start_one(rt)
     if request.node.get_marker("start_threads"):
         xom.thread_pool.start()
     elif request.node.get_marker("with_notifier"):
         xom.thread_pool.start_one(xom.keyfs.notifier)
     request.addfinalizer(xom.thread_pool.shutdown)
     return xom
Пример #3
0
def xom(request, keyfs, filestore, httpget):
    from devpi_server.main import parseoptions, XOM
    from devpi_server.extpypi import ExtDB
    config = parseoptions(["devpi-server"])
    xom = XOM(config)
    xom.keyfs = keyfs
    xom.releasefilestore = filestore
    xom.httpget = httpget
    xom.extdb = ExtDB(xom=xom)
    xom.extdb.url2response = httpget.url2response
    request.addfinalizer(xom.shutdown)
    return xom