cpan_loader = <swh.loader.package.cpan.loader.CpanLoader object at 0x7feb00a2e240>
head_release_original_artifacts_metadata = b'[{"url": "https://cpan.metacpan.org/authors/id/J/JJ/JJORE/Internals-CountObjects-0.05.tar.gz", "filename": "CountObj....tar.gz", "length": 632, "checksums": {"sha256": "e0ecf6ab4873fa55ff74da22a3c4ae0ab6a1409635c9cd2d6059abbb32be3a6a"}}]'
head_release_extrinsic_metadata = b'{\n "release" : {\n "provides" : "Internals::CountObjects",\n "distribution" : "Internals-CountObjects",...a256" : "bbf65021207a7a51c8f8475bc25c4735f49d62744a75d33595e9720731b2b02f"\n },\n "took" : 2,\n "total" : 1\n}\n'
def test_cpan_loader_load_multiple_version(
cpan_loader,
head_release_original_artifacts_metadata,
head_release_extrinsic_metadata,
):
load_status = cpan_loader.load()
assert load_status["status"] == "eventful"
assert load_status["snapshot_id"] is not None
expected_snapshot_id = "848ee8d69d33481c88ab81f6794f6504190f011f"
expected_head_release = "07382fd255ec0fc293b92aeb7e68b3fe31c174f9"
assert expected_snapshot_id == load_status["snapshot_id"]
expected_snapshot = Snapshot(
id=hash_to_bytes(load_status["snapshot_id"]),
branches={
b"releases/0.01": SnapshotBranch(
target=hash_to_bytes("e73aced4cc3d56b32a328d3248b25b052f029df4"),
target_type=TargetType.RELEASE,
),
b"releases/0.05": SnapshotBranch(
target=hash_to_bytes(expected_head_release),
target_type=TargetType.RELEASE,
),
b"HEAD": SnapshotBranch(
target=b"releases/0.05",
target_type=TargetType.ALIAS,
),
},
)
storage = cpan_loader.storage
check_snapshot(expected_snapshot, storage)
stats = get_stats(storage)
assert {
"content": 2,
"directory": 4,
"origin": 1,
"origin_visit": 1,
"release": 2,
"revision": 0,
"skipped_content": 0,
"snapshot": 1,
} == stats
head_release = storage.release_get([hash_to_bytes(expected_head_release)])[0]
assert head_release == Release(
name=b"0.05",
message=b"Synthetic release for Perl source package Internals-CountObjects version 0.05\n",
target=hash_to_bytes("af3f6a43eaf4b26dbcadb1101e8d81db6d6151e0"),
target_type=ModelObjectType.DIRECTORY,
synthetic=True,
author=Person(
fullname=b"Josh Jore <jjore@cpan.org>",
name=b"Josh Jore",
email=b"jjore@cpan.org",
),
date=TimestampWithTimezone.from_iso8601("2011-06-11T05:23:31+00:00"),
id=hash_to_bytes(expected_head_release),
)
assert_last_visit_matches(
storage,
url=ORIGIN_URL,
status="full",
type="cpan",
snapshot=expected_snapshot.id,
)
release_swhid = CoreSWHID(object_type=ObjectType.RELEASE, object_id=head_release.id)
directory_swhid = ExtendedSWHID(
object_type=ExtendedObjectType.DIRECTORY, object_id=head_release.target
)
expected_metadata = [
RawExtrinsicMetadata(
target=directory_swhid,
authority=cpan_loader.get_metadata_authority(),
fetcher=MetadataFetcher(
name="swh.loader.package.cpan.loader.CpanLoader",
version=__version__,
),
discovery_date=cpan_loader.visit_date,
format="origin-artifacts-json",
metadata=head_release_original_artifacts_metadata,
origin=ORIGIN_URL,
release=release_swhid,
),
RawExtrinsicMetadata(
target=directory_swhid,
authority=cpan_loader.get_metadata_authority(),
fetcher=MetadataFetcher(
name="swh.loader.package.cpan.loader.CpanLoader",
version=__version__,
),
discovery_date=cpan_loader.visit_date,
format="cpan-module-json",
metadata=head_release_extrinsic_metadata,
origin=ORIGIN_URL,
release=release_swhid,
),
]
> assert (
cpan_loader.storage.raw_extrinsic_metadata_get(
directory_swhid,
cpan_loader.get_metadata_authority(),
).results
== expected_metadata
)
E assert [RawExtrinsic...d1087d75e5'))] == [RawExtrinsic...d73e313f91'))]
E At index 0 diff: RawExtrinsicMetadata(target=ExtendedSWHID.from_string('swh:1:dir:af3f6a43eaf4b26dbcadb1101e8d81db6d6151e0'), discovery_date=datetime.datetime(2022, 10, 10, 15, 7, 52, tzinfo=datetime.timezone.utc), authority=MetadataAuthority(type=MetadataAuthorityType.FORGE, url='https://metacpan.org/', metadata=None), fetcher=MetadataFetcher(name='swh.loader.package.cpan.loader.CpanLoader', version='4.2.1.dev22+ga38d40a', metadata=None), format='cpan-module-json', metadata=b'{\n "release" : {\n "provides" : "Internals::CountObjects",\n "distribution" : "In...
E
E ...Full output truncated (7 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/loader/package/cpan/tests/test_cpan.py:213: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Oct 10 2022, 5:08 PM