Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/svn/tests/test_utils.py
# Copyright (C) 2016-2022 The Software Heritage developers | # Copyright (C) 2016-2022 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 | ||||
import logging | import logging | ||||
import os | import os | ||||
from pathlib import Path | |||||
import pty | import pty | ||||
import shutil | import shutil | ||||
from subprocess import Popen | from subprocess import Popen | ||||
import pytest | import pytest | ||||
from swh.loader.svn import utils | from swh.loader.svn import utils | ||||
Show All 22 Lines | def test_init_svn_repo_from_dump(datadir, tmp_path): | ||||
tmp_repo, repo_path = utils.init_svn_repo_from_dump( | tmp_repo, repo_path = utils.init_svn_repo_from_dump( | ||||
dump_path, gzip=True, cleanup_dump=False, root_dir=tmp_path | dump_path, gzip=True, cleanup_dump=False, root_dir=tmp_path | ||||
) | ) | ||||
assert os.path.exists(dump_path), "Dump path should still exists" | assert os.path.exists(dump_path), "Dump path should still exists" | ||||
assert os.path.exists(repo_path), "Repository should exists" | assert os.path.exists(repo_path), "Repository should exists" | ||||
def test_init_svn_repo_from_dump_svnadmin_error(tmp_path): | |||||
"""svnadmin load error should be reported in exception text""" | |||||
dump_path = os.path.join(tmp_path, "foo") | |||||
Path(dump_path).touch() | |||||
with pytest.raises( | |||||
ValueError, | |||||
match="svnadmin: E200003: Premature end of content data in dumpstream", | |||||
): | |||||
utils.init_svn_repo_from_dump(dump_path, cleanup_dump=False, root_dir=tmp_path) | |||||
def test_init_svn_repo_from_dump_and_cleanup(datadir, tmp_path): | def test_init_svn_repo_from_dump_and_cleanup(datadir, tmp_path): | ||||
"""Mounting svn repository with a dump cleanup after is ok""" | """Mounting svn repository with a dump cleanup after is ok""" | ||||
dump_name = "penguinsdbtools2018.dump.gz" | dump_name = "penguinsdbtools2018.dump.gz" | ||||
dump_ori_path = os.path.join(datadir, dump_name) | dump_ori_path = os.path.join(datadir, dump_name) | ||||
dump_path = os.path.join(tmp_path, dump_name) | dump_path = os.path.join(tmp_path, dump_name) | ||||
shutil.copyfile(dump_ori_path, dump_path) | shutil.copyfile(dump_ori_path, dump_path) | ||||
▲ Show 20 Lines • Show All 375 Lines • Show Last 20 Lines |