Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/algos/test_snapshot.py
Show First 20 Lines • Show All 129 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 | [OriginVisit(origin=origin.url, date=now(), type=data.type_visit1,)] | ||||
ardumont: that should go away. | |||||
assert actual_snapshot == complete_snapshot | |||||
swh_storage.origin_visit_status_add( | |||||
[ | |||||
OriginVisitStatus( | |||||
origin=origin.url, | |||||
visit=visit_id, | |||||
date=date_now, | |||||
status="full", | |||||
snapshot=complete_snapshot.id, | |||||
) | |||||
] | |||||
) | ) | ||||
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") | ||||
# Last visit has no snapshot so only looking back with a limit of 1 visit, we don't | |||||
# find anything | |||||
actual_snapshot = snapshot_get_latest(swh_storage, origin.url, limit=1) | |||||
assert actual_snapshot is None |
that should go away.