|
@@ -316,6 +316,10 @@ def test_restore_single_dump_extracts_and_restores_single_file_dump():
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
).and_return({'postgresql': flexmock()})
|
|
).and_return({'postgresql': flexmock()})
|
|
|
flexmock(module.tempfile).should_receive('mkdtemp').never()
|
|
flexmock(module.tempfile).should_receive('mkdtemp').never()
|
|
|
flexmock(module.borgmatic.hooks.data_source.dump).should_receive(
|
|
flexmock(module.borgmatic.hooks.data_source.dump).should_receive(
|
|
@@ -360,6 +364,10 @@ def test_restore_single_dump_extracts_and_restores_directory_dump():
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
).and_return({'postgresql': flexmock()})
|
|
).and_return({'postgresql': flexmock()})
|
|
|
flexmock(module.tempfile).should_receive('mkdtemp').once().and_return(
|
|
flexmock(module.tempfile).should_receive('mkdtemp').once().and_return(
|
|
|
'/run/user/0/borgmatic/tmp1234',
|
|
'/run/user/0/borgmatic/tmp1234',
|
|
@@ -406,6 +414,10 @@ def test_restore_single_dump_with_directory_dump_error_cleans_up_temporary_direc
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
).and_return({'postgresql': flexmock()})
|
|
).and_return({'postgresql': flexmock()})
|
|
|
flexmock(module.tempfile).should_receive('mkdtemp').once().and_return(
|
|
flexmock(module.tempfile).should_receive('mkdtemp').once().and_return(
|
|
|
'/run/user/0/borgmatic/tmp1234',
|
|
'/run/user/0/borgmatic/tmp1234',
|
|
@@ -453,6 +465,10 @@ def test_restore_single_dump_with_directory_dump_and_dry_run_skips_directory_mov
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
object,
|
|
object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
|
|
+ object,
|
|
|
).and_return({'postgresql': flexmock()})
|
|
).and_return({'postgresql': flexmock()})
|
|
|
flexmock(module.tempfile).should_receive('mkdtemp').once().and_return('/run/borgmatic/tmp1234')
|
|
flexmock(module.tempfile).should_receive('mkdtemp').once().and_return('/run/borgmatic/tmp1234')
|
|
|
flexmock(module.borgmatic.hooks.data_source.dump).should_receive(
|
|
flexmock(module.borgmatic.hooks.data_source.dump).should_receive(
|
|
@@ -526,7 +542,7 @@ def test_collect_dumps_from_archive_with_dumps_metadata_parses_it():
|
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- assert archive_dumps == set(dumps_metadata)
|
|
|
|
|
|
|
+ assert archive_dumps == tuple(dumps_metadata)
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_collect_dumps_from_archive_with_empty_dumps_metadata_path_falls_back_to_parsing_archive_paths():
|
|
def test_collect_dumps_from_archive_with_empty_dumps_metadata_path_falls_back_to_parsing_archive_paths():
|
|
@@ -564,11 +580,11 @@ def test_collect_dumps_from_archive_with_empty_dumps_metadata_path_falls_back_to
|
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- assert archive_dumps == {
|
|
|
|
|
|
|
+ assert archive_dumps == (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar', 'host', 1234),
|
|
module.Dump('postgresql_databases', 'bar', 'host', 1234),
|
|
|
module.Dump('mysql_databases', 'quux'),
|
|
module.Dump('mysql_databases', 'quux'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_collect_dumps_from_archive_without_dumps_metadata_falls_back_to_parsing_archive_paths():
|
|
def test_collect_dumps_from_archive_without_dumps_metadata_falls_back_to_parsing_archive_paths():
|
|
@@ -606,11 +622,11 @@ def test_collect_dumps_from_archive_without_dumps_metadata_falls_back_to_parsing
|
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- assert archive_dumps == {
|
|
|
|
|
|
|
+ assert archive_dumps == (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar', 'host', 1234),
|
|
module.Dump('postgresql_databases', 'bar', 'host', 1234),
|
|
|
module.Dump('mysql_databases', 'quux'),
|
|
module.Dump('mysql_databases', 'quux'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_collect_dumps_from_archive_parses_archive_paths_with_different_base_directories():
|
|
def test_collect_dumps_from_archive_parses_archive_paths_with_different_base_directories():
|
|
@@ -649,12 +665,12 @@ def test_collect_dumps_from_archive_parses_archive_paths_with_different_base_dir
|
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- assert archive_dumps == {
|
|
|
|
|
|
|
+ assert archive_dumps == (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
module.Dump('postgresql_databases', 'baz'),
|
|
module.Dump('postgresql_databases', 'baz'),
|
|
|
module.Dump('mysql_databases', 'quux'),
|
|
module.Dump('mysql_databases', 'quux'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_collect_dumps_from_archive_parses_directory_format_archive_paths():
|
|
def test_collect_dumps_from_archive_parses_directory_format_archive_paths():
|
|
@@ -691,9 +707,7 @@ def test_collect_dumps_from_archive_parses_directory_format_archive_paths():
|
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- assert archive_dumps == {
|
|
|
|
|
- module.Dump('postgresql_databases', 'foo'),
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ assert archive_dumps == (module.Dump('postgresql_databases', 'foo'),)
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_collect_dumps_from_archive_skips_bad_archive_paths_or_bad_path_components():
|
|
def test_collect_dumps_from_archive_skips_bad_archive_paths_or_bad_path_components():
|
|
@@ -733,18 +747,18 @@ def test_collect_dumps_from_archive_skips_bad_archive_paths_or_bad_path_componen
|
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
borgmatic_runtime_directory='/run/borgmatic',
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- assert archive_dumps == {
|
|
|
|
|
|
|
+ assert archive_dumps == (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_gets_requested_dumps_found_in_archive():
|
|
def test_get_dumps_to_restore_gets_requested_dumps_found_in_archive():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
module.Dump('postgresql_databases', 'baz'),
|
|
module.Dump('postgresql_databases', 'baz'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -777,16 +791,14 @@ def test_get_dumps_to_restore_gets_requested_dumps_found_in_archive():
|
|
|
original_container=None,
|
|
original_container=None,
|
|
|
),
|
|
),
|
|
|
dumps_from_archive=dumps_from_archive,
|
|
dumps_from_archive=dumps_from_archive,
|
|
|
- ) == {
|
|
|
|
|
|
|
+ ) == (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_raises_for_requested_dumps_missing_from_archive():
|
|
def test_get_dumps_to_restore_raises_for_requested_dumps_missing_from_archive():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
- module.Dump('postgresql_databases', 'foo'),
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ dumps_from_archive = (module.Dump('postgresql_databases', 'foo'),)
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -816,10 +828,10 @@ def test_get_dumps_to_restore_raises_for_requested_dumps_missing_from_archive():
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_without_requested_dumps_finds_all_archive_dumps():
|
|
def test_get_dumps_to_restore_without_requested_dumps_finds_all_archive_dumps():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
|
|
|
|
|
assert (
|
|
assert (
|
|
@@ -839,10 +851,10 @@ def test_get_dumps_to_restore_without_requested_dumps_finds_all_archive_dumps():
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_with_all_in_requested_dumps_finds_all_archive_dumps():
|
|
def test_get_dumps_to_restore_with_all_in_requested_dumps_finds_all_archive_dumps():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -882,10 +894,10 @@ def test_get_dumps_to_restore_with_all_in_requested_dumps_finds_all_archive_dump
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_with_all_in_requested_dumps_plus_additional_requested_dumps_omits_duplicates():
|
|
def test_get_dumps_to_restore_with_all_in_requested_dumps_plus_additional_requested_dumps_omits_duplicates():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -958,10 +970,10 @@ def test_get_dumps_to_restore_raises_for_multiple_matching_dumps_in_archive():
|
|
|
original_label=None,
|
|
original_label=None,
|
|
|
original_container=None,
|
|
original_container=None,
|
|
|
),
|
|
),
|
|
|
- dumps_from_archive={
|
|
|
|
|
|
|
+ dumps_from_archive=(
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('mariadb_databases', 'foo'),
|
|
module.Dump('mariadb_databases', 'foo'),
|
|
|
- },
|
|
|
|
|
|
|
+ ),
|
|
|
)
|
|
)
|
|
|
assert 'Try adding flags to disambiguate.' in str(exc_info.value)
|
|
assert 'Try adding flags to disambiguate.' in str(exc_info.value)
|
|
|
|
|
|
|
@@ -990,17 +1002,17 @@ def test_get_dumps_to_restore_raises_for_all_in_requested_dumps_and_requested_du
|
|
|
original_label=None,
|
|
original_label=None,
|
|
|
original_container=None,
|
|
original_container=None,
|
|
|
),
|
|
),
|
|
|
- dumps_from_archive={module.Dump('postgresql_databases', 'foo')},
|
|
|
|
|
|
|
+ dumps_from_archive=(module.Dump('postgresql_databases', 'foo'),),
|
|
|
)
|
|
)
|
|
|
assert 'dump test missing from archive' in str(exc_info.value)
|
|
assert 'dump test missing from archive' in str(exc_info.value)
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_with_requested_hook_name_filters_dumps_found_in_archive():
|
|
def test_get_dumps_to_restore_with_requested_hook_name_filters_dumps_found_in_archive():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('mariadb_databases', 'foo'),
|
|
module.Dump('mariadb_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('sqlite_databases', 'bar'),
|
|
module.Dump('sqlite_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -1023,17 +1035,15 @@ def test_get_dumps_to_restore_with_requested_hook_name_filters_dumps_found_in_ar
|
|
|
original_container=None,
|
|
original_container=None,
|
|
|
),
|
|
),
|
|
|
dumps_from_archive=dumps_from_archive,
|
|
dumps_from_archive=dumps_from_archive,
|
|
|
- ) == {
|
|
|
|
|
- module.Dump('postgresql_databases', 'foo'),
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ) == (module.Dump('postgresql_databases', 'foo'),)
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_with_requested_shortened_hook_name_filters_dumps_found_in_archive():
|
|
def test_get_dumps_to_restore_with_requested_shortened_hook_name_filters_dumps_found_in_archive():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('mariadb_databases', 'foo'),
|
|
module.Dump('mariadb_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('sqlite_databases', 'bar'),
|
|
module.Dump('sqlite_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -1056,17 +1066,15 @@ def test_get_dumps_to_restore_with_requested_shortened_hook_name_filters_dumps_f
|
|
|
original_container=None,
|
|
original_container=None,
|
|
|
),
|
|
),
|
|
|
dumps_from_archive=dumps_from_archive,
|
|
dumps_from_archive=dumps_from_archive,
|
|
|
- ) == {
|
|
|
|
|
- module.Dump('postgresql_databases', 'foo'),
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ) == (module.Dump('postgresql_databases', 'foo'),)
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_with_requested_hostname_filters_dumps_found_in_archive():
|
|
def test_get_dumps_to_restore_with_requested_hostname_filters_dumps_found_in_archive():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
module.Dump('postgresql_databases', 'foo'),
|
|
|
module.Dump('postgresql_databases', 'foo', 'host'),
|
|
module.Dump('postgresql_databases', 'foo', 'host'),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -1089,17 +1097,15 @@ def test_get_dumps_to_restore_with_requested_hostname_filters_dumps_found_in_arc
|
|
|
original_container=None,
|
|
original_container=None,
|
|
|
),
|
|
),
|
|
|
dumps_from_archive=dumps_from_archive,
|
|
dumps_from_archive=dumps_from_archive,
|
|
|
- ) == {
|
|
|
|
|
- module.Dump('postgresql_databases', 'foo', 'host'),
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ) == (module.Dump('postgresql_databases', 'foo', 'host'),)
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_get_dumps_to_restore_with_requested_port_filters_dumps_found_in_archive():
|
|
def test_get_dumps_to_restore_with_requested_port_filters_dumps_found_in_archive():
|
|
|
- dumps_from_archive = {
|
|
|
|
|
|
|
+ dumps_from_archive = (
|
|
|
module.Dump('postgresql_databases', 'foo', 'host'),
|
|
module.Dump('postgresql_databases', 'foo', 'host'),
|
|
|
module.Dump('postgresql_databases', 'foo', 'host', 1234),
|
|
module.Dump('postgresql_databases', 'foo', 'host', 1234),
|
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
module.Dump('postgresql_databases', 'bar'),
|
|
|
- }
|
|
|
|
|
|
|
+ )
|
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
flexmock(module).should_receive('dumps_match').and_return(False)
|
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
flexmock(module).should_receive('dumps_match').with_args(
|
|
|
module.Dump(
|
|
module.Dump(
|
|
@@ -1123,9 +1129,7 @@ def test_get_dumps_to_restore_with_requested_port_filters_dumps_found_in_archive
|
|
|
original_container=None,
|
|
original_container=None,
|
|
|
),
|
|
),
|
|
|
dumps_from_archive=dumps_from_archive,
|
|
dumps_from_archive=dumps_from_archive,
|
|
|
- ) == {
|
|
|
|
|
- module.Dump('postgresql_databases', 'foo', 'host', 1234),
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ) == (module.Dump('postgresql_databases', 'foo', 'host', 1234),)
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_ensure_requested_dumps_restored_with_all_dumps_restored_does_not_raise():
|
|
def test_ensure_requested_dumps_restored_with_all_dumps_restored_does_not_raise():
|