Пример #1
0
def test_export_import_no_root_pypi(tmpdir, capfd, monkeypatch, use_option):
    from devpi_server.importexport import import_
    from devpi_server.init import init
    from devpi_server.main import main
    monkeypatch.setattr("devpi_server.main.configure_logging", lambda a: None)
    clean = tmpdir.join("clean").ensure(dir=True)
    if use_option:
        ret = main(argv=[
            "devpi-server", "--init", "--serverdir", clean.strpath,
            "--no-root-pypi"
        ])
    else:
        ret = init(argv=[
            "devpi-init", "--serverdir", clean.strpath, "--no-root-pypi"
        ])
    assert ret == 0
    export = tmpdir.join("export")
    ret = main([
        "devpi-server", "--serverdir", clean.strpath, "--export",
        export.strpath
    ])
    assert ret == 0
    # first we test regular import
    import_dir = tmpdir.join("import")
    if use_option:
        ret = main(argv=[
            "devpi-server", "--serverdir", import_dir.strpath, "--no-events",
            "--import", export.strpath
        ])
    else:
        ret = import_(argv=[
            "devpi-import", "--serverdir", import_dir.strpath, "--no-events",
            export.strpath
        ])
    assert ret == 0
    out, err = capfd.readouterr()
    assert os.listdir(clean.strpath) == os.listdir(import_dir.strpath)
    assert 'import_all: importing finished' in out
    assert err == ''
    # now we add --no-root-pypi
    import_dir.remove()
    if use_option:
        ret = main(argv=[
            "devpi-server", "--serverdir", import_dir.strpath, "--no-events",
            "--no-root-pypi", "--import", export.strpath
        ])
    else:
        ret = import_(argv=[
            "devpi-import", "--serverdir", import_dir.strpath, "--no-events",
            "--no-root-pypi", export.strpath
        ])
    assert ret == 0
    out, err = capfd.readouterr()
    assert os.listdir(clean.strpath) == os.listdir(import_dir.strpath)
    assert 'import_all: importing finished' in out
    assert err == ''
Пример #2
0
 def new_import(self, options=(), plugin=None):
     if request.param:
         mapp2 = makemapp(
             options=("--import", str(self.exportdir)) + options)
         if plugin is not None:
             mapp2.xom.config.pluginmanager.register(plugin)
         mapp2.xom.config.init_nodeinfo()
         assert mapp2.xom.main() == 0
     else:
         from devpi_server.config import get_pluginmanager
         from devpi_server.importexport import import_
         serverdir = gentmp()
         argv = [
             "devpi-import", "--no-events", "--serverdir", serverdir
         ]
         argv.extend(options)
         argv.extend(["--storage", storage_info["name"]])
         argv.append(self.exportdir)
         pm = get_pluginmanager()
         pm.register(plugin)
         assert import_(pluginmanager=pm, argv=argv) == 0
         mapp2 = makemapp(options=["--serverdir", serverdir])
         if plugin is not None:
             mapp2.xom.config.pluginmanager.register(plugin)
     return mapp2
Пример #3
0
 def import_testdata(self, name, options=()):
     from devpi_server.importexport import import_
     path = self.testdatadir.join(name).strpath
     serverdir = gentmp()
     argv = [
         "devpi-import", "--no-events", "--serverdir", serverdir
     ]
     argv.extend(options)
     argv.extend(["--storage", storage_info["name"]])
     argv.append(path)
     assert import_(argv=argv) == 0
     mapp = makemapp(options=["--serverdir", serverdir])
     return mapp
Пример #4
0
 def import_testdata(self, name, options=()):
     path = self.testdatadir.join(name).strpath
     if request.param:
         mapp = makemapp(options=("--import", path) + options)
         mapp.xom.config.init_nodeinfo()
         assert mapp.xom.main() == 0
     else:
         from devpi_server.importexport import import_
         serverdir = gentmp()
         argv = [
             "devpi-import", "--no-events", "--serverdir", serverdir
         ]
         argv.extend(options)
         argv.extend(["--storage", storage_info["name"]])
         argv.append(path)
         assert import_(argv=argv) == 0
         mapp = makemapp(options=["--serverdir", serverdir])
     return mapp
Пример #5
0
def test_export_import(tmpdir, capfd, monkeypatch):
    from devpi_server.importexport import export
    from devpi_server.importexport import import_
    from devpi_server.init import init
    monkeypatch.setattr("devpi_server.main.configure_logging", lambda a: None)
    clean = tmpdir.join("clean").ensure(dir=True)
    ret = init(argv=["devpi-init", "--serverdir", clean.strpath])
    assert ret == 0
    export_dir = tmpdir.join("export")
    ret = export(argv=[
        "devpi-export", "--serverdir", clean.strpath, export_dir.strpath
    ])
    assert ret == 0
    import_dir = tmpdir.join("import")
    ret = import_(argv=[
        "devpi-import", "--serverdir", import_dir.strpath, "--no-events",
        export_dir.strpath
    ])
    assert ret == 0
    out, err = capfd.readouterr()
    assert os.listdir(clean.strpath) == os.listdir(import_dir.strpath)
    assert 'import_all: importing finished' in out
    assert err == ''