|
@@ -47,69 +47,28 @@ def test_create_named_pipe_for_dump_does_not_raise():
|
|
module.create_named_pipe_for_dump('/path/to/pipe')
|
|
module.create_named_pipe_for_dump('/path/to/pipe')
|
|
|
|
|
|
|
|
|
|
-def test_remove_database_dumps_removes_dump_for_each_database():
|
|
|
|
- databases = [{'name': 'foo'}, {'name': 'bar'}]
|
|
|
|
- flexmock(module).should_receive('make_database_dump_filename').with_args(
|
|
|
|
- 'databases', 'foo', None
|
|
|
|
- ).and_return('databases/localhost/foo')
|
|
|
|
- flexmock(module).should_receive('make_database_dump_filename').with_args(
|
|
|
|
- 'databases', 'bar', None
|
|
|
|
- ).and_return('databases/localhost/bar')
|
|
|
|
-
|
|
|
|
|
|
+def test_remove_database_dumps_removes_dump_path():
|
|
|
|
+ flexmock(module.os.path).should_receive('expanduser').and_return('databases/localhost')
|
|
flexmock(module.os.path).should_receive('exists').and_return(True)
|
|
flexmock(module.os.path).should_receive('exists').and_return(True)
|
|
- flexmock(module.os.path).should_receive('isdir').and_return(False)
|
|
|
|
- flexmock(module.os).should_receive('remove').with_args('databases/localhost/foo').once()
|
|
|
|
- flexmock(module.os).should_receive('remove').with_args('databases/localhost/bar').once()
|
|
|
|
- flexmock(module.os).should_receive('listdir').with_args('databases/localhost').and_return(
|
|
|
|
- ['bar']
|
|
|
|
- ).and_return([])
|
|
|
|
-
|
|
|
|
- flexmock(module.os).should_receive('rmdir').with_args('databases/localhost').once()
|
|
|
|
-
|
|
|
|
- module.remove_database_dumps('databases', databases, 'SuperDB', 'test.yaml', dry_run=False)
|
|
|
|
|
|
+ flexmock(module.shutil).should_receive('rmtree').with_args('databases/localhost').once()
|
|
|
|
|
|
-
|
|
|
|
-def test_remove_database_dumps_removes_dump_in_directory_format():
|
|
|
|
- databases = [{'name': 'foo'}]
|
|
|
|
- flexmock(module).should_receive('make_database_dump_filename').with_args(
|
|
|
|
- 'databases', 'foo', None
|
|
|
|
- ).and_return('databases/localhost/foo')
|
|
|
|
-
|
|
|
|
- flexmock(module.os.path).should_receive('exists').and_return(True)
|
|
|
|
- flexmock(module.os.path).should_receive('isdir').and_return(True)
|
|
|
|
- flexmock(module.os).should_receive('remove').never()
|
|
|
|
- flexmock(module.shutil).should_receive('rmtree').with_args('databases/localhost/foo').once()
|
|
|
|
- flexmock(module.os).should_receive('listdir').with_args('databases/localhost').and_return([])
|
|
|
|
- flexmock(module.os).should_receive('rmdir').with_args('databases/localhost').once()
|
|
|
|
-
|
|
|
|
- module.remove_database_dumps('databases', databases, 'SuperDB', 'test.yaml', dry_run=False)
|
|
|
|
|
|
+ module.remove_database_dumps('databases', 'SuperDB', 'test.yaml', dry_run=False)
|
|
|
|
|
|
|
|
|
|
def test_remove_database_dumps_with_dry_run_skips_removal():
|
|
def test_remove_database_dumps_with_dry_run_skips_removal():
|
|
- databases = [{'name': 'foo'}, {'name': 'bar'}]
|
|
|
|
- flexmock(module.os).should_receive('rmdir').never()
|
|
|
|
- flexmock(module.os).should_receive('remove').never()
|
|
|
|
-
|
|
|
|
- module.remove_database_dumps('databases', databases, 'SuperDB', 'test.yaml', dry_run=True)
|
|
|
|
|
|
+ flexmock(module.os.path).should_receive('expanduser').and_return('databases/localhost')
|
|
|
|
+ flexmock(module.os.path).should_receive('exists').never()
|
|
|
|
+ flexmock(module.shutil).should_receive('rmtree').never()
|
|
|
|
|
|
|
|
+ module.remove_database_dumps('databases', 'SuperDB', 'test.yaml', dry_run=True)
|
|
|
|
|
|
-def test_remove_database_dumps_without_dump_present_skips_removal():
|
|
|
|
- databases = [{'name': 'foo'}]
|
|
|
|
- flexmock(module).should_receive('make_database_dump_filename').with_args(
|
|
|
|
- 'databases', 'foo', None
|
|
|
|
- ).and_return('databases/localhost/foo')
|
|
|
|
|
|
|
|
|
|
+def test_remove_database_dumps_without_dump_path_present_skips_removal():
|
|
|
|
+ flexmock(module.os.path).should_receive('expanduser').and_return('databases/localhost')
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
flexmock(module.os.path).should_receive('exists').and_return(False)
|
|
- flexmock(module.os.path).should_receive('isdir').never()
|
|
|
|
- flexmock(module.os).should_receive('remove').never()
|
|
|
|
flexmock(module.shutil).should_receive('rmtree').never()
|
|
flexmock(module.shutil).should_receive('rmtree').never()
|
|
- flexmock(module.os).should_receive('rmdir').never()
|
|
|
|
-
|
|
|
|
- module.remove_database_dumps('databases', databases, 'SuperDB', 'test.yaml', dry_run=False)
|
|
|
|
-
|
|
|
|
|
|
|
|
-def test_remove_database_dumps_without_databases_does_not_raise():
|
|
|
|
- module.remove_database_dumps('databases', [], 'SuperDB', 'test.yaml', dry_run=False)
|
|
|
|
|
|
+ module.remove_database_dumps('databases', 'SuperDB', 'test.yaml', dry_run=False)
|
|
|
|
|
|
|
|
|
|
def test_convert_glob_patterns_to_borg_patterns_removes_leading_slash():
|
|
def test_convert_glob_patterns_to_borg_patterns_removes_leading_slash():
|