Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/algos/test_snapshot.py
Show First 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | swh_storage.origin_visit_status_add( | ||||
visit=visit_id, | visit=visit_id, | ||||
date=date_now, | date=date_now, | ||||
status="full", | status="full", | ||||
snapshot=complete_snapshot.id, | snapshot=complete_snapshot.id, | ||||
) | ) | ||||
] | ] | ||||
) | ) | ||||
actual_snapshot = snapshot_get_latest(swh_storage, origin.url) | swh_storage.origin_visit_add( | ||||
assert actual_snapshot is not None | |||||
assert actual_snapshot == complete_snapshot | |||||
swh_storage.origin_visit_status_add( | |||||
[ | [ | ||||
OriginVisitStatus( | OriginVisit( | ||||
origin=origin.url, | origin=origin.url, | ||||
visit=visit_id, | date=now(), | ||||
date=date_now, | type=data.type_visit1, | ||||
status="full", | status="ongoing", | ||||
ardumont: that should go away. | |||||
snapshot=complete_snapshot.id, | snapshot=None, | ||||
) | ) | ||||
] | ] | ||||
) | ) | ||||
actual_snapshot = snapshot_get_latest(swh_storage, origin.url) | actual_snapshot = snapshot_get_latest(swh_storage, origin.url) | ||||
assert actual_snapshot is not None | assert actual_snapshot is not None | ||||
assert actual_snapshot == complete_snapshot | assert actual_snapshot == complete_snapshot | ||||
actual_snapshot = snapshot_get_latest(swh_storage, origin.url, branches_count=1) | actual_snapshot = snapshot_get_latest(swh_storage, origin.url, branches_count=1) | ||||
assert actual_snapshot is not None | assert actual_snapshot is not None | ||||
assert actual_snapshot.id == complete_snapshot.id | assert actual_snapshot.id == complete_snapshot.id | ||||
assert len(actual_snapshot.branches.values()) == 1 | assert len(actual_snapshot.branches.values()) == 1 | ||||
with pytest.raises(ValueError, match="branches_count must be a positive integer"): | with pytest.raises(ValueError, match="branches_count must be a positive integer"): | ||||
snapshot_get_latest(swh_storage, origin.url, branches_count="something-wrong") | snapshot_get_latest(swh_storage, origin.url, branches_count="something-wrong") | ||||
actual_snapshot = snapshot_get_latest(swh_storage, origin.url, branches_count=1) | |||||
assert actual_snapshot is not None | |||||
assert actual_snapshot.id == complete_snapshot.id | |||||
assert len(actual_snapshot.branches.values()) == 1 | |||||
# Last visit does not hold a snapshot so only look back one visit (limit of 1), we | |||||
# found no snapshot | |||||
actual_snapshot = snapshot_get_latest(swh_storage, origin.url, limit=1) | |||||
assert actual_snapshot is None |
that should go away.