Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/tests/algos/test_snapshot.py
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | def test_snapshot_get_latest(swh_storage, sample_data): | ||||
) | ) | ||||
assert actual_snapshot is None | assert actual_snapshot is None | ||||
date_now = now() | date_now = now() | ||||
assert visit2.date < date_now | assert visit2.date < date_now | ||||
swh_storage.origin_visit_status_add( | swh_storage.origin_visit_status_add( | ||||
[ | [ | ||||
OriginVisitStatus( | OriginVisitStatus( | ||||
origin=origin.url, | origin=ov1.origin, | ||||
visit=ov1.visit, | visit=ov1.visit, | ||||
date=date_now, | date=date_now, | ||||
type=ov1.type, | |||||
status="full", | status="full", | ||||
snapshot=complete_snapshot.id, | snapshot=complete_snapshot.id, | ||||
) | ) | ||||
] | ] | ||||
) | ) | ||||
swh_storage.origin_visit_add( | swh_storage.origin_visit_add( | ||||
[OriginVisit(origin=origin.url, date=now(), type=visit1.type,)] | [OriginVisit(origin=origin.url, date=now(), type=visit1.type,)] | ||||
Show All 26 Lines | def test_snapshot_id_get_from_revision(swh_storage, sample_data): | ||||
swh_storage.revision_add([revision1, revision2]) | swh_storage.revision_add([revision1, revision2]) | ||||
empty_snapshot, complete_snapshot = sample_data.snapshots[1:3] | empty_snapshot, complete_snapshot = sample_data.snapshots[1:3] | ||||
swh_storage.snapshot_add([complete_snapshot]) | swh_storage.snapshot_add([complete_snapshot]) | ||||
# Add complete_snapshot to visit1 which targets revision1 | # Add complete_snapshot to visit1 which targets revision1 | ||||
ovs1, ovs2 = [ | ovs1, ovs2 = [ | ||||
OriginVisitStatus( | OriginVisitStatus( | ||||
origin=origin.url, | origin=ov1.origin, | ||||
visit=ov1.visit, | visit=ov1.visit, | ||||
date=date_visit2, | date=date_visit2, | ||||
type=ov1.type, | |||||
status="partial", | status="partial", | ||||
snapshot=complete_snapshot.id, | snapshot=complete_snapshot.id, | ||||
), | ), | ||||
OriginVisitStatus( | OriginVisitStatus( | ||||
origin=origin.url, | origin=ov2.origin, | ||||
visit=ov2.visit, | visit=ov2.visit, | ||||
date=now(), | date=now(), | ||||
type=ov2.type, | |||||
status="full", | status="full", | ||||
snapshot=empty_snapshot.id, | snapshot=empty_snapshot.id, | ||||
), | ), | ||||
] | ] | ||||
swh_storage.origin_visit_status_add([ovs1, ovs2]) | swh_storage.origin_visit_status_add([ovs1, ovs2]) | ||||
assert ov1.date < ov2.date | assert ov1.date < ov2.date | ||||
assert ov2.date < ovs1.date | assert ov2.date < ovs1.date | ||||
Show All 32 Lines | def test_visit_and_snapshot_get_from_revision(swh_storage, sample_data): | ||||
swh_storage.revision_add([revision1, revision2]) | swh_storage.revision_add([revision1, revision2]) | ||||
empty_snapshot, complete_snapshot = sample_data.snapshots[1:3] | empty_snapshot, complete_snapshot = sample_data.snapshots[1:3] | ||||
swh_storage.snapshot_add([complete_snapshot]) | swh_storage.snapshot_add([complete_snapshot]) | ||||
# Add complete_snapshot to visit1 which targets revision1 | # Add complete_snapshot to visit1 which targets revision1 | ||||
ovs1, ovs2 = [ | ovs1, ovs2 = [ | ||||
OriginVisitStatus( | OriginVisitStatus( | ||||
origin=origin.url, | origin=ov1.origin, | ||||
visit=ov1.visit, | visit=ov1.visit, | ||||
date=date_visit2, | date=date_visit2, | ||||
type=ov1.type, | |||||
status="partial", | status="partial", | ||||
snapshot=complete_snapshot.id, | snapshot=complete_snapshot.id, | ||||
), | ), | ||||
OriginVisitStatus( | OriginVisitStatus( | ||||
origin=origin.url, | origin=ov2.origin, | ||||
visit=ov2.visit, | visit=ov2.visit, | ||||
date=now(), | date=now(), | ||||
type=ov2.type, | |||||
status="full", | status="full", | ||||
snapshot=empty_snapshot.id, | snapshot=empty_snapshot.id, | ||||
), | ), | ||||
] | ] | ||||
swh_storage.origin_visit_status_add([ovs1, ovs2]) | swh_storage.origin_visit_status_add([ovs1, ovs2]) | ||||
assert ov1.date < ov2.date | assert ov1.date < ov2.date | ||||
assert ov2.date < ovs1.date | assert ov2.date < ovs1.date | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |