mirror of
https://github.com/borgbackup/borg.git
synced 2026-05-28 04:03:21 -04:00
generate_archiver_tests added: generate tests by specifying kinds of archivers
This commit is contained in:
parent
7f1847ef85
commit
975a094e6e
21 changed files with 92 additions and 45 deletions
|
|
@ -119,10 +119,21 @@ def cmd_fixture(request):
|
|||
return exec_fn
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
def generate_archiver_tests(metafunc, kinds: str):
|
||||
# Generate tests for different scenarios: local repository, remote repository, and using the borg binary.
|
||||
archivers = []
|
||||
for kind in kinds.split(","):
|
||||
if kind == "local":
|
||||
archivers.append("archiver")
|
||||
elif kind == "remote":
|
||||
archivers.append("remote_archiver")
|
||||
elif kind == "binary":
|
||||
archivers.append("binary_archiver")
|
||||
else:
|
||||
raise ValueError(f"Invalid archiver: Expected local, remote, or binary, received {kind}.")
|
||||
|
||||
if "archivers" in metafunc.fixturenames:
|
||||
metafunc.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
|
||||
metafunc.parametrize("archivers", archivers)
|
||||
|
||||
|
||||
def checkts(ts):
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@ from ...helpers import bin_to_hex
|
|||
from ...helpers import msgpack
|
||||
from ...manifest import Manifest
|
||||
from ...repository import Repository
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, src_file, create_src_archive, open_archive, RK_ENCRYPTION
|
||||
from . import cmd, src_file, create_src_archive, open_archive, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def check_cmd_setup(archiver):
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ from ...repository import Repository
|
|||
from .. import llfuse
|
||||
from .. import changedir, environment_variable
|
||||
from . import cmd, _extract_repository_id, open_repository, check_cache, create_test_files, create_src_archive
|
||||
from . import _set_repository_id, create_regular_file, assert_creates_file, RK_ENCRYPTION
|
||||
from . import _set_repository_id, create_regular_file, assert_creates_file, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote") # NOQA
|
||||
|
||||
|
||||
def get_security_directory(repo_path):
|
||||
|
|
@ -42,12 +44,6 @@ def cmd_raises_unknown_feature(archiver, args):
|
|||
assert excinfo.value.args == (["unknown-feature"],)
|
||||
|
||||
|
||||
def pytest_generate_tests(metafunc):
|
||||
# Generate tests for local and remote archivers
|
||||
if "archivers" in metafunc.fixturenames:
|
||||
metafunc.parametrize("archivers", ["archiver", "remote_archiver"])
|
||||
|
||||
|
||||
def test_repository_swap_detection(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
repo_location, repo_path, input_path = archiver.repository_location, archiver.repository_path, archiver.input_path
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from ...constants import * # NOQA
|
||||
from . import RK_ENCRYPTION, create_test_files, cmd
|
||||
from . import RK_ENCRYPTION, create_test_files, cmd, generate_archiver_tests
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,binary") # NOQA
|
||||
|
||||
|
||||
@pytest.mark.parametrize("archivers", ["archiver", "binary_archiver"])
|
||||
def test_config(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
repo_location = archiver.repository_location
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ from .. import (
|
|||
same_ts_ns,
|
||||
is_root,
|
||||
)
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import (
|
||||
cmd,
|
||||
generate_archiver_tests,
|
||||
create_test_files,
|
||||
assert_dirs_equal,
|
||||
create_regular_file,
|
||||
|
|
@ -43,6 +43,9 @@ from . import (
|
|||
RK_ENCRYPTION,
|
||||
)
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_basic_functionality(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ import pstats
|
|||
from ...constants import * # NOQA
|
||||
from .. import changedir
|
||||
from ..compress import Compressor
|
||||
from . import cmd, create_test_files, create_regular_file, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, create_test_files, create_regular_file, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_debug_profile(archivers, request):
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ from ...archive import Archive
|
|||
from ...constants import * # NOQA
|
||||
from ...manifest import Manifest
|
||||
from ...repository import Repository
|
||||
from . import cmd, create_regular_file, src_file, create_src_archive, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, create_regular_file, src_file, create_src_archive, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_delete(archivers, request):
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ import time
|
|||
from ...constants import * # NOQA
|
||||
from .. import are_symlinks_supported, are_hardlinks_supported
|
||||
from ..platform import is_win32, is_darwin
|
||||
from . import cmd, create_regular_file, RK_ENCRYPTION, assert_line_exists
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, create_regular_file, RK_ENCRYPTION, assert_line_exists, generate_archiver_tests
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_basic_functionality(archivers, request):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from ...helpers import flags_noatime, flags_normal
|
|||
from .. import changedir, same_ts_ns
|
||||
from .. import are_symlinks_supported, are_hardlinks_supported, is_utime_fully_supported, is_birthtime_fully_supported
|
||||
from ..platform import is_darwin, is_win32
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import (
|
||||
RK_ENCRYPTION,
|
||||
requires_hardlinks,
|
||||
|
|
@ -24,8 +23,12 @@ from . import (
|
|||
assert_dirs_equal,
|
||||
_extract_hardlinks_setup,
|
||||
assert_creates_file,
|
||||
generate_archiver_tests,
|
||||
)
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
@pytest.mark.skipif(not are_symlinks_supported(), reason="symlinks not supported")
|
||||
def test_symlink_extract(archivers, request):
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import json
|
|||
import os
|
||||
|
||||
from ...constants import * # NOQA
|
||||
from . import cmd, checkts, create_regular_file, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, checkts, create_regular_file, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_info(archivers, request):
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ from ...helpers import msgpack
|
|||
from ...repository import Repository
|
||||
from .. import environment_variable
|
||||
from .. import key
|
||||
from . import RK_ENCRYPTION, KF_ENCRYPTION, cmd, _extract_repository_id, _set_repository_id
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import RK_ENCRYPTION, KF_ENCRYPTION, cmd, _extract_repository_id, _set_repository_id, generate_archiver_tests
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_change_passphrase(archivers, request):
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import json
|
|||
import os
|
||||
|
||||
from ...constants import * # NOQA
|
||||
from . import src_dir, cmd, create_regular_file, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import src_dir, cmd, create_regular_file, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_list_format(archivers, request):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import os
|
||||
|
||||
from ...constants import * # NOQA
|
||||
from . import cmd, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_break_lock(archivers, request):
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ from .. import changedir, no_selinux, same_ts_ns
|
|||
from .. import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported
|
||||
from ..platform import fakeroot_detected
|
||||
from . import RK_ENCRYPTION, cmd, assert_dirs_equal, create_regular_file, create_src_archive, open_archive, src_file
|
||||
from . import requires_hardlinks, _extract_hardlinks_setup, fuse_mount, create_test_files
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import requires_hardlinks, _extract_hardlinks_setup, fuse_mount, create_test_files, generate_archiver_tests
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
@requires_hardlinks
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import re
|
|||
from datetime import datetime
|
||||
|
||||
from ...constants import * # NOQA
|
||||
from . import cmd, RK_ENCRYPTION, src_dir
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, RK_ENCRYPTION, src_dir, generate_archiver_tests
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def _create_archive_ts(archiver, name, y, m, d, H=0, M=0, S=0):
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ from ...constants import * # NOQA
|
|||
from ...crypto.key import FlexiKey
|
||||
from ...repository import Repository
|
||||
from .. import environment_variable
|
||||
from . import cmd, RK_ENCRYPTION, KF_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, generate_archiver_tests, RK_ENCRYPTION, KF_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_rcreate_parent_dirs(archivers, request):
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import pytest
|
|||
|
||||
from ...constants import * # NOQA
|
||||
from .. import changedir, are_hardlinks_supported
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import (
|
||||
_create_test_caches,
|
||||
_create_test_tagged,
|
||||
|
|
@ -15,6 +14,7 @@ from . import (
|
|||
_assert_test_tagged,
|
||||
_assert_test_keep_tagged,
|
||||
_extract_hardlinks_setup,
|
||||
generate_archiver_tests,
|
||||
check_cache,
|
||||
cmd,
|
||||
create_regular_file,
|
||||
|
|
@ -22,6 +22,9 @@ from . import (
|
|||
RK_ENCRYPTION,
|
||||
)
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_recreate_exclude_caches(archivers, request):
|
||||
archiver = request.getfixturevalue(archivers)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import json
|
|||
from random import randbytes
|
||||
|
||||
from ...constants import * # NOQA
|
||||
from . import checkts, cmd, create_regular_file, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import checkts, cmd, create_regular_file, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_info(archivers, request):
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ import json
|
|||
import os
|
||||
|
||||
from ...constants import * # NOQA
|
||||
from . import cmd, checkts, create_src_archive, create_regular_file, src_dir, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, checkts, create_src_archive, create_regular_file, src_dir, generate_archiver_tests, RK_ENCRYPTION
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_rlist_glob(archivers, request):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ import pytest
|
|||
from ...constants import * # NOQA
|
||||
from .. import changedir
|
||||
from . import assert_dirs_equal, _extract_hardlinks_setup, cmd, create_test_files, requires_hardlinks, RK_ENCRYPTION
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import generate_archiver_tests
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def have_gnutar():
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import pytest
|
|||
from ...constants import * # NOQA
|
||||
from ...helpers.time import parse_timestamp
|
||||
from ..platform import is_win32
|
||||
from . import cmd, create_test_files, RK_ENCRYPTION, open_archive
|
||||
from . import pytest_generate_tests # NOQA
|
||||
from . import cmd, create_test_files, RK_ENCRYPTION, open_archive, generate_archiver_tests
|
||||
|
||||
# Tests that include the 'archivers' argument will generate a tests for each kind of archivers specified.
|
||||
pytest_generate_tests = lambda metafunc: generate_archiver_tests(metafunc, kinds="local,remote,binary") # NOQA
|
||||
|
||||
|
||||
def test_transfer(archivers, request):
|
||||
|
|
|
|||
Loading…
Reference in a new issue