def test_package_move(self): """Test package move.""" pkg_name = "pydad" pkg_version = Version("2") # copy packages to a temp repo repo_path = os.path.join(self.root, "tmp2_packages") shutil.copytree(self.solver_packages_path, repo_path) # create an empty temp repo dest_repo_path = os.path.join(self.root, "tmp3_packages") os.mkdir(dest_repo_path) # verify that source pkg exists src_pkg = get_package_from_repository(pkg_name, pkg_version, repo_path) self.assertNotEqual(src_pkg, None) # move it to dest repo move_package(src_pkg, dest_repo_path) # verify it exists in dest repo dest_pkg = get_package_from_repository(pkg_name, pkg_version, dest_repo_path) self.assertNotEqual(dest_pkg, None) # verify it is not visible in source repo src_pkg = get_package_from_repository(pkg_name, pkg_version, repo_path) self.assertEqual(src_pkg, None)
def test_package_ignore(self): """Test package ignore/unignore.""" pkg_name = "pydad" pkg_version = Version("2") # copy packages to a temp repo repo_path = os.path.join(self.root, "tmp1_packages") shutil.copytree(self.solver_packages_path, repo_path) # check that a known package exists pkg = get_package_from_repository(pkg_name, pkg_version, repo_path) self.assertNotEqual(pkg, None) repo = pkg.repository # ignore a pkg that doesn't exist i = repo.ignore_package("i_dont_exist", Version("1")) self.assertEqual(i, -1) # ignore a pkg that doesn't exist, but allow it i = repo.ignore_package("i_dont_exist", Version("1"), allow_missing=True) self.assertEqual(i, 1) # unignore a pkg that doesn't exist i = repo.unignore_package("i_dont_exist", Version("1")) self.assertEqual(i, -1) # ignore an existing package i = repo.ignore_package(pkg_name, pkg_version) self.assertEqual(i, 1) # verify that ignoring it again does nothing i = repo.ignore_package(pkg_name, pkg_version) self.assertEqual(i, 0) # verify that we cannot see it pkg = get_package_from_repository(pkg_name, pkg_version, repo_path) self.assertEqual(pkg, None) # unignore it i = repo.unignore_package(pkg_name, pkg_version) self.assertEqual(i, 1) # verify that unignoring it again does nothing i = repo.unignore_package(pkg_name, pkg_version) self.assertEqual(i, 0) # verify that we can see it again pkg = get_package_from_repository(pkg_name, pkg_version, repo_path) self.assertNotEqual(pkg, None)
def command(opts, parser, extra_arg_groups=None): from rez.vendor.version.requirement import VersionedObject from rez.packages import get_package_from_repository from rez.package_move import move_package import sys obj = VersionedObject(opts.PKG) if opts.PATH is None: list_repos_containing_pkg(obj.name, obj.version) sys.exit(0) # find src pkg src_pkg = get_package_from_repository(obj.name, obj.version, opts.PATH) if src_pkg is None: print("Package not found.", file=sys.stderr) sys.exit(1) move_package( package=src_pkg, dest_repository=opts.dest_path, keep_timestamp=opts.keep_timestamp, force=opts.force, verbose=opts.verbose )
def test_package_remove(self): """Test package remove.""" pkg_name = "pydad" pkg_version = Version("2") # copy packages to a temp repo repo_path = os.path.join(self.root, "tmp4_packages") shutil.copytree(self.solver_packages_path, repo_path) # verify that source pkg exists src_pkg = get_package_from_repository(pkg_name, pkg_version, repo_path) self.assertNotEqual(src_pkg, None) # remove it was_removed = remove_package(pkg_name, pkg_version, repo_path) self.assertTrue(was_removed) # verify that source pkg no longer exists (and isn't simply ignored) repo = package_repository_manager.get_repository(repo_path) i = repo.unignore_package(pkg_name, pkg_version) self.assertEqual(i, -1)
def test_remove_packages_ignored_since(self): pkg_name = "pydad" pkg_version = Version("2") # copy packages to a temp repo repo_path = os.path.join(self.root, "tmp5_packages") shutil.copytree(self.solver_packages_path, repo_path) # verify that source pkg exists src_pkg = get_package_from_repository(pkg_name, pkg_version, repo_path) self.assertNotEqual(src_pkg, None) # ignore it repo = package_repository_manager.get_repository(repo_path) i = repo.ignore_package(pkg_name, pkg_version) self.assertEqual(i, 1) # remove all ignored packages num_removed = remove_packages_ignored_since(days=0, paths=[repo_path]) self.assertEqual(num_removed, 1) # verify that source pkg no longer exists (and isn't simply ignored) i = repo.unignore_package(pkg_name, pkg_version) self.assertEqual(i, -1)