|
@@ -4,69 +4,71 @@ from flexmock import flexmock
|
|
|
import borgmatic.actions.restore as module
|
|
|
|
|
|
|
|
|
-def test_get_configured_database_matches_database_by_name():
|
|
|
- assert module.get_configured_database(
|
|
|
+def test_get_configured_data_source_matches_data_source_by_name():
|
|
|
+ assert module.get_configured_data_source(
|
|
|
config={
|
|
|
'other_databases': [{'name': 'other'}],
|
|
|
'postgresql_databases': [{'name': 'foo'}, {'name': 'bar'}],
|
|
|
},
|
|
|
- archive_database_names={'postgresql_databases': ['other', 'foo', 'bar']},
|
|
|
+ archive_data_source_names={'postgresql_databases': ['other', 'foo', 'bar']},
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='bar',
|
|
|
+ data_source_name='bar',
|
|
|
) == ('postgresql_databases', {'name': 'bar'})
|
|
|
|
|
|
|
|
|
-def test_get_configured_database_matches_nothing_when_nothing_configured():
|
|
|
- assert module.get_configured_database(
|
|
|
+def test_get_configured_data_source_matches_nothing_when_nothing_configured():
|
|
|
+ assert module.get_configured_data_source(
|
|
|
config={},
|
|
|
- archive_database_names={'postgresql_databases': ['foo']},
|
|
|
+ archive_data_source_names={'postgresql_databases': ['foo']},
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='quux',
|
|
|
+ data_source_name='quux',
|
|
|
) == (None, None)
|
|
|
|
|
|
|
|
|
-def test_get_configured_database_matches_nothing_when_database_name_not_configured():
|
|
|
- assert module.get_configured_database(
|
|
|
+def test_get_configured_data_source_matches_nothing_when_data_source_name_not_configured():
|
|
|
+ assert module.get_configured_data_source(
|
|
|
config={'postgresql_databases': [{'name': 'foo'}, {'name': 'bar'}]},
|
|
|
- archive_database_names={'postgresql_databases': ['foo']},
|
|
|
+ archive_data_source_names={'postgresql_databases': ['foo']},
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='quux',
|
|
|
+ data_source_name='quux',
|
|
|
) == (None, None)
|
|
|
|
|
|
|
|
|
-def test_get_configured_database_matches_nothing_when_database_name_not_in_archive():
|
|
|
- assert module.get_configured_database(
|
|
|
+def test_get_configured_data_source_matches_nothing_when_data_source_name_not_in_archive():
|
|
|
+ assert module.get_configured_data_source(
|
|
|
config={'postgresql_databases': [{'name': 'foo'}, {'name': 'bar'}]},
|
|
|
- archive_database_names={'postgresql_databases': ['bar']},
|
|
|
+ archive_data_source_names={'postgresql_databases': ['bar']},
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='foo',
|
|
|
+ data_source_name='foo',
|
|
|
) == (None, None)
|
|
|
|
|
|
|
|
|
-def test_get_configured_database_matches_database_by_configuration_database_name():
|
|
|
- assert module.get_configured_database(
|
|
|
+def test_get_configured_data_source_matches_data_source_by_configuration_data_source_name():
|
|
|
+ assert module.get_configured_data_source(
|
|
|
config={'postgresql_databases': [{'name': 'all'}, {'name': 'bar'}]},
|
|
|
- archive_database_names={'postgresql_databases': ['foo']},
|
|
|
+ archive_data_source_names={'postgresql_databases': ['foo']},
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='foo',
|
|
|
- configuration_database_name='all',
|
|
|
+ data_source_name='foo',
|
|
|
+ configuration_data_source_name='all',
|
|
|
) == ('postgresql_databases', {'name': 'all'})
|
|
|
|
|
|
|
|
|
-def test_get_configured_database_with_unspecified_hook_matches_database_by_name():
|
|
|
- assert module.get_configured_database(
|
|
|
+def test_get_configured_data_source_with_unspecified_hook_matches_data_source_by_name():
|
|
|
+ assert module.get_configured_data_source(
|
|
|
config={
|
|
|
'other_databases': [{'name': 'other'}],
|
|
|
'postgresql_databases': [{'name': 'foo'}, {'name': 'bar'}],
|
|
|
},
|
|
|
- archive_database_names={'postgresql_databases': ['other', 'foo', 'bar']},
|
|
|
+ archive_data_source_names={'postgresql_databases': ['other', 'foo', 'bar']},
|
|
|
hook_name=module.UNSPECIFIED_HOOK,
|
|
|
- database_name='bar',
|
|
|
+ data_source_name='bar',
|
|
|
) == ('postgresql_databases', {'name': 'bar'})
|
|
|
|
|
|
|
|
|
-def test_collect_archive_database_names_parses_archive_paths():
|
|
|
- flexmock(module.borgmatic.hooks.dump).should_receive('make_database_dump_path').and_return('')
|
|
|
+def test_collect_archive_data_source_names_parses_archive_paths():
|
|
|
+ flexmock(module.borgmatic.hooks.dump).should_receive('make_data_source_dump_path').and_return(
|
|
|
+ ''
|
|
|
+ )
|
|
|
flexmock(module.borgmatic.borg.list).should_receive('capture_archive_listing').and_return(
|
|
|
[
|
|
|
'.borgmatic/postgresql_databases/localhost/foo',
|
|
@@ -75,7 +77,7 @@ def test_collect_archive_database_names_parses_archive_paths():
|
|
|
]
|
|
|
)
|
|
|
|
|
|
- archive_database_names = module.collect_archive_database_names(
|
|
|
+ archive_data_source_names = module.collect_archive_data_source_names(
|
|
|
repository={'path': 'repo'},
|
|
|
archive='archive',
|
|
|
config={'borgmatic_source_directory': '.borgmatic'},
|
|
@@ -85,14 +87,16 @@ def test_collect_archive_database_names_parses_archive_paths():
|
|
|
remote_path=flexmock(),
|
|
|
)
|
|
|
|
|
|
- assert archive_database_names == {
|
|
|
+ assert archive_data_source_names == {
|
|
|
'postgresql_databases': ['foo', 'bar'],
|
|
|
'mysql_databases': ['quux'],
|
|
|
}
|
|
|
|
|
|
|
|
|
-def test_collect_archive_database_names_parses_directory_format_archive_paths():
|
|
|
- flexmock(module.borgmatic.hooks.dump).should_receive('make_database_dump_path').and_return('')
|
|
|
+def test_collect_archive_data_source_names_parses_directory_format_archive_paths():
|
|
|
+ flexmock(module.borgmatic.hooks.dump).should_receive('make_data_source_dump_path').and_return(
|
|
|
+ ''
|
|
|
+ )
|
|
|
flexmock(module.borgmatic.borg.list).should_receive('capture_archive_listing').and_return(
|
|
|
[
|
|
|
'.borgmatic/postgresql_databases/localhost/foo/table1',
|
|
@@ -100,7 +104,7 @@ def test_collect_archive_database_names_parses_directory_format_archive_paths():
|
|
|
]
|
|
|
)
|
|
|
|
|
|
- archive_database_names = module.collect_archive_database_names(
|
|
|
+ archive_data_source_names = module.collect_archive_data_source_names(
|
|
|
repository={'path': 'repo'},
|
|
|
archive='archive',
|
|
|
config={'borgmatic_source_directory': '.borgmatic'},
|
|
@@ -110,18 +114,20 @@ def test_collect_archive_database_names_parses_directory_format_archive_paths():
|
|
|
remote_path=flexmock(),
|
|
|
)
|
|
|
|
|
|
- assert archive_database_names == {
|
|
|
+ assert archive_data_source_names == {
|
|
|
'postgresql_databases': ['foo'],
|
|
|
}
|
|
|
|
|
|
|
|
|
-def test_collect_archive_database_names_skips_bad_archive_paths():
|
|
|
- flexmock(module.borgmatic.hooks.dump).should_receive('make_database_dump_path').and_return('')
|
|
|
+def test_collect_archive_data_source_names_skips_bad_archive_paths():
|
|
|
+ flexmock(module.borgmatic.hooks.dump).should_receive('make_data_source_dump_path').and_return(
|
|
|
+ ''
|
|
|
+ )
|
|
|
flexmock(module.borgmatic.borg.list).should_receive('capture_archive_listing').and_return(
|
|
|
['.borgmatic/postgresql_databases/localhost/foo', '.borgmatic/invalid', 'invalid/as/well']
|
|
|
)
|
|
|
|
|
|
- archive_database_names = module.collect_archive_database_names(
|
|
|
+ archive_data_source_names = module.collect_archive_data_source_names(
|
|
|
repository={'path': 'repo'},
|
|
|
archive='archive',
|
|
|
config={'borgmatic_source_directory': '.borgmatic'},
|
|
@@ -131,96 +137,96 @@ def test_collect_archive_database_names_skips_bad_archive_paths():
|
|
|
remote_path=flexmock(),
|
|
|
)
|
|
|
|
|
|
- assert archive_database_names == {
|
|
|
+ assert archive_data_source_names == {
|
|
|
'postgresql_databases': ['foo'],
|
|
|
}
|
|
|
|
|
|
|
|
|
-def test_find_databases_to_restore_passes_through_requested_names_found_in_archive():
|
|
|
- restore_names = module.find_databases_to_restore(
|
|
|
- requested_database_names=['foo', 'bar'],
|
|
|
- archive_database_names={'postresql_databases': ['foo', 'bar', 'baz']},
|
|
|
+def test_find_data_sources_to_restore_passes_through_requested_names_found_in_archive():
|
|
|
+ restore_names = module.find_data_sources_to_restore(
|
|
|
+ requested_data_source_names=['foo', 'bar'],
|
|
|
+ archive_data_source_names={'postresql_databases': ['foo', 'bar', 'baz']},
|
|
|
)
|
|
|
|
|
|
assert restore_names == {module.UNSPECIFIED_HOOK: ['foo', 'bar']}
|
|
|
|
|
|
|
|
|
-def test_find_databases_to_restore_raises_for_requested_names_missing_from_archive():
|
|
|
+def test_find_data_sources_to_restore_raises_for_requested_names_missing_from_archive():
|
|
|
with pytest.raises(ValueError):
|
|
|
- module.find_databases_to_restore(
|
|
|
- requested_database_names=['foo', 'bar'],
|
|
|
- archive_database_names={'postresql_databases': ['foo']},
|
|
|
+ module.find_data_sources_to_restore(
|
|
|
+ requested_data_source_names=['foo', 'bar'],
|
|
|
+ archive_data_source_names={'postresql_databases': ['foo']},
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_find_databases_to_restore_without_requested_names_finds_all_archive_databases():
|
|
|
- archive_database_names = {'postresql_databases': ['foo', 'bar']}
|
|
|
+def test_find_data_sources_to_restore_without_requested_names_finds_all_archive_data_sources():
|
|
|
+ archive_data_source_names = {'postresql_databases': ['foo', 'bar']}
|
|
|
|
|
|
- restore_names = module.find_databases_to_restore(
|
|
|
- requested_database_names=[],
|
|
|
- archive_database_names=archive_database_names,
|
|
|
+ restore_names = module.find_data_sources_to_restore(
|
|
|
+ requested_data_source_names=[],
|
|
|
+ archive_data_source_names=archive_data_source_names,
|
|
|
)
|
|
|
|
|
|
- assert restore_names == archive_database_names
|
|
|
+ assert restore_names == archive_data_source_names
|
|
|
|
|
|
|
|
|
-def test_find_databases_to_restore_with_all_in_requested_names_finds_all_archive_databases():
|
|
|
- archive_database_names = {'postresql_databases': ['foo', 'bar']}
|
|
|
+def test_find_data_sources_to_restore_with_all_in_requested_names_finds_all_archive_data_sources():
|
|
|
+ archive_data_source_names = {'postresql_databases': ['foo', 'bar']}
|
|
|
|
|
|
- restore_names = module.find_databases_to_restore(
|
|
|
- requested_database_names=['all'],
|
|
|
- archive_database_names=archive_database_names,
|
|
|
+ restore_names = module.find_data_sources_to_restore(
|
|
|
+ requested_data_source_names=['all'],
|
|
|
+ archive_data_source_names=archive_data_source_names,
|
|
|
)
|
|
|
|
|
|
- assert restore_names == archive_database_names
|
|
|
+ assert restore_names == archive_data_source_names
|
|
|
|
|
|
|
|
|
-def test_find_databases_to_restore_with_all_in_requested_names_plus_additional_requested_names_omits_duplicates():
|
|
|
- archive_database_names = {'postresql_databases': ['foo', 'bar']}
|
|
|
+def test_find_data_sources_to_restore_with_all_in_requested_names_plus_additional_requested_names_omits_duplicates():
|
|
|
+ archive_data_source_names = {'postresql_databases': ['foo', 'bar']}
|
|
|
|
|
|
- restore_names = module.find_databases_to_restore(
|
|
|
- requested_database_names=['all', 'foo', 'bar'],
|
|
|
- archive_database_names=archive_database_names,
|
|
|
+ restore_names = module.find_data_sources_to_restore(
|
|
|
+ requested_data_source_names=['all', 'foo', 'bar'],
|
|
|
+ archive_data_source_names=archive_data_source_names,
|
|
|
)
|
|
|
|
|
|
- assert restore_names == archive_database_names
|
|
|
+ assert restore_names == archive_data_source_names
|
|
|
|
|
|
|
|
|
-def test_find_databases_to_restore_raises_for_all_in_requested_names_and_requested_named_missing_from_archives():
|
|
|
+def test_find_data_sources_to_restore_raises_for_all_in_requested_names_and_requested_named_missing_from_archives():
|
|
|
with pytest.raises(ValueError):
|
|
|
- module.find_databases_to_restore(
|
|
|
- requested_database_names=['all', 'foo', 'bar'],
|
|
|
- archive_database_names={'postresql_databases': ['foo']},
|
|
|
+ module.find_data_sources_to_restore(
|
|
|
+ requested_data_source_names=['all', 'foo', 'bar'],
|
|
|
+ archive_data_source_names={'postresql_databases': ['foo']},
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_ensure_databases_found_with_all_databases_found_does_not_raise():
|
|
|
- module.ensure_databases_found(
|
|
|
+def test_ensure_data_sources_found_with_all_data_sources_found_does_not_raise():
|
|
|
+ module.ensure_data_sources_found(
|
|
|
restore_names={'postgresql_databases': ['foo']},
|
|
|
remaining_restore_names={'postgresql_databases': ['bar']},
|
|
|
found_names=['foo', 'bar'],
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_ensure_databases_found_with_no_databases_raises():
|
|
|
+def test_ensure_data_sources_found_with_no_data_sources_raises():
|
|
|
with pytest.raises(ValueError):
|
|
|
- module.ensure_databases_found(
|
|
|
+ module.ensure_data_sources_found(
|
|
|
restore_names={'postgresql_databases': []},
|
|
|
remaining_restore_names={},
|
|
|
found_names=[],
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_ensure_databases_found_with_missing_databases_raises():
|
|
|
+def test_ensure_data_sources_found_with_missing_data_sources_raises():
|
|
|
with pytest.raises(ValueError):
|
|
|
- module.ensure_databases_found(
|
|
|
+ module.ensure_data_sources_found(
|
|
|
restore_names={'postgresql_databases': ['foo']},
|
|
|
remaining_restore_names={'postgresql_databases': ['bar']},
|
|
|
found_names=['foo'],
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_run_restore_restores_each_database():
|
|
|
+def test_run_restore_restores_each_data_source():
|
|
|
restore_names = {
|
|
|
'postgresql_databases': ['foo', 'bar'],
|
|
|
}
|
|
@@ -230,12 +236,12 @@ def test_run_restore_restores_each_database():
|
|
|
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
|
|
|
flexmock()
|
|
|
)
|
|
|
- flexmock(module).should_receive('collect_archive_database_names').and_return(flexmock())
|
|
|
- flexmock(module).should_receive('find_databases_to_restore').and_return(restore_names)
|
|
|
- flexmock(module).should_receive('get_configured_database').and_return(
|
|
|
+ flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())
|
|
|
+ flexmock(module).should_receive('find_data_sources_to_restore').and_return(restore_names)
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').and_return(
|
|
|
('postgresql_databases', {'name': 'foo'})
|
|
|
).and_return(('postgresql_databases', {'name': 'bar'}))
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -244,10 +250,10 @@ def test_run_restore_restores_each_database():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database={'name': 'foo', 'schemas': None},
|
|
|
+ data_source={'name': 'foo', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).once()
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -256,10 +262,10 @@ def test_run_restore_restores_each_database():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database={'name': 'bar', 'schemas': None},
|
|
|
+ data_source={'name': 'bar', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).once()
|
|
|
- flexmock(module).should_receive('ensure_databases_found')
|
|
|
+ flexmock(module).should_receive('ensure_data_sources_found')
|
|
|
|
|
|
module.run_restore(
|
|
|
repository={'path': 'repo'},
|
|
@@ -268,7 +274,7 @@ def test_run_restore_restores_each_database():
|
|
|
restore_arguments=flexmock(
|
|
|
repository='repo',
|
|
|
archive='archive',
|
|
|
- databases=flexmock(),
|
|
|
+ data_sources=flexmock(),
|
|
|
schemas=None,
|
|
|
hostname=None,
|
|
|
port=None,
|
|
@@ -289,20 +295,20 @@ def test_run_restore_bails_for_non_matching_repository():
|
|
|
flexmock(module.borgmatic.hooks.dispatch).should_receive(
|
|
|
'call_hooks_even_if_unconfigured'
|
|
|
).never()
|
|
|
- flexmock(module).should_receive('restore_single_database').never()
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').never()
|
|
|
|
|
|
module.run_restore(
|
|
|
repository={'path': 'repo'},
|
|
|
config=flexmock(),
|
|
|
local_borg_version=flexmock(),
|
|
|
- restore_arguments=flexmock(repository='repo', archive='archive', databases=flexmock()),
|
|
|
+ restore_arguments=flexmock(repository='repo', archive='archive', data_sources=flexmock()),
|
|
|
global_arguments=flexmock(dry_run=False),
|
|
|
local_path=flexmock(),
|
|
|
remote_path=flexmock(),
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_run_restore_restores_database_configured_with_all_name():
|
|
|
+def test_run_restore_restores_data_source_configured_with_all_name():
|
|
|
restore_names = {
|
|
|
'postgresql_databases': ['foo', 'bar'],
|
|
|
}
|
|
@@ -312,28 +318,28 @@ def test_run_restore_restores_database_configured_with_all_name():
|
|
|
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
|
|
|
flexmock()
|
|
|
)
|
|
|
- flexmock(module).should_receive('collect_archive_database_names').and_return(flexmock())
|
|
|
- flexmock(module).should_receive('find_databases_to_restore').and_return(restore_names)
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())
|
|
|
+ flexmock(module).should_receive('find_data_sources_to_restore').and_return(restore_names)
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='foo',
|
|
|
+ data_source_name='foo',
|
|
|
).and_return(('postgresql_databases', {'name': 'foo'}))
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='bar',
|
|
|
+ data_source_name='bar',
|
|
|
).and_return((None, None))
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='bar',
|
|
|
- configuration_database_name='all',
|
|
|
+ data_source_name='bar',
|
|
|
+ configuration_data_source_name='all',
|
|
|
).and_return(('postgresql_databases', {'name': 'bar'}))
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -342,10 +348,10 @@ def test_run_restore_restores_database_configured_with_all_name():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database={'name': 'foo', 'schemas': None},
|
|
|
+ data_source={'name': 'foo', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).once()
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -354,10 +360,10 @@ def test_run_restore_restores_database_configured_with_all_name():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database={'name': 'bar', 'schemas': None},
|
|
|
+ data_source={'name': 'bar', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).once()
|
|
|
- flexmock(module).should_receive('ensure_databases_found')
|
|
|
+ flexmock(module).should_receive('ensure_data_sources_found')
|
|
|
|
|
|
module.run_restore(
|
|
|
repository={'path': 'repo'},
|
|
@@ -366,7 +372,7 @@ def test_run_restore_restores_database_configured_with_all_name():
|
|
|
restore_arguments=flexmock(
|
|
|
repository='repo',
|
|
|
archive='archive',
|
|
|
- databases=flexmock(),
|
|
|
+ data_sources=flexmock(),
|
|
|
schemas=None,
|
|
|
hostname=None,
|
|
|
port=None,
|
|
@@ -380,7 +386,7 @@ def test_run_restore_restores_database_configured_with_all_name():
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_run_restore_skips_missing_database():
|
|
|
+def test_run_restore_skips_missing_data_source():
|
|
|
restore_names = {
|
|
|
'postgresql_databases': ['foo', 'bar'],
|
|
|
}
|
|
@@ -390,28 +396,28 @@ def test_run_restore_skips_missing_database():
|
|
|
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
|
|
|
flexmock()
|
|
|
)
|
|
|
- flexmock(module).should_receive('collect_archive_database_names').and_return(flexmock())
|
|
|
- flexmock(module).should_receive('find_databases_to_restore').and_return(restore_names)
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())
|
|
|
+ flexmock(module).should_receive('find_data_sources_to_restore').and_return(restore_names)
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='foo',
|
|
|
+ data_source_name='foo',
|
|
|
).and_return(('postgresql_databases', {'name': 'foo'}))
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='bar',
|
|
|
+ data_source_name='bar',
|
|
|
).and_return((None, None))
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='bar',
|
|
|
- configuration_database_name='all',
|
|
|
+ data_source_name='bar',
|
|
|
+ configuration_data_source_name='all',
|
|
|
).and_return((None, None))
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -420,10 +426,10 @@ def test_run_restore_skips_missing_database():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database={'name': 'foo', 'schemas': None},
|
|
|
+ data_source={'name': 'foo', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).once()
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -432,10 +438,10 @@ def test_run_restore_skips_missing_database():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database={'name': 'bar', 'schemas': None},
|
|
|
+ data_source={'name': 'bar', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).never()
|
|
|
- flexmock(module).should_receive('ensure_databases_found')
|
|
|
+ flexmock(module).should_receive('ensure_data_sources_found')
|
|
|
|
|
|
module.run_restore(
|
|
|
repository={'path': 'repo'},
|
|
@@ -444,7 +450,7 @@ def test_run_restore_skips_missing_database():
|
|
|
restore_arguments=flexmock(
|
|
|
repository='repo',
|
|
|
archive='archive',
|
|
|
- databases=flexmock(),
|
|
|
+ data_sources=flexmock(),
|
|
|
schemas=None,
|
|
|
hostname=None,
|
|
|
port=None,
|
|
@@ -458,7 +464,7 @@ def test_run_restore_skips_missing_database():
|
|
|
)
|
|
|
|
|
|
|
|
|
-def test_run_restore_restores_databases_from_different_hooks():
|
|
|
+def test_run_restore_restores_data_sources_from_different_hooks():
|
|
|
restore_names = {
|
|
|
'postgresql_databases': ['foo'],
|
|
|
'mysql_databases': ['bar'],
|
|
@@ -469,21 +475,21 @@ def test_run_restore_restores_databases_from_different_hooks():
|
|
|
flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name').and_return(
|
|
|
flexmock()
|
|
|
)
|
|
|
- flexmock(module).should_receive('collect_archive_database_names').and_return(flexmock())
|
|
|
- flexmock(module).should_receive('find_databases_to_restore').and_return(restore_names)
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('collect_archive_data_source_names').and_return(flexmock())
|
|
|
+ flexmock(module).should_receive('find_data_sources_to_restore').and_return(restore_names)
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database_name='foo',
|
|
|
+ data_source_name='foo',
|
|
|
).and_return(('postgresql_databases', {'name': 'foo'}))
|
|
|
- flexmock(module).should_receive('get_configured_database').with_args(
|
|
|
+ flexmock(module).should_receive('get_configured_data_source').with_args(
|
|
|
config=object,
|
|
|
- archive_database_names=object,
|
|
|
+ archive_data_source_names=object,
|
|
|
hook_name='mysql_databases',
|
|
|
- database_name='bar',
|
|
|
+ data_source_name='bar',
|
|
|
).and_return(('mysql_databases', {'name': 'bar'}))
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -492,10 +498,10 @@ def test_run_restore_restores_databases_from_different_hooks():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='postgresql_databases',
|
|
|
- database={'name': 'foo', 'schemas': None},
|
|
|
+ data_source={'name': 'foo', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).once()
|
|
|
- flexmock(module).should_receive('restore_single_database').with_args(
|
|
|
+ flexmock(module).should_receive('restore_single_data_source').with_args(
|
|
|
repository=object,
|
|
|
config=object,
|
|
|
local_borg_version=object,
|
|
@@ -504,10 +510,10 @@ def test_run_restore_restores_databases_from_different_hooks():
|
|
|
remote_path=object,
|
|
|
archive_name=object,
|
|
|
hook_name='mysql_databases',
|
|
|
- database={'name': 'bar', 'schemas': None},
|
|
|
+ data_source={'name': 'bar', 'schemas': None},
|
|
|
connection_params=object,
|
|
|
).once()
|
|
|
- flexmock(module).should_receive('ensure_databases_found')
|
|
|
+ flexmock(module).should_receive('ensure_data_sources_found')
|
|
|
|
|
|
module.run_restore(
|
|
|
repository={'path': 'repo'},
|
|
@@ -516,7 +522,7 @@ def test_run_restore_restores_databases_from_different_hooks():
|
|
|
restore_arguments=flexmock(
|
|
|
repository='repo',
|
|
|
archive='archive',
|
|
|
- databases=flexmock(),
|
|
|
+ data_sources=flexmock(),
|
|
|
schemas=None,
|
|
|
hostname=None,
|
|
|
port=None,
|