mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-08-02 22:53:01 +02:00
Attempt to use with_args().
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
import logging
|
||||
|
||||
from flexmock import flexmock
|
||||
|
||||
import borgmatic.borg.diff
|
||||
import borgmatic.borg.environment
|
||||
import borgmatic.borg.feature
|
||||
import borgmatic.execute
|
||||
from borgmatic.borg import flags
|
||||
from borgmatic.borg import diff as module
|
||||
|
||||
|
||||
def test_diff_calls_execute_command():
|
||||
flexmock(borgmatic.borg.feature).should_receive('available').and_return(False)
|
||||
flexmock(flags).should_receive('make_repository_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_repository_archive_flags').and_return(())
|
||||
flexmock(borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(False)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive(
|
||||
'make_repository_archive_flags'
|
||||
).and_return(())
|
||||
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
flexmock(name='test')
|
||||
)
|
||||
flexmock(borgmatic.execute).should_receive('execute_command').once()
|
||||
flexmock(borgmatic.borg.environment).should_receive('make_environment').and_return({})
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').once()
|
||||
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return({})
|
||||
|
||||
borgmatic.borg.diff.diff(
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
archive='archive',
|
||||
config={},
|
||||
@@ -38,17 +38,19 @@ def test_diff_calls_execute_command():
|
||||
|
||||
|
||||
def test_diff_with_numeric_ids_flag():
|
||||
flexmock(borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(flags).should_receive('make_repository_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_repository_archive_flags').and_return(())
|
||||
flexmock(borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive(
|
||||
'make_repository_archive_flags'
|
||||
).and_return(())
|
||||
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
flexmock(name='test')
|
||||
)
|
||||
flexmock(borgmatic.execute).should_receive('execute_command').once()
|
||||
flexmock(borgmatic.borg.environment).should_receive('make_environment').and_return({})
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').once()
|
||||
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return({})
|
||||
|
||||
borgmatic.borg.diff.diff(
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
archive='archive',
|
||||
config={'numeric_ids': True},
|
||||
@@ -68,17 +70,19 @@ def test_diff_with_numeric_ids_flag():
|
||||
|
||||
|
||||
def test_diff_with_numeric_ids_flag_false():
|
||||
flexmock(borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(flags).should_receive('make_repository_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_repository_archive_flags').and_return(())
|
||||
flexmock(borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive(
|
||||
'make_repository_archive_flags'
|
||||
).and_return(())
|
||||
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
flexmock(name='test')
|
||||
)
|
||||
flexmock(borgmatic.execute).should_receive('execute_command').once()
|
||||
flexmock(borgmatic.borg.environment).should_receive('make_environment').and_return({})
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').once()
|
||||
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return({})
|
||||
|
||||
borgmatic.borg.diff.diff(
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
archive='archive',
|
||||
config={'numeric_ids': False},
|
||||
@@ -98,17 +102,45 @@ def test_diff_with_numeric_ids_flag_false():
|
||||
|
||||
|
||||
def test_diff_with_only_patterns():
|
||||
flexmock(borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
flexmock(flags).should_receive('make_repository_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(flags).should_receive('make_repository_archive_flags').and_return(())
|
||||
flexmock(borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
flexmock(name='test')
|
||||
)
|
||||
flexmock(borgmatic.execute).should_receive('execute_command').once()
|
||||
flexmock(borgmatic.borg.environment).should_receive('make_environment').and_return({})
|
||||
# Mock the feature check
|
||||
flexmock(module.borgmatic.borg.feature).should_receive('available').and_return(True)
|
||||
|
||||
borgmatic.borg.diff.diff(
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_repository_flags').and_return(
|
||||
('--repo', 'repo')
|
||||
)
|
||||
flexmock(module.borgmatic.borg.flags).should_receive('make_match_archives_flags').and_return(())
|
||||
flexmock(module.borgmatic.borg.flags).should_receive(
|
||||
'make_repository_archive_flags'
|
||||
).and_return(())
|
||||
|
||||
environment = flexmock()
|
||||
flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
|
||||
environment
|
||||
)
|
||||
|
||||
flexmock(module.borgmatic.borg.pattern).should_receive('write_patterns_file').and_return(
|
||||
'/tmp/test_patterns'
|
||||
)
|
||||
|
||||
expected_command = (
|
||||
'borg',
|
||||
'diff',
|
||||
'--log-json', # Add this flag
|
||||
'--repo',
|
||||
'repo',
|
||||
None,
|
||||
)
|
||||
|
||||
flexmock(module.borgmatic.execute).should_receive('execute_command').with_args(
|
||||
full_command=expected_command,
|
||||
output_log_level=logging.ANSWER,
|
||||
environment=environment,
|
||||
working_directory=None,
|
||||
borg_local_path='borg',
|
||||
borg_exit_codes=None,
|
||||
).once()
|
||||
|
||||
module.borgmatic.borg.diff.diff(
|
||||
repository='repo',
|
||||
archive='archive',
|
||||
config={},
|
||||
|
||||
Reference in New Issue
Block a user