def test_cloning_no_overwrite(): repo1 = Repository() pm = PackageManager(repo=repo1, installer=Installer(), overwrite=False, console=Console(exit_on_error=False)) pkg = Package(name="test_package", version="1.0.0", type="SOURCE") filename = resource_filename(__name__, "data/test_package-1.0.0.zip") pm.upload(pkg, filename) try: tdir = tempfile.mkdtemp() pm.clone(tdir) assert os.listdir(tdir) cloned_zip = os.path.join(tdir, os.listdir(tdir)[0]) #tryint to write back in the same repository if not in overwrite mode #is not allowed assert not pm.restore(cloned_zip, interactive=False) dest_pm = PackageManager(repo=Repository(), installer=Installer(), console=Console(exit_on_error=False)) assert not dest_pm.list_items() dest_pm.restore(cloned_zip, interactive=False) assert dest_pm.list_items() == pm.list_items() finally: shutil.rmtree(tdir)
def handle_push(config, data): with Console(verbose=config.get("verbose", False), exit_on_error=True) as c: repo = init_repository(c, config["repository"]) pkg_mgr = PackageManager(repo, console=c, installer=None, is_python3=config.get("python3", False)) pkg_mgr.restore(data["zipped_repo"])