Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/debian/tests/test_debian.py
Show First 20 Lines • Show All 491 Lines • ▼ Show 20 Lines | known_package_artifacts = { | ||||
"extrinsic": {"raw": package_files,}, | "extrinsic": {"raw": package_files,}, | ||||
# ... removed the unnecessary intermediary data | # ... removed the unnecessary intermediary data | ||||
} | } | ||||
} | } | ||||
actual_revision = resolve_revision_from(known_package_artifacts, p_info) | actual_revision = resolve_revision_from(known_package_artifacts, p_info) | ||||
assert actual_revision == expected_revision_id | assert actual_revision == expected_revision_id | ||||
def test_debian_resolve_revision_from_corrupt_known_artifact(): | |||||
ardumont: why `corrupt` by the way?
and that should be corrupted, shouldn't it? | |||||
vlorentzAuthorUnsubmitted Done Inline ActionsBecause there should only be one .dsc per package. And "corrupt" and "corrupted" are synonyms vlorentz: Because there should only be one .dsc per package. And "corrupt" and "corrupted" are synonyms | |||||
"""To many or not enough .dsc files in the known_artifacts dict""" | |||||
artifact_metadata = PACKAGE_FILES | |||||
p_info = DebianPackageInfo.from_metadata(artifact_metadata, url=URL) | |||||
expected_revision_id = ( | |||||
b"(\x07\xf5\xb3\xf8Ch\xb4\x88\x9a\x9a\xe8'\xfe\x85\x85O\xfe\xcf\x07" | |||||
) | |||||
files = dict(artifact_metadata["files"]) | |||||
package_files = { | |||||
"name": PACKAGE_FILES["name"], | |||||
"version": PACKAGE_FILES["version"], | |||||
"files": files, | |||||
} | |||||
known_package_artifacts = { | |||||
expected_revision_id: { | |||||
"extrinsic": {"raw": package_files,}, | |||||
# ... removed the unnecessary intermediary data | |||||
} | |||||
} | |||||
# Too many .dsc | |||||
files["another.dsc"] = files["cicero_0.7.2-3.dsc"] | |||||
with pytest.raises(ValueError, match="exactly one known .dsc"): | |||||
resolve_revision_from(known_package_artifacts, p_info) | |||||
# Not enough .dsc | |||||
del files["another.dsc"] | |||||
del files["cicero_0.7.2-3.dsc"] | |||||
with pytest.raises(ValueError, match="exactly one known .dsc"): | |||||
resolve_revision_from(known_package_artifacts, p_info) | |||||
def test_debian_resolve_revision_from_corrupt_new_artifact(): | |||||
artifact_metadata = PACKAGE_FILES | |||||
files = PACKAGE_FILES["files"] | |||||
files = {**files, "another.dsc": files["cicero_0.7.2-3.dsc"]} | |||||
artifact_metadata = {**PACKAGE_FILES, "files": files} | |||||
# Too many .dsc | |||||
files["another.dsc"] = files["cicero_0.7.2-3.dsc"] | |||||
p_info = DebianPackageInfo.from_metadata(artifact_metadata, url=URL) | |||||
with pytest.raises(ValueError, match="exactly one new .dsc"): | |||||
resolve_revision_from(PACKAGE_FILES, p_info) | |||||
# Not enough .dsc | |||||
del files["another.dsc"] | |||||
del files["cicero_0.7.2-3.dsc"] | |||||
p_info = DebianPackageInfo.from_metadata(artifact_metadata, url=URL) | |||||
with pytest.raises(ValueError, match="exactly one new .dsc"): | |||||
resolve_revision_from(PACKAGE_FILES, p_info) | |||||
ardumontUnsubmitted Not Done Inline ActionsIt's not immediately clear what's the difference between this test and the previous one. ardumont: It's not immediately clear what's the difference between this test and the previous one.
Can… | |||||
vlorentzAuthorUnsubmitted Done Inline ActionsOne is for the known artifacts, and one is for the new artifact vlorentz: One is for the **known** artifacts, and one is for the **new** artifact |
why corrupt by the way?
and that should be corrupted, shouldn't it?