swh_storage = <swh.storage.proxies.retry.RetryingProxyStorage object at 0x7f461e03e2b0>
requests_mock = <requests_mock.mocker.Mocker object at 0x7f461e1879e8>
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_jar_visit_with_release_artifact_no_prior_visit(
swh_storage, requests_mock, data_jar_1
):
"""With no prior visit, loading a jar ends up with 1 snapshot
"""
requests_mock.get(MVN_ARTIFACTS[0]["url"], content=data_jar_1)
loader = JarLoader(
swh_storage, MVN_ARTIFACTS[0]["url"], artifacts=[MVN_ARTIFACTS[0]]
)
actual_load_status = loader.load()
assert actual_load_status["status"] == "eventful"
expected_snapshot_first_visit_id = hash_to_bytes(
"677b0280cbe9e650c9dfa80fbb1ab7ebb1603c86"
)
expected_snapshot = Snapshot(
id=expected_snapshot_first_visit_id,
branches={
b"HEAD": SnapshotBranch(
target_type=TargetType.ALIAS, target=b"releases/0.1.0",
),
b"releases/0.1.0": SnapshotBranch(
target_type=TargetType.REVISION,
target=hash_to_bytes("b7cd10479d3639a813b444d2ccfbdaa0b2613690"),
),
},
)
> check_snapshot(expected_snapshot, swh_storage)
.tox/py3/lib/python3.7/site-packages/swh/loader/package/jar/tests/test_jar.py:179:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
snapshot = Snapshot(branches=ImmutableDict({b'HEAD': SnapshotBranch(target=b'releases/0.1.0', target_type=<TargetType.ALIAS: 'ali...get_type=<TargetType.REVISION: 'revision'>)}), id=b'g{\x02\x80\xcb\xe9\xe6P\xc9\xdf\xa8\x0f\xbb\x1a\xb7\xeb\xb1`<\x86')
storage = <swh.storage.proxies.retry.RetryingProxyStorage object at 0x7f461e03e2b0>
allowed_empty = []
def check_snapshot(
snapshot: Snapshot,
storage: StorageInterface,
allowed_empty: Iterable[Tuple[TargetType, bytes]] = [],
) -> Snapshot:
"""Check that:
- snapshot exists in the storage and match
- each object reference up to the revision/release targets exists
Args:
snapshot: full snapshot to check for existence and consistency
storage: storage to lookup information into
allowed_empty: Iterable of branch we allow to be empty (some edge case loaders
allows this case to happen, nixguix for example allows the branch evaluation"
to target the nixpkgs git commit reference, which may not yet be resolvable at
loading time)
Returns:
the snapshot stored in the storage for further test assertion if any is
needed.
"""
if not isinstance(snapshot, Snapshot):
raise AssertionError(f"variable 'snapshot' must be a snapshot: {snapshot!r}")
expected_snapshot = snapshot_get_all_branches(storage, snapshot.id)
if expected_snapshot is None:
> raise AssertionError(f"Snapshot {snapshot.id.hex()} is not found")
E AssertionError: Snapshot 677b0280cbe9e650c9dfa80fbb1ab7ebb1603c86 is not found
.tox/py3/lib/python3.7/site-packages/swh/loader/tests/__init__.py:144: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Sep 3 2021, 3:16 PM