Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_loader.py
# Copyright (C) 2016-2021 The Software Heritage developers | # Copyright (C) 2016-2021 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from enum import Enum | from enum import Enum | ||||
from io import BytesIO | from io import BytesIO | ||||
import os | import os | ||||
import shutil | |||||
import subprocess | import subprocess | ||||
from typing import Any, Dict, List | from typing import Any, Dict, List | ||||
import pytest | import pytest | ||||
from subvertpy import SubversionException, delta, repos | from subvertpy import SubversionException, delta, repos | ||||
from subvertpy.ra import Auth, RemoteAccess, get_username_provider | from subvertpy.ra import Auth, RemoteAccess, get_username_provider | ||||
from typing_extensions import TypedDict | from typing_extensions import TypedDict | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | |||||
def test_loader_svnrdump_no_such_revision(swh_storage, tmp_path, datadir): | def test_loader_svnrdump_no_such_revision(swh_storage, tmp_path, datadir): | ||||
"""Visit multiple times an origin with the remote loader should not raise. | """Visit multiple times an origin with the remote loader should not raise. | ||||
It used to fail the ingestion on the second visit with a "No such revision x, | It used to fail the ingestion on the second visit with a "No such revision x, | ||||
160006" message. | 160006" message. | ||||
""" | """ | ||||
archive_ori_dump = os.path.join(datadir, "penguinsdbtools2018.dump.gz") | |||||
archive_dump_dir = os.path.join(tmp_path, "dump") | |||||
os.mkdir(archive_dump_dir) | |||||
archive_dump = os.path.join(archive_dump_dir, "penguinsdbtools2018.dump.gz") | |||||
# loader now drops the dump as soon as it's mounted so we need to make a copy first | |||||
shutil.copyfile(archive_ori_dump, archive_dump) | |||||
archive_dump = os.path.join(datadir, "penguinsdbtools2018.dump.gz") | |||||
loading_path = str(tmp_path / "loading") | loading_path = str(tmp_path / "loading") | ||||
os.mkdir(loading_path) | os.mkdir(loading_path) | ||||
# Prepare the dump as a local svn repository for test purposes | # Prepare the dump as a local svn repository for test purposes | ||||
temp_dir, repo_path = init_svn_repo_from_dump( | temp_dir, repo_path = init_svn_repo_from_dump( | ||||
archive_dump, root_dir=tmp_path, gzip=True | archive_dump, root_dir=tmp_path, gzip=True | ||||
) | ) | ||||
repo_url = f"file://{repo_path}" | repo_url = f"file://{repo_path}" | ||||
▲ Show 20 Lines • Show All 1,139 Lines • Show Last 20 Lines |