checksum.py tests: extract add_versions_to_pkg fixture (#49100)
This commit is contained in:
parent
3fbdfc464b
commit
c97be2a9d7
@ -23,7 +23,15 @@
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def can_fetch_versions(monkeypatch):
|
def no_add(monkeypatch):
|
||||||
|
def add_versions_to_pkg(pkg, version_lines, open_in_editor):
|
||||||
|
raise AssertionError("Should not be called")
|
||||||
|
|
||||||
|
monkeypatch.setattr(spack.cmd.checksum, "add_versions_to_pkg", add_versions_to_pkg)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def can_fetch_versions(monkeypatch, no_add):
|
||||||
"""Fake successful version detection."""
|
"""Fake successful version detection."""
|
||||||
|
|
||||||
def fetch_remote_versions(pkg, concurrency):
|
def fetch_remote_versions(pkg, concurrency):
|
||||||
@ -38,10 +46,6 @@ def get_checksums_for_versions(url_by_version, package_name, **kwargs):
|
|||||||
def url_exists(url, curl=None):
|
def url_exists(url, curl=None):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def add_versions_to_pkg(pkg, version_lines, open_in_editor):
|
|
||||||
raise AssertionError("Should not be called")
|
|
||||||
|
|
||||||
monkeypatch.setattr(spack.cmd.checksum, "add_versions_to_pkg", add_versions_to_pkg)
|
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
spack.package_base.PackageBase, "fetch_remote_versions", fetch_remote_versions
|
spack.package_base.PackageBase, "fetch_remote_versions", fetch_remote_versions
|
||||||
)
|
)
|
||||||
@ -50,7 +54,7 @@ def add_versions_to_pkg(pkg, version_lines, open_in_editor):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def cannot_fetch_versions(monkeypatch):
|
def cannot_fetch_versions(monkeypatch, no_add):
|
||||||
"""Fake unsuccessful version detection."""
|
"""Fake unsuccessful version detection."""
|
||||||
|
|
||||||
def fetch_remote_versions(pkg, concurrency):
|
def fetch_remote_versions(pkg, concurrency):
|
||||||
@ -283,11 +287,7 @@ def test_checksum_versions(mock_packages, can_fetch_versions, monkeypatch):
|
|||||||
assert "version(" in output
|
assert "version(" in output
|
||||||
|
|
||||||
|
|
||||||
def test_checksum_missing_version(mock_packages, cannot_fetch_versions, monkeypatch):
|
def test_checksum_missing_version(mock_packages, cannot_fetch_versions):
|
||||||
def add_versions_to_pkg(pkg, version_lines, open_in_editor):
|
|
||||||
raise AssertionError("Should not be called")
|
|
||||||
|
|
||||||
monkeypatch.setattr(spack.cmd.checksum, "add_versions_to_pkg", add_versions_to_pkg)
|
|
||||||
output = spack_checksum("preferred-test", "99.99.99", fail_on_error=False)
|
output = spack_checksum("preferred-test", "99.99.99", fail_on_error=False)
|
||||||
assert "Could not find any remote versions" in output
|
assert "Could not find any remote versions" in output
|
||||||
output = spack_checksum("--add-to-package", "preferred-test", "99.99.99", fail_on_error=False)
|
output = spack_checksum("--add-to-package", "preferred-test", "99.99.99", fail_on_error=False)
|
||||||
@ -295,9 +295,6 @@ def add_versions_to_pkg(pkg, version_lines, open_in_editor):
|
|||||||
|
|
||||||
|
|
||||||
def test_checksum_deprecated_version(mock_packages, can_fetch_versions):
|
def test_checksum_deprecated_version(mock_packages, can_fetch_versions):
|
||||||
def add_versions_to_pkg(pkg, version_lines, open_in_editor):
|
|
||||||
raise AssertionError("Should not be called")
|
|
||||||
|
|
||||||
output = spack_checksum("deprecated-versions", "1.1.0", fail_on_error=False)
|
output = spack_checksum("deprecated-versions", "1.1.0", fail_on_error=False)
|
||||||
assert "Version 1.1.0 is deprecated" in output
|
assert "Version 1.1.0 is deprecated" in output
|
||||||
output = spack_checksum(
|
output = spack_checksum(
|
||||||
|
Loading…
Reference in New Issue
Block a user