Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/cran/tests/test_cran.py
Show First 20 Lines • Show All 176 Lines • ▼ Show 20 Lines | def test_cran_one_visit(swh_storage, requests_mock_datadir): | ||||
actual_load_status = loader.load() | actual_load_status = loader.load() | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": SNAPSHOT.id.hex(), | "snapshot_id": SNAPSHOT.id.hex(), | ||||
} | } | ||||
check_snapshot(SNAPSHOT, swh_storage) | assert_last_visit_matches( | ||||
swh_storage, origin_url, status="full", type="cran", snapshot=SNAPSHOT.id | |||||
) | |||||
assert_last_visit_matches(swh_storage, origin_url, status="full", type="cran") | check_snapshot(SNAPSHOT, swh_storage) | ||||
visit_stats = get_stats(swh_storage) | visit_stats = get_stats(swh_storage) | ||||
assert { | assert { | ||||
"content": 33, | "content": 33, | ||||
"directory": 7, | "directory": 7, | ||||
"origin": 1, | "origin": 1, | ||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"release": 0, | "release": 0, | ||||
Show All 29 Lines | def test_cran_2_visits_same_origin(swh_storage, requests_mock_datadir): | ||||
expected_snapshot_id = "920adcccc78aaeedd3cfa4459dd900d8c3431a21" | expected_snapshot_id = "920adcccc78aaeedd3cfa4459dd900d8c3431a21" | ||||
assert actual_load_status == { | assert actual_load_status == { | ||||
"status": "eventful", | "status": "eventful", | ||||
"snapshot_id": SNAPSHOT.id.hex(), | "snapshot_id": SNAPSHOT.id.hex(), | ||||
} | } | ||||
check_snapshot(SNAPSHOT, swh_storage) | check_snapshot(SNAPSHOT, swh_storage) | ||||
assert_last_visit_matches(swh_storage, origin_url, status="full", type="cran") | assert_last_visit_matches( | ||||
swh_storage, origin_url, status="full", type="cran", snapshot=SNAPSHOT.id | |||||
) | |||||
visit_stats = get_stats(swh_storage) | visit_stats = get_stats(swh_storage) | ||||
assert { | assert { | ||||
"content": 33, | "content": 33, | ||||
"directory": 7, | "directory": 7, | ||||
"origin": 1, | "origin": 1, | ||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"release": 0, | "release": 0, | ||||
"revision": 1, | "revision": 1, | ||||
"skipped_content": 0, | "skipped_content": 0, | ||||
"snapshot": 1, | "snapshot": 1, | ||||
} == visit_stats | } == visit_stats | ||||
# second visit | # second visit | ||||
actual_load_status2 = loader.load() | actual_load_status2 = loader.load() | ||||
assert actual_load_status2 == { | assert actual_load_status2 == { | ||||
"status": "uneventful", | "status": "uneventful", | ||||
"snapshot_id": expected_snapshot_id, | "snapshot_id": expected_snapshot_id, | ||||
} | } | ||||
assert_last_visit_matches(swh_storage, origin_url, status="full", type="cran") | assert_last_visit_matches( | ||||
swh_storage, | |||||
origin_url, | |||||
status="full", | |||||
type="cran", | |||||
snapshot=hash_to_bytes(expected_snapshot_id), | |||||
) | |||||
visit_stats2 = get_stats(swh_storage) | visit_stats2 = get_stats(swh_storage) | ||||
visit_stats["origin_visit"] += 1 | visit_stats["origin_visit"] += 1 | ||||
assert visit_stats2 == visit_stats, "same stats as 1st visit, +1 visit" | assert visit_stats2 == visit_stats, "same stats as 1st visit, +1 visit" | ||||
urls = [ | urls = [ | ||||
m.url | m.url | ||||
for m in requests_mock_datadir.request_history | for m in requests_mock_datadir.request_history | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | ): | ||||
"origin_visit": 1, | "origin_visit": 1, | ||||
"release": 0, | "release": 0, | ||||
"revision": 1, | "revision": 1, | ||||
"skipped_content": 0, | "skipped_content": 0, | ||||
"snapshot": 1, | "snapshot": 1, | ||||
} == visit_stats | } == visit_stats | ||||
assert_last_visit_matches( | assert_last_visit_matches( | ||||
swh_storage, origin_url, status="partial", type="cran" | swh_storage, origin_url, status="partial", type="cran", snapshot=SNAPSHOT.id | ||||
) | ) |