From fa7ee002936cea613b9b19914192bd0edffd1227 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 26 Dec 2024 14:33:09 +0100 Subject: [PATCH] Add test --- micromamba/tests/test_create.py | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/micromamba/tests/test_create.py b/micromamba/tests/test_create.py index 18b92c3b1b..5f5b452e67 100644 --- a/micromamba/tests/test_create.py +++ b/micromamba/tests/test_create.py @@ -1156,6 +1156,46 @@ def test_create_with_non_existing_subdir(tmp_home, tmp_root_prefix, tmp_path): helpers.create("-p", env_prefix, "--dry-run", "--json", "conda-forge/noarch::xtensor") +@pytest.mark.parametrize( + "spec", + [ + "https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-main.tar.bz2", + "https://conda.anaconda.org/conda-forge/linux-64/abacus-3.2.4-hb6c440e_0.conda", + ], +) +def test_create_with_explicit_url(tmp_home, tmp_root_prefix, tmp_path, spec): + """Attempts to install a package using an explicit url.""" + empty_root_prefix = tmp_path / "empty-root-create-from-explicit-url" + env_name = "env-create-from-explicit-url" + + os.environ["MAMBA_ROOT_PREFIX"] = str(empty_root_prefix) + + res = helpers.create( + spec, "--no-env", "-n", env_name, "--override-channels", "--json", default_channel=False + ) + assert res["success"] + + pkgs = res["actions"]["LINK"] + if spec.endswith(".tar.bz2"): + assert len(pkgs) == 1 + assert pkgs[0]["name"] == "_libgcc_mutex" + assert pkgs[0]["version"] == "0.1" + assert ( + pkgs[0]["url"] + == "https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-main.tar.bz2" + ) + assert pkgs[0]["channel"] == "https://conda.anaconda.org/conda-forge" + else: + assert len(pkgs) == 1 + assert pkgs[0]["name"] == "abacus" + assert pkgs[0]["version"] == "3.2.4" + assert ( + pkgs[0]["url"] + == "https://conda.anaconda.org/conda-forge/linux-64/abacus-3.2.4-hb6c440e_0.conda" + ) + assert pkgs[0]["channel"] == "https://conda.anaconda.org/conda-forge" + + @pytest.mark.parametrize("shared_pkgs_dirs", [True], indirect=True) def test_create_with_multiple_files(tmp_home, tmp_root_prefix, tmpdir): env_name = "myenv"