(
monkeypatch,
remove_user_data: bool,
remove_caches: bool,
remove_config_files: str | None,
tmp_path: Path,
)
| 1664 | ), |
| 1665 | ) |
| 1666 | def test_uninstallation_standalone( |
| 1667 | monkeypatch, |
| 1668 | remove_user_data: bool, |
| 1669 | remove_caches: bool, |
| 1670 | remove_config_files: str | None, |
| 1671 | tmp_path: Path, |
| 1672 | ): |
| 1673 | recipe_path = _example_path("uninstall_with_conda_exe") |
| 1674 | input_path = tmp_path / "input" |
| 1675 | shutil.copytree(str(recipe_path), str(input_path)) |
| 1676 | |
| 1677 | # Set up files for removal. |
| 1678 | # Since conda-standalone is extensively tested upstream, |
| 1679 | # only set up a minimum set of files. |
| 1680 | |
| 1681 | # Minimum set of files needed for an index cache |
| 1682 | pkg_cache = tmp_path / "pkgs" |
| 1683 | (pkg_cache / "cache").mkdir(parents=True) |
| 1684 | (pkg_cache / "urls.txt").touch() |
| 1685 | |
| 1686 | user_rc = tmp_path / ".condarc" |
| 1687 | system_rc = Path("C:/ProgramData/conda/.condarc") |
| 1688 | system_rc.parent.mkdir(parents=True) |
| 1689 | condarc = f"pkgs_dirs:\n - {pkg_cache}\n" |
| 1690 | user_rc.write_text(condarc) |
| 1691 | system_rc.write_text(condarc) |
| 1692 | |
| 1693 | uninstall_options = [] |
| 1694 | remove_system_rcs = False |
| 1695 | remove_user_rcs = False |
| 1696 | if remove_config_files is not None: |
| 1697 | uninstall_options.append(f"/RemoveConfigFiles={remove_config_files}") |
| 1698 | remove_system_rcs = remove_config_files != "user" |
| 1699 | remove_user_rcs = remove_config_files != "system" |
| 1700 | if remove_user_data: |
| 1701 | uninstall_options.append("/RemoveUserData=1") |
| 1702 | if remove_caches: |
| 1703 | uninstall_options.append("/RemoveCaches=1") |
| 1704 | |
| 1705 | # Create extra files to delete in pre-uninstall script |
| 1706 | user_files_dir = tmp_path / "user_files" |
| 1707 | user_files_dir.mkdir() |
| 1708 | user_files: dict[str, bool] = { |
| 1709 | "cache": remove_caches, |
| 1710 | "data": remove_user_data, |
| 1711 | "config_user": remove_user_rcs, |
| 1712 | "config_system": remove_system_rcs, |
| 1713 | } |
| 1714 | for file in user_files: |
| 1715 | (user_files_dir / file).touch() |
| 1716 | assert (user_files_dir / file).exists() |
| 1717 | yaml = YAML() |
| 1718 | construct_yaml_file = input_path / "construct.yaml" |
| 1719 | with construct_yaml_file.open() as file: |
| 1720 | construct_yaml = yaml.load(file) |
| 1721 | construct_yaml["script_env_variables"] = {"USER_FILES": str(user_files_dir)} |
| 1722 | with construct_yaml_file.open(mode="w") as file: |
| 1723 | yaml.dump(construct_yaml, file) |
nothing calls this directly
no test coverage detected