| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742 | 
							- import argparse
 
- import logging
 
- import pytest
 
- from flexmock import flexmock
 
- from borgmatic.borg import list as module
 
- from ..test_verbosity import insert_logging_mock
 
- def test_make_list_command_includes_log_info():
 
-     insert_logging_mock(logging.INFO)
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=False),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--info', 'repo')
 
- def test_make_list_command_includes_json_but_not_info():
 
-     insert_logging_mock(logging.INFO)
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=True),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--json', 'repo')
 
- def test_make_list_command_includes_log_debug():
 
-     insert_logging_mock(logging.DEBUG)
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=False),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--debug', '--show-rc', 'repo')
 
- def test_make_list_command_includes_json_but_not_debug():
 
-     insert_logging_mock(logging.DEBUG)
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=True),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--json', 'repo')
 
- def test_make_list_command_includes_json():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=True),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--json', 'repo')
 
- def test_make_list_command_includes_log_json():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(('--log-json',))
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=False),
 
-         global_arguments=flexmock(log_json=True),
 
-     )
 
-     assert command == ('borg', 'list', '--log-json', 'repo')
 
- def test_make_list_command_includes_lock_wait():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(
 
-         ('--lock-wait', '5')
 
-     )
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={'lock_wait': 5},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=False),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--lock-wait', '5', 'repo')
 
- def test_make_list_command_includes_archive():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
 
-         ('repo::archive',)
 
-     )
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive='archive', paths=None, json=False),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', 'repo::archive')
 
- def test_make_list_command_includes_archive_and_path():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
 
-         ('repo::archive',)
 
-     )
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive='archive', paths=['var/lib'], json=False),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', 'repo::archive', 'var/lib')
 
- def test_make_list_command_includes_local_path():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=False),
 
-         global_arguments=flexmock(log_json=False),
 
-         local_path='borg2',
 
-     )
 
-     assert command == ('borg2', 'list', 'repo')
 
- def test_make_list_command_includes_remote_path():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags').with_args(
 
-         'remote-path', 'borg2'
 
-     ).and_return(('--remote-path', 'borg2'))
 
-     flexmock(module.flags).should_receive('make_flags').with_args('log-json', True).and_return(
 
-         ('--log-json')
 
-     )
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=False),
 
-         global_arguments=flexmock(log_json=False),
 
-         remote_path='borg2',
 
-     )
 
-     assert command == ('borg', 'list', '--remote-path', 'borg2', 'repo')
 
- def test_make_list_command_includes_short():
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--short',))
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(archive=None, paths=None, json=False, short=True),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--short', 'repo')
 
- @pytest.mark.parametrize(
 
-     'argument_name',
 
-     (
 
-         'prefix',
 
-         'match_archives',
 
-         'sort_by',
 
-         'first',
 
-         'last',
 
-         'exclude',
 
-         'exclude_from',
 
-         'pattern',
 
-         'patterns_from',
 
-     ),
 
- )
 
- def test_make_list_command_includes_additional_flags(argument_name):
 
-     flexmock(module.flags).should_receive('make_flags').and_return(())
 
-     flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(
 
-         (f"--{argument_name.replace('_', '-')}", 'value')
 
-     )
 
-     flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
 
-     command = module.make_list_command(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=flexmock(
 
-             archive=None,
 
-             paths=None,
 
-             json=False,
 
-             find_paths=None,
 
-             format=None,
 
-             **{argument_name: 'value'},
 
-         ),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
-     assert command == ('borg', 'list', '--' + argument_name.replace('_', '-'), 'value', 'repo')
 
- def test_make_find_paths_considers_none_as_empty_paths():
 
-     assert module.make_find_paths(None) == ()
 
- def test_make_find_paths_passes_through_patterns():
 
-     find_paths = (
 
-         'fm:*',
 
-         'sh:**/*.txt',
 
-         're:^.*$',
 
-         'pp:root/somedir',
 
-         'pf:root/foo.txt',
 
-         'R /',
 
-         'r /',
 
-         'p /',
 
-         'P /',
 
-         '+ /',
 
-         '- /',
 
-         '! /',
 
-     )
 
-     assert module.make_find_paths(find_paths) == find_paths
 
- def test_make_find_paths_adds_globs_to_path_fragments():
 
-     assert module.make_find_paths(('foo.txt',)) == ('sh:**/*foo.txt*/**',)
 
- def test_capture_archive_listing_does_not_raise():
 
-     flexmock(module.environment).should_receive('make_environment')
 
-     flexmock(module).should_receive('execute_command_and_capture_output').and_return('')
 
-     flexmock(module).should_receive('make_list_command')
 
-     module.capture_archive_listing(
 
-         repository_path='repo',
 
-         archive='archive',
 
-         config=flexmock(),
 
-         local_borg_version=flexmock(),
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
- def test_list_archive_calls_borg_with_flags():
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     list_arguments = argparse.Namespace(
 
-         archive='archive',
 
-         paths=None,
 
-         json=False,
 
-         find_paths=None,
 
-         prefix=None,
 
-         match_archives=None,
 
-         sort_by=None,
 
-         first=None,
 
-         last=None,
 
-     )
 
-     global_arguments = flexmock(log_json=False)
 
-     flexmock(module.feature).should_receive('available').and_return(False)
 
-     flexmock(module).should_receive('make_list_command').with_args(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=global_arguments,
 
-         local_path='borg',
 
-         remote_path=None,
 
-     ).and_return(('borg', 'list', 'repo::archive'))
 
-     flexmock(module).should_receive('make_find_paths').and_return(())
 
-     flexmock(module.environment).should_receive('make_environment')
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg', 'list', 'repo::archive'),
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg',
 
-         extra_environment=None,
 
-     ).once()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=global_arguments,
 
-     )
 
- def test_list_archive_with_archive_and_json_errors():
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     list_arguments = argparse.Namespace(archive='archive', paths=None, json=True, find_paths=None)
 
-     flexmock(module.feature).should_receive('available').and_return(False)
 
-     with pytest.raises(ValueError):
 
-         module.list_archive(
 
-             repository_path='repo',
 
-             config={},
 
-             local_borg_version='1.2.3',
 
-             list_arguments=list_arguments,
 
-             global_arguments=flexmock(log_json=False),
 
-         )
 
- def test_list_archive_calls_borg_with_local_path():
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     list_arguments = argparse.Namespace(
 
-         archive='archive',
 
-         paths=None,
 
-         json=False,
 
-         find_paths=None,
 
-         prefix=None,
 
-         match_archives=None,
 
-         sort_by=None,
 
-         first=None,
 
-         last=None,
 
-     )
 
-     global_arguments = flexmock(log_json=False)
 
-     flexmock(module.feature).should_receive('available').and_return(False)
 
-     flexmock(module).should_receive('make_list_command').with_args(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=global_arguments,
 
-         local_path='borg2',
 
-         remote_path=None,
 
-     ).and_return(('borg2', 'list', 'repo::archive'))
 
-     flexmock(module).should_receive('make_find_paths').and_return(())
 
-     flexmock(module.environment).should_receive('make_environment')
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg2', 'list', 'repo::archive'),
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg2',
 
-         extra_environment=None,
 
-     ).once()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=global_arguments,
 
-         local_path='borg2',
 
-     )
 
- def test_list_archive_calls_borg_multiple_times_with_find_paths():
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     glob_paths = ('**/*foo.txt*/**',)
 
-     list_arguments = argparse.Namespace(
 
-         archive=None,
 
-         json=False,
 
-         find_paths=['foo.txt'],
 
-         prefix=None,
 
-         match_archives=None,
 
-         sort_by=None,
 
-         first=None,
 
-         last=None,
 
-     )
 
-     flexmock(module.feature).should_receive('available').and_return(False)
 
-     flexmock(module.rlist).should_receive('make_rlist_command').and_return(('borg', 'list', 'repo'))
 
-     flexmock(module).should_receive('execute_command_and_capture_output').with_args(
 
-         ('borg', 'list', 'repo'),
 
-         extra_environment=None,
 
-         borg_local_path='borg',
 
-     ).and_return('archive1\narchive2').once()
 
-     flexmock(module).should_receive('make_list_command').and_return(
 
-         ('borg', 'list', 'repo::archive1')
 
-     ).and_return(('borg', 'list', 'repo::archive2'))
 
-     flexmock(module).should_receive('make_find_paths').and_return(glob_paths)
 
-     flexmock(module.environment).should_receive('make_environment')
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg', 'list', 'repo::archive1') + glob_paths,
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg',
 
-         extra_environment=None,
 
-     ).once()
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg', 'list', 'repo::archive2') + glob_paths,
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg',
 
-         extra_environment=None,
 
-     ).once()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
- def test_list_archive_calls_borg_with_archive():
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     list_arguments = argparse.Namespace(
 
-         archive='archive',
 
-         paths=None,
 
-         json=False,
 
-         find_paths=None,
 
-         prefix=None,
 
-         match_archives=None,
 
-         sort_by=None,
 
-         first=None,
 
-         last=None,
 
-     )
 
-     global_arguments = flexmock(log_json=False)
 
-     flexmock(module.feature).should_receive('available').and_return(False)
 
-     flexmock(module).should_receive('make_list_command').with_args(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=global_arguments,
 
-         local_path='borg',
 
-         remote_path=None,
 
-     ).and_return(('borg', 'list', 'repo::archive'))
 
-     flexmock(module).should_receive('make_find_paths').and_return(())
 
-     flexmock(module.environment).should_receive('make_environment')
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg', 'list', 'repo::archive'),
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg',
 
-         extra_environment=None,
 
-     ).once()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=global_arguments,
 
-     )
 
- def test_list_archive_without_archive_delegates_to_list_repository():
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     list_arguments = argparse.Namespace(
 
-         archive=None,
 
-         short=None,
 
-         format=None,
 
-         json=None,
 
-         prefix=None,
 
-         match_archives=None,
 
-         sort_by=None,
 
-         first=None,
 
-         last=None,
 
-         find_paths=None,
 
-     )
 
-     flexmock(module.feature).should_receive('available').and_return(False)
 
-     flexmock(module.rlist).should_receive('list_repository')
 
-     flexmock(module.environment).should_receive('make_environment').never()
 
-     flexmock(module).should_receive('execute_command').never()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
- def test_list_archive_with_borg_features_without_archive_delegates_to_list_repository():
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     list_arguments = argparse.Namespace(
 
-         archive=None,
 
-         short=None,
 
-         format=None,
 
-         json=None,
 
-         prefix=None,
 
-         match_archives=None,
 
-         sort_by=None,
 
-         first=None,
 
-         last=None,
 
-         find_paths=None,
 
-     )
 
-     flexmock(module.feature).should_receive('available').and_return(True)
 
-     flexmock(module.rlist).should_receive('list_repository')
 
-     flexmock(module.environment).should_receive('make_environment').never()
 
-     flexmock(module).should_receive('execute_command').never()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=list_arguments,
 
-         global_arguments=flexmock(log_json=False),
 
-     )
 
- @pytest.mark.parametrize(
 
-     'archive_filter_flag',
 
-     (
 
-         'prefix',
 
-         'match_archives',
 
-         'sort_by',
 
-         'first',
 
-         'last',
 
-     ),
 
- )
 
- def test_list_archive_with_archive_ignores_archive_filter_flag(
 
-     archive_filter_flag,
 
- ):
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     global_arguments = flexmock(log_json=False)
 
-     default_filter_flags = {
 
-         'prefix': None,
 
-         'match_archives': None,
 
-         'sort_by': None,
 
-         'first': None,
 
-         'last': None,
 
-     }
 
-     altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
 
-     flexmock(module.feature).should_receive('available').with_args(
 
-         module.feature.Feature.RLIST, '1.2.3'
 
-     ).and_return(False)
 
-     flexmock(module).should_receive('make_list_command').with_args(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=argparse.Namespace(
 
-             archive='archive', paths=None, json=False, find_paths=None, **default_filter_flags
 
-         ),
 
-         global_arguments=global_arguments,
 
-         local_path='borg',
 
-         remote_path=None,
 
-     ).and_return(('borg', 'list', 'repo::archive'))
 
-     flexmock(module).should_receive('make_find_paths').and_return(())
 
-     flexmock(module.environment).should_receive('make_environment')
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg', 'list', 'repo::archive'),
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg',
 
-         extra_environment=None,
 
-     ).once()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=argparse.Namespace(
 
-             archive='archive', paths=None, json=False, find_paths=None, **altered_filter_flags
 
-         ),
 
-         global_arguments=global_arguments,
 
-     )
 
- @pytest.mark.parametrize(
 
-     'archive_filter_flag',
 
-     (
 
-         'prefix',
 
-         'match_archives',
 
-         'sort_by',
 
-         'first',
 
-         'last',
 
-     ),
 
- )
 
- def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes_it_to_rlist(
 
-     archive_filter_flag,
 
- ):
 
-     flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
 
-     flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
 
-     flexmock(module.logger).answer = lambda message: None
 
-     default_filter_flags = {
 
-         'prefix': None,
 
-         'match_archives': None,
 
-         'sort_by': None,
 
-         'first': None,
 
-         'last': None,
 
-     }
 
-     altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
 
-     glob_paths = ('**/*foo.txt*/**',)
 
-     global_arguments = flexmock(log_json=False)
 
-     flexmock(module.feature).should_receive('available').and_return(True)
 
-     flexmock(module.rlist).should_receive('make_rlist_command').with_args(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         rlist_arguments=argparse.Namespace(
 
-             repository='repo', short=True, format=None, json=None, **altered_filter_flags
 
-         ),
 
-         global_arguments=global_arguments,
 
-         local_path='borg',
 
-         remote_path=None,
 
-     ).and_return(('borg', 'rlist', '--repo', 'repo'))
 
-     flexmock(module).should_receive('execute_command_and_capture_output').with_args(
 
-         ('borg', 'rlist', '--repo', 'repo'),
 
-         extra_environment=None,
 
-         borg_local_path='borg',
 
-     ).and_return('archive1\narchive2').once()
 
-     flexmock(module).should_receive('make_list_command').with_args(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=argparse.Namespace(
 
-             repository='repo',
 
-             archive='archive1',
 
-             paths=None,
 
-             short=True,
 
-             format=None,
 
-             json=None,
 
-             find_paths=['foo.txt'],
 
-             **default_filter_flags,
 
-         ),
 
-         global_arguments=global_arguments,
 
-         local_path='borg',
 
-         remote_path=None,
 
-     ).and_return(('borg', 'list', '--repo', 'repo', 'archive1'))
 
-     flexmock(module).should_receive('make_list_command').with_args(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=argparse.Namespace(
 
-             repository='repo',
 
-             archive='archive2',
 
-             paths=None,
 
-             short=True,
 
-             format=None,
 
-             json=None,
 
-             find_paths=['foo.txt'],
 
-             **default_filter_flags,
 
-         ),
 
-         global_arguments=global_arguments,
 
-         local_path='borg',
 
-         remote_path=None,
 
-     ).and_return(('borg', 'list', '--repo', 'repo', 'archive2'))
 
-     flexmock(module).should_receive('make_find_paths').and_return(glob_paths)
 
-     flexmock(module.environment).should_receive('make_environment')
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg', 'list', '--repo', 'repo', 'archive1') + glob_paths,
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg',
 
-         extra_environment=None,
 
-     ).once()
 
-     flexmock(module).should_receive('execute_command').with_args(
 
-         ('borg', 'list', '--repo', 'repo', 'archive2') + glob_paths,
 
-         output_log_level=module.borgmatic.logger.ANSWER,
 
-         borg_local_path='borg',
 
-         extra_environment=None,
 
-     ).once()
 
-     module.list_archive(
 
-         repository_path='repo',
 
-         config={},
 
-         local_borg_version='1.2.3',
 
-         list_arguments=argparse.Namespace(
 
-             repository='repo',
 
-             archive=None,
 
-             paths=None,
 
-             short=True,
 
-             format=None,
 
-             json=None,
 
-             find_paths=['foo.txt'],
 
-             **altered_filter_flags,
 
-         ),
 
-         global_arguments=global_arguments,
 
-     )
 
 
  |