swh_storage = <swh.storage.proxies.retry.RetryingProxyStorage object at 0x7f65cfa46080>
requests_mock = <requests_mock.mocker.Mocker object at 0x7f65cf0b19b0>
data_jar_1 = b'PK\x03\x04\n\x00\x00\x08\x08\x00\xba\\\xb7L\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00META-INF/\x...*\x00\x00al/aldi/sprova4j/models/Execution.javaPK\x05\x06\x00\x00\x00\x00#\x00#\x00\xe2\n\x00\x00\xf4,\x00\x00\x00\x00'
def test_metadatata_no_pom(swh_storage, requests_mock, data_jar_1):
"""With no prior visit, loading a jar ends up with 1 snapshot.
Extrinsic metadata is None if the pom file cannot be retrieved.
"""
requests_mock.get(MVN_ARTIFACTS[0]["url"], content=data_jar_1)
requests_mock.get(MVN_ARTIFACTS_POM[0], status_code="404")
loader = MavenLoader(
swh_storage, MVN_ARTIFACTS[0]["url"], artifacts=[MVN_ARTIFACTS[0]]
)
actual_load_status = loader.load()
assert actual_load_status["status"] == "eventful"
expected_release_id = hash_to_bytes(_expected_new_release_first_visit)
release = swh_storage.release_get([expected_release_id])[0]
assert release is not None
release_swhid = CoreSWHID(
object_type=ObjectType.RELEASE, object_id=expected_release_id
)
directory_swhid = ExtendedSWHID(
object_type=ExtendedObjectType.DIRECTORY, object_id=release.target
)
metadata_authority = MetadataAuthority(
type=MetadataAuthorityType.FORGE, url="https://repo1.maven.org/",
)
expected_metadata = [
RawExtrinsicMetadata(
target=directory_swhid,
authority=metadata_authority,
fetcher=MetadataFetcher(
name="swh.loader.package.maven.loader.MavenLoader", version=__version__,
),
discovery_date=loader.visit_date,
format="maven-pom",
metadata=b"",
origin=MVN_ARTIFACTS[0]["url"],
release=release_swhid,
),
RawExtrinsicMetadata(
target=directory_swhid,
authority=metadata_authority,
fetcher=MetadataFetcher(
name="swh.loader.package.maven.loader.MavenLoader", version=__version__,
),
discovery_date=loader.visit_date,
format="maven-json",
metadata=json.dumps(_expected_json_metadata).encode(),
origin=MVN_ARTIFACTS[0]["url"],
release=release_swhid,
),
]
res = swh_storage.raw_extrinsic_metadata_get(directory_swhid, metadata_authority)
assert res.next_page_token is None
> assert list(res.results) == expected_metadata
E AssertionError: assert [RawExtrinsic...x97C\xe7+mQ')] == [RawExtrinsic...x8981\x00qA')]
E At index 0 diff: RawExtrinsicMetadata(target=ExtendedSWHID(namespace='swh', scheme_version=1, object_id=b'l\x9d\xe4\x1eL\xeb\xb9\x1a\x83h\xda\x1d\x89\xae\x98s\xbdT\x0e\xc3', object_type=<ExtendedObjectType.DIRECTORY: 'dir'>), discovery_date=datetime.datetime(2021, 12, 1, 12, 39, 19, tzinfo=datetime.timezone.utc), authority=MetadataAuthority(type=<MetadataAuthorityType.FORGE: 'forge'>, url='https://repo1.maven.org/', metadata=None), fetcher=MetadataFetcher(name='swh.loader.package.maven.loader.MavenLoader', version='1.1.1.dev8+g72514d2', metadata=None), format='maven-jso...
E
E ...Full output truncated (7 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/loader/package/maven/tests/test_maven.py:532: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Dec 1 2021, 1:39 PM