fuse_mntdir = PosixPath('/tmp/tmpoqyj7_4e.swh-fuse-test')
def test_list_history(fuse_mntdir):
dir_path = fuse_mntdir / "archive" / REV_SMALL_HISTORY / "history"
assert os.listdir(dir_path) == ["by-date", "by-hash", "by-page"]
history_meta = get_data_from_graph_archive(
REV_SMALL_HISTORY, GRAPH_API_REQUEST.HISTORY
)
history = history_meta.strip()
# Only keep second node in the edge because first node is redundant
# information or the root node (hence not an ancestor)
expected = set(
map(parse_swhid, [edge.split(" ")[1] for edge in history.split("\n")])
)
dir_by_hash = dir_path / "by-hash"
for swhid in expected:
depth1 = swhid.object_id[:2]
depth2 = str(swhid)
assert (dir_by_hash / depth1).exists()
assert depth2 in (os.listdir(dir_by_hash / depth1))
dir_by_page = dir_path / "by-page"
for idx, swhid in enumerate(expected):
page_number = idx // RevisionHistoryShardByPage.PAGE_SIZE
depth1 = RevisionHistoryShardByPage.PAGE_FMT.format(page_number=page_number)
depth2 = str(swhid)
assert (dir_by_page / depth1).exists()
assert depth2 in (os.listdir(dir_by_page / depth1))
dir_by_date = dir_path / "by-date"
# Wait max 3 second to populate by-date/ dir
for i in range(300):
if ".status" not in os.listdir(dir_by_date):
break
time.sleep(0.01)
for swhid in expected:
meta = get_data_from_web_archive(str(swhid))
date = dateutil.parser.parse(meta["date"])
depth1 = RevisionHistoryShardByDate.DATE_FMT.format(
year=date.year, month=date.month, day=date.day
)
depth2 = str(swhid)
assert (dir_by_date / depth1).exists()
> assert depth2 in (os.listdir(dir_by_date / depth1))
E AssertionError: assert 'swh:1:rev:4a1f86ccd7e823f63d12208baef79b1e74479203' in ['swh:1:rev:72c6c60d80cdfe63af5046a1a98549f0515734f2', 'swh:1:rev:c483808e0ff9836bc1cda0ce95d77c8b7d3be91c', 'swh:1:rev:1c60be2f32f70f9181a261ae2c2b4efe353d0f85', 'swh:1:rev:bcf29b882acdf477be412fdb401b0fc2a6c819aa']
E + where ['swh:1:rev:72c6c60d80cdfe63af5046a1a98549f0515734f2', 'swh:1:rev:c483808e0ff9836bc1cda0ce95d77c8b7d3be91c', 'swh:1:rev:1c60be2f32f70f9181a261ae2c2b4efe353d0f85', 'swh:1:rev:bcf29b882acdf477be412fdb401b0fc2a6c819aa'] = <built-in function listdir>((PosixPath('/tmp/tmpoqyj7_4e.swh-fuse-test/archive/swh:1:rev:37426e42cf78a43779312d780eecb21a64006d99/history/by-date') / '2010/06/24/'))
E + where <built-in function listdir> = os.listdir
.tox/py3/lib/python3.7/site-packages/swh/fuse/tests/test_revision.py:88: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Nov 24 2020, 11:21 AM