Changeset View
Changeset View
Standalone View
Standalone View
swh/fuse/tests/test_revision.py
import json | import json | ||||
import os | import os | ||||
import time | import time | ||||
from swh.fuse.fs.artifact import RevisionHistoryShardByPage | import dateutil.parser | ||||
from swh.fuse.fs.artifact import RevisionHistoryShardByDate, RevisionHistoryShardByPage | |||||
from swh.fuse.tests.api_url import GRAPH_API_REQUEST | from swh.fuse.tests.api_url import GRAPH_API_REQUEST | ||||
from swh.fuse.tests.common import ( | from swh.fuse.tests.common import ( | ||||
check_dir_name_entries, | check_dir_name_entries, | ||||
get_data_from_graph_archive, | get_data_from_graph_archive, | ||||
get_data_from_web_archive, | get_data_from_web_archive, | ||||
) | ) | ||||
from swh.fuse.tests.data.config import REV_SMALL_HISTORY, ROOT_DIR, ROOT_REV | from swh.fuse.tests.data.config import REV_SMALL_HISTORY, ROOT_DIR, ROOT_REV | ||||
from swh.model.identifiers import parse_swhid | from swh.model.identifiers import parse_swhid | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | for idx, swhid in enumerate(expected): | ||||
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 1 second to populate by-date/ dir | # Wait max 1 second to populate by-date/ dir | ||||
for i in range(100): | for i in range(100): | ||||
if ".status" not in os.listdir(dir_by_date): | if ".status" not in os.listdir(dir_by_date): | ||||
break | break | ||||
time.sleep(0.01) | time.sleep(0.01) | ||||
assert os.listdir(dir_by_date) == ["2010"] | for swhid in expected: | ||||
assert os.listdir(dir_by_date / "2010") == ["06"] | meta = get_data_from_web_archive(str(swhid)) | ||||
assert os.listdir(dir_by_date / "2010/06") == ["25", "24", "23", "16"] | 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)) |