|
@@ -19,6 +19,7 @@ from ..repository import Repository, MAGIC
|
|
|
pytestmark = pytest.mark.skipif(attic is None,
|
|
|
reason='cannot find an attic install')
|
|
|
|
|
|
+
|
|
|
def repo_valid(path):
|
|
|
"""
|
|
|
utility function to check if borg can open a repository
|
|
@@ -32,6 +33,7 @@ def repo_valid(path):
|
|
|
repository.close()
|
|
|
return state
|
|
|
|
|
|
+
|
|
|
def key_valid(path):
|
|
|
"""
|
|
|
check that the new keyfile is alright
|
|
@@ -44,6 +46,7 @@ def key_valid(path):
|
|
|
with open(keyfile, 'r') as f:
|
|
|
return f.read().startswith(KeyfileKey.FILE_ID)
|
|
|
|
|
|
+
|
|
|
@pytest.fixture(autouse=True)
|
|
|
def attic_repo(tmpdir):
|
|
|
"""
|
|
@@ -59,6 +62,7 @@ def attic_repo(tmpdir):
|
|
|
attic_repo.close()
|
|
|
return attic_repo
|
|
|
|
|
|
+
|
|
|
@pytest.mark.usefixtures("tmpdir")
|
|
|
def test_convert_segments(tmpdir, attic_repo):
|
|
|
"""test segment conversion
|
|
@@ -80,6 +84,7 @@ def test_convert_segments(tmpdir, attic_repo):
|
|
|
repo.convert_segments(segments, dryrun=False)
|
|
|
assert repo_valid(tmpdir)
|
|
|
|
|
|
+
|
|
|
class MockArgs:
|
|
|
"""
|
|
|
mock attic location
|
|
@@ -90,6 +95,7 @@ class MockArgs:
|
|
|
def __init__(self, path):
|
|
|
self.repository = attic.helpers.Location(path)
|
|
|
|
|
|
+
|
|
|
@pytest.fixture()
|
|
|
def attic_key_file(attic_repo, tmpdir):
|
|
|
"""
|
|
@@ -116,6 +122,7 @@ def attic_key_file(attic_repo, tmpdir):
|
|
|
return attic.key.KeyfileKey.create(attic_repo,
|
|
|
MockArgs(keys_dir))
|
|
|
|
|
|
+
|
|
|
def test_keys(tmpdir, attic_repo, attic_key_file):
|
|
|
"""test key conversion
|
|
|
|
|
@@ -133,6 +140,7 @@ def test_keys(tmpdir, attic_repo, attic_key_file):
|
|
|
AtticRepositoryConverter.convert_keyfiles(keyfile, dryrun=False)
|
|
|
assert key_valid(attic_key_file.path)
|
|
|
|
|
|
+
|
|
|
def test_convert_all(tmpdir, attic_repo, attic_key_file):
|
|
|
"""test all conversion steps
|
|
|
|