Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/nixguix/tests/test_nixguix.py
Show All 20 Lines | from swh.loader.package.nixguix.loader import ( | ||||
make_pattern_unsupported_file_extension, | make_pattern_unsupported_file_extension, | ||||
parse_sources, | parse_sources, | ||||
retrieve_sources, | retrieve_sources, | ||||
) | ) | ||||
from swh.loader.package.utils import download | from swh.loader.package.utils import download | ||||
from swh.loader.tests import assert_last_visit_matches | from swh.loader.tests import assert_last_visit_matches | ||||
from swh.loader.tests import check_snapshot as check_snapshot_full | from swh.loader.tests import check_snapshot as check_snapshot_full | ||||
from swh.loader.tests import get_stats | from swh.loader.tests import get_stats | ||||
from swh.model.hashutil import hash_to_bytes, hash_to_hex | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.identifiers import ExtendedObjectType, ExtendedSWHID | from swh.model.identifiers import ExtendedObjectType, ExtendedSWHID | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
RawExtrinsicMetadata, | RawExtrinsicMetadata, | ||||
Snapshot, | Snapshot, | ||||
SnapshotBranch, | SnapshotBranch, | ||||
▲ Show 20 Lines • Show All 653 Lines • ▼ Show 20 Lines | ) as last_snapshot: | ||||
actual_detections: List[Dict] = [] | actual_detections: List[Dict] = [] | ||||
for record in caplog.records: | for record in caplog.records: | ||||
logtext = record.getMessage() | logtext = record.getMessage() | ||||
if "Unexpected metadata revision structure detected:" in logtext: | if "Unexpected metadata revision structure detected:" in logtext: | ||||
actual_detections.append(record.args["context"]) | actual_detections.append(record.args["context"]) | ||||
expected_detections = [ | expected_detections = [ | ||||
{ | {"reason": "'integrity'", "known_artifact": old_revision.metadata,}, | ||||
"revision": hash_to_hex(old_revision.id), | {"reason": "'integrity'", "known_artifact": old_revision.metadata,}, | ||||
"reason": "'integrity'", | |||||
"known_artifact": old_revision.metadata, | |||||
}, | |||||
{ | |||||
"revision": hash_to_hex(old_revision.id), | |||||
"reason": "'integrity'", | |||||
"known_artifact": old_revision.metadata, | |||||
}, | |||||
] | ] | ||||
# as many calls as there are sources listed in the sources.json | # as many calls as there are sources listed in the sources.json | ||||
assert len(expected_detections) == len(all_sources["sources"]) | assert len(expected_detections) == len(all_sources["sources"]) | ||||
assert actual_detections == expected_detections | assert actual_detections == expected_detections |