Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/tests/__init__.py
Show All 38 Lines | ) -> OriginVisitStatus: | ||||
Raises: | Raises: | ||||
AssertionError in case visit or visit status is not found, or any of the type, | AssertionError in case visit or visit status is not found, or any of the type, | ||||
status and snapshot mismatch | status and snapshot mismatch | ||||
Returns: | Returns: | ||||
the visit status for further check during the remaining part of the test. | the visit status for further check during the remaining part of the test. | ||||
""" | """ | ||||
__tracebackhide__ = True # Hide from pytest tracebacks on failure | |||||
visit_status = origin_get_latest_visit_status(storage, url) | visit_status = origin_get_latest_visit_status(storage, url) | ||||
assert visit_status is not None, f"Origin {url} has no visits" | assert visit_status is not None, f"Origin {url} has no visits" | ||||
if type: | if type: | ||||
assert ( | assert ( | ||||
visit_status.type == type | visit_status.type == type | ||||
), f"Visit has type {visit_status.type} instead of {type}" | ), f"Visit has type {visit_status.type} instead of {type}" | ||||
assert ( | assert ( | ||||
visit_status.status == status | visit_status.status == status | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | Args: | ||||
to target the nixpkgs git commit reference, which may not yet be resolvable at | to target the nixpkgs git commit reference, which may not yet be resolvable at | ||||
loading time) | loading time) | ||||
Returns: | Returns: | ||||
the snapshot stored in the storage for further test assertion if any is | the snapshot stored in the storage for further test assertion if any is | ||||
needed. | needed. | ||||
""" | """ | ||||
__tracebackhide__ = True # Hide from pytest tracebacks on failure | |||||
if not isinstance(expected_snapshot, Snapshot): | if not isinstance(expected_snapshot, Snapshot): | ||||
raise AssertionError( | raise AssertionError( | ||||
f"argument 'expected_snapshot' must be a snapshot: {expected_snapshot!r}" | f"argument 'expected_snapshot' must be a snapshot: {expected_snapshot!r}" | ||||
) | ) | ||||
snapshot = snapshot_get_all_branches(storage, expected_snapshot.id) | snapshot = snapshot_get_all_branches(storage, expected_snapshot.id) | ||||
if snapshot is None: | if snapshot is None: | ||||
raise AssertionError(f"Snapshot {expected_snapshot.id.hex()} is not found") | raise AssertionError(f"Snapshot {expected_snapshot.id.hex()} is not found") | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |