Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/tests/test_revision.py
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | def test_list_history(fuse_mntdir): | ||||
for idx, swhid in enumerate(expected): | for idx, swhid in enumerate(expected): | ||||
page_number = idx // RevisionHistoryShardByPage.PAGE_SIZE | page_number = idx // RevisionHistoryShardByPage.PAGE_SIZE | ||||
depth1 = RevisionHistoryShardByPage.PAGE_FMT.format(page_number=page_number) | depth1 = RevisionHistoryShardByPage.PAGE_FMT.format(page_number=page_number) | ||||
depth2 = str(swhid) | depth2 = str(swhid) | ||||
assert (dir_by_page / depth1).exists() | assert (dir_by_page / depth1).exists() | ||||
assert depth2 in (os.listdir(dir_by_page / depth1)) | assert depth2 in (os.listdir(dir_by_page / depth1)) | ||||
dir_by_date = dir_path / "by-date" | dir_by_date = dir_path / "by-date" | ||||
# Wait max 3 seconds to populate by-date/ dir | # TODO: rely on .status file instead to wait | ||||
for i in range(300): | # Wait 2 seconds to populate by-date/ dir | ||||
if ".status" not in os.listdir(dir_by_date): | time.sleep(2) | ||||
break | |||||
time.sleep(0.01) | |||||
for swhid in expected: | for swhid in expected: | ||||
meta = get_data_from_web_archive(str(swhid)) | meta = get_data_from_web_archive(str(swhid)) | ||||
date = dateutil.parser.parse(meta["date"]) | date = dateutil.parser.parse(meta["date"]) | ||||
depth1 = RevisionHistoryShardByDate.DATE_FMT.format( | depth1 = RevisionHistoryShardByDate.DATE_FMT.format( | ||||
year=date.year, month=date.month, day=date.day | year=date.year, month=date.month, day=date.day | ||||
) | ) | ||||
depth2 = str(swhid) | depth2 = str(swhid) | ||||
assert (dir_by_date / depth1).exists() | assert (dir_by_date / depth1).exists() | ||||
assert depth2 in (os.listdir(dir_by_date / depth1)) | assert depth2 in (os.listdir(dir_by_date / depth1)) |