From 66e9ec9c3ce4da86c4a147b1f6a03b81aebf9fb7 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Wed, 12 Jun 2019 11:31:46 -0700 Subject: [PATCH] A few tests for JSON flag suppressing Borg output. --- tests/unit/borg/test_create.py | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/unit/borg/test_create.py b/tests/unit/borg/test_create.py index ed50eed..cf6cca6 100644 --- a/tests/unit/borg/test_create.py +++ b/tests/unit/borg/test_create.py @@ -255,6 +255,31 @@ def test_create_archive_with_log_info_calls_borg_with_info_parameter(): ) +def test_create_archive_with_log_info_and_json_suppresses_most_borg_output(): + flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')) + flexmock(module).should_receive('_expand_home_directories').and_return(()) + flexmock(module).should_receive('_write_pattern_file').and_return(None) + flexmock(module).should_receive('_make_pattern_flags').and_return(()) + flexmock(module).should_receive('_make_pattern_flags').and_return(()) + flexmock(module).should_receive('_make_exclude_flags').and_return(()) + flexmock(module).should_receive('execute_command').with_args( + CREATE_COMMAND + ('--json',), capture_output=True + ) + insert_logging_mock(logging.INFO) + + module.create_archive( + dry_run=False, + repository='repo', + location_config={ + 'source_directories': ['foo', 'bar'], + 'repositories': ['repo'], + 'exclude_patterns': None, + }, + storage_config={}, + json=True, + ) + + def test_create_archive_with_log_debug_calls_borg_with_debug_parameter(): flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')) flexmock(module).should_receive('_expand_home_directories').and_return(()) @@ -279,6 +304,30 @@ def test_create_archive_with_log_debug_calls_borg_with_debug_parameter(): ) +def test_create_archive_with_log_debug_and_json_suppresses_most_borg_output(): + flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')) + flexmock(module).should_receive('_expand_home_directories').and_return(()) + flexmock(module).should_receive('_write_pattern_file').and_return(None) + flexmock(module).should_receive('_make_pattern_flags').and_return(()) + flexmock(module).should_receive('_make_exclude_flags').and_return(()) + flexmock(module).should_receive('execute_command').with_args( + CREATE_COMMAND + ('--json',), capture_output=True + ) + insert_logging_mock(logging.DEBUG) + + module.create_archive( + dry_run=False, + repository='repo', + location_config={ + 'source_directories': ['foo', 'bar'], + 'repositories': ['repo'], + 'exclude_patterns': None, + }, + storage_config={}, + json=True, + ) + + def test_create_archive_with_dry_run_calls_borg_with_dry_run_parameter(): flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')) flexmock(module).should_receive('_expand_home_directories').and_return(())