test_list.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. import argparse
  2. import logging
  3. import pytest
  4. from flexmock import flexmock
  5. from borgmatic.borg import list as module
  6. from ..test_verbosity import insert_logging_mock
  7. def test_make_list_command_includes_log_info():
  8. insert_logging_mock(logging.INFO)
  9. flexmock(module.flags).should_receive('make_flags').and_return(())
  10. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
  11. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  12. command = module.make_list_command(
  13. repository_path='repo',
  14. storage_config={},
  15. local_borg_version='1.2.3',
  16. list_arguments=flexmock(archive=None, paths=None, json=False),
  17. )
  18. assert command == ('borg', 'list', '--info', 'repo')
  19. def test_make_list_command_includes_json_but_not_info():
  20. insert_logging_mock(logging.INFO)
  21. flexmock(module.flags).should_receive('make_flags').and_return(())
  22. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
  23. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  24. command = module.make_list_command(
  25. repository_path='repo',
  26. storage_config={},
  27. local_borg_version='1.2.3',
  28. list_arguments=flexmock(archive=None, paths=None, json=True),
  29. )
  30. assert command == ('borg', 'list', '--json', 'repo')
  31. def test_make_list_command_includes_log_debug():
  32. insert_logging_mock(logging.DEBUG)
  33. flexmock(module.flags).should_receive('make_flags').and_return(())
  34. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
  35. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  36. command = module.make_list_command(
  37. repository_path='repo',
  38. storage_config={},
  39. local_borg_version='1.2.3',
  40. list_arguments=flexmock(archive=None, paths=None, json=False),
  41. )
  42. assert command == ('borg', 'list', '--debug', '--show-rc', 'repo')
  43. def test_make_list_command_includes_json_but_not_debug():
  44. insert_logging_mock(logging.DEBUG)
  45. flexmock(module.flags).should_receive('make_flags').and_return(())
  46. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
  47. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  48. command = module.make_list_command(
  49. repository_path='repo',
  50. storage_config={},
  51. local_borg_version='1.2.3',
  52. list_arguments=flexmock(archive=None, paths=None, json=True),
  53. )
  54. assert command == ('borg', 'list', '--json', 'repo')
  55. def test_make_list_command_includes_json():
  56. flexmock(module.flags).should_receive('make_flags').and_return(())
  57. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--json',))
  58. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  59. command = module.make_list_command(
  60. repository_path='repo',
  61. storage_config={},
  62. local_borg_version='1.2.3',
  63. list_arguments=flexmock(archive=None, paths=None, json=True),
  64. )
  65. assert command == ('borg', 'list', '--json', 'repo')
  66. def test_make_list_command_includes_lock_wait():
  67. flexmock(module.flags).should_receive('make_flags').and_return(()).and_return(
  68. ('--lock-wait', '5')
  69. )
  70. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
  71. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  72. command = module.make_list_command(
  73. repository_path='repo',
  74. storage_config={'lock_wait': 5},
  75. local_borg_version='1.2.3',
  76. list_arguments=flexmock(archive=None, paths=None, json=False),
  77. )
  78. assert command == ('borg', 'list', '--lock-wait', '5', 'repo')
  79. def test_make_list_command_includes_archive():
  80. flexmock(module.flags).should_receive('make_flags').and_return(())
  81. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
  82. flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
  83. ('repo::archive',)
  84. )
  85. command = module.make_list_command(
  86. repository_path='repo',
  87. storage_config={},
  88. local_borg_version='1.2.3',
  89. list_arguments=flexmock(archive='archive', paths=None, json=False),
  90. )
  91. assert command == ('borg', 'list', 'repo::archive')
  92. def test_make_list_command_includes_archive_and_path():
  93. flexmock(module.flags).should_receive('make_flags').and_return(())
  94. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
  95. flexmock(module.flags).should_receive('make_repository_archive_flags').and_return(
  96. ('repo::archive',)
  97. )
  98. command = module.make_list_command(
  99. repository_path='repo',
  100. storage_config={},
  101. local_borg_version='1.2.3',
  102. list_arguments=flexmock(archive='archive', paths=['var/lib'], json=False),
  103. )
  104. assert command == ('borg', 'list', 'repo::archive', 'var/lib')
  105. def test_make_list_command_includes_local_path():
  106. flexmock(module.flags).should_receive('make_flags').and_return(())
  107. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
  108. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  109. command = module.make_list_command(
  110. repository_path='repo',
  111. storage_config={},
  112. local_borg_version='1.2.3',
  113. list_arguments=flexmock(archive=None, paths=None, json=False),
  114. local_path='borg2',
  115. )
  116. assert command == ('borg2', 'list', 'repo')
  117. def test_make_list_command_includes_remote_path():
  118. flexmock(module.flags).should_receive('make_flags').and_return(
  119. ('--remote-path', 'borg2')
  120. ).and_return(())
  121. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(())
  122. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  123. command = module.make_list_command(
  124. repository_path='repo',
  125. storage_config={},
  126. local_borg_version='1.2.3',
  127. list_arguments=flexmock(archive=None, paths=None, json=False),
  128. remote_path='borg2',
  129. )
  130. assert command == ('borg', 'list', '--remote-path', 'borg2', 'repo')
  131. def test_make_list_command_includes_short():
  132. flexmock(module.flags).should_receive('make_flags').and_return(())
  133. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(('--short',))
  134. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  135. command = module.make_list_command(
  136. repository_path='repo',
  137. storage_config={},
  138. local_borg_version='1.2.3',
  139. list_arguments=flexmock(archive=None, paths=None, json=False, short=True),
  140. )
  141. assert command == ('borg', 'list', '--short', 'repo')
  142. @pytest.mark.parametrize(
  143. 'argument_name',
  144. (
  145. 'prefix',
  146. 'match_archives',
  147. 'sort_by',
  148. 'first',
  149. 'last',
  150. 'exclude',
  151. 'exclude_from',
  152. 'pattern',
  153. 'patterns_from',
  154. ),
  155. )
  156. def test_make_list_command_includes_additional_flags(argument_name):
  157. flexmock(module.flags).should_receive('make_flags').and_return(())
  158. flexmock(module.flags).should_receive('make_flags_from_arguments').and_return(
  159. (f"--{argument_name.replace('_', '-')}", 'value')
  160. )
  161. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  162. command = module.make_list_command(
  163. repository_path='repo',
  164. storage_config={},
  165. local_borg_version='1.2.3',
  166. list_arguments=flexmock(
  167. archive=None,
  168. paths=None,
  169. json=False,
  170. find_paths=None,
  171. format=None,
  172. **{argument_name: 'value'},
  173. ),
  174. )
  175. assert command == ('borg', 'list', '--' + argument_name.replace('_', '-'), 'value', 'repo')
  176. def test_make_find_paths_considers_none_as_empty_paths():
  177. assert module.make_find_paths(None) == ()
  178. def test_make_find_paths_passes_through_patterns():
  179. find_paths = (
  180. 'fm:*',
  181. 'sh:**/*.txt',
  182. 're:^.*$',
  183. 'pp:root/somedir',
  184. 'pf:root/foo.txt',
  185. 'R /',
  186. 'r /',
  187. 'p /',
  188. 'P /',
  189. '+ /',
  190. '- /',
  191. '! /',
  192. )
  193. assert module.make_find_paths(find_paths) == find_paths
  194. def test_make_find_paths_adds_globs_to_path_fragments():
  195. assert module.make_find_paths(('foo.txt',)) == ('sh:**/*foo.txt*/**',)
  196. def test_capture_archive_listing_does_not_raise():
  197. flexmock(module.environment).should_receive('make_environment')
  198. flexmock(module).should_receive('execute_command_and_capture_output').and_return('')
  199. flexmock(module).should_receive('make_list_command')
  200. module.capture_archive_listing(
  201. repository_path='repo',
  202. archive='archive',
  203. storage_config=flexmock(),
  204. local_borg_version=flexmock(),
  205. )
  206. def test_list_archive_calls_borg_with_parameters():
  207. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  208. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  209. flexmock(module.logger).answer = lambda message: None
  210. list_arguments = argparse.Namespace(
  211. archive='archive',
  212. paths=None,
  213. json=False,
  214. find_paths=None,
  215. prefix=None,
  216. match_archives=None,
  217. sort_by=None,
  218. first=None,
  219. last=None,
  220. )
  221. flexmock(module.feature).should_receive('available').and_return(False)
  222. flexmock(module).should_receive('make_list_command').with_args(
  223. repository_path='repo',
  224. storage_config={},
  225. local_borg_version='1.2.3',
  226. list_arguments=list_arguments,
  227. local_path='borg',
  228. remote_path=None,
  229. ).and_return(('borg', 'list', 'repo::archive'))
  230. flexmock(module).should_receive('make_find_paths').and_return(())
  231. flexmock(module.environment).should_receive('make_environment')
  232. flexmock(module).should_receive('execute_command').with_args(
  233. ('borg', 'list', 'repo::archive'),
  234. output_log_level=module.borgmatic.logger.ANSWER,
  235. borg_local_path='borg',
  236. extra_environment=None,
  237. ).once()
  238. module.list_archive(
  239. repository_path='repo',
  240. storage_config={},
  241. local_borg_version='1.2.3',
  242. list_arguments=list_arguments,
  243. )
  244. def test_list_archive_with_archive_and_json_errors():
  245. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  246. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  247. flexmock(module.logger).answer = lambda message: None
  248. list_arguments = argparse.Namespace(archive='archive', paths=None, json=True, find_paths=None)
  249. flexmock(module.feature).should_receive('available').and_return(False)
  250. with pytest.raises(ValueError):
  251. module.list_archive(
  252. repository_path='repo',
  253. storage_config={},
  254. local_borg_version='1.2.3',
  255. list_arguments=list_arguments,
  256. )
  257. def test_list_archive_calls_borg_with_local_path():
  258. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  259. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  260. flexmock(module.logger).answer = lambda message: None
  261. list_arguments = argparse.Namespace(
  262. archive='archive',
  263. paths=None,
  264. json=False,
  265. find_paths=None,
  266. prefix=None,
  267. match_archives=None,
  268. sort_by=None,
  269. first=None,
  270. last=None,
  271. )
  272. flexmock(module.feature).should_receive('available').and_return(False)
  273. flexmock(module).should_receive('make_list_command').with_args(
  274. repository_path='repo',
  275. storage_config={},
  276. local_borg_version='1.2.3',
  277. list_arguments=list_arguments,
  278. local_path='borg2',
  279. remote_path=None,
  280. ).and_return(('borg2', 'list', 'repo::archive'))
  281. flexmock(module).should_receive('make_find_paths').and_return(())
  282. flexmock(module.environment).should_receive('make_environment')
  283. flexmock(module).should_receive('execute_command').with_args(
  284. ('borg2', 'list', 'repo::archive'),
  285. output_log_level=module.borgmatic.logger.ANSWER,
  286. borg_local_path='borg2',
  287. extra_environment=None,
  288. ).once()
  289. module.list_archive(
  290. repository_path='repo',
  291. storage_config={},
  292. local_borg_version='1.2.3',
  293. list_arguments=list_arguments,
  294. local_path='borg2',
  295. )
  296. def test_list_archive_calls_borg_multiple_times_with_find_paths():
  297. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  298. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  299. flexmock(module.logger).answer = lambda message: None
  300. glob_paths = ('**/*foo.txt*/**',)
  301. list_arguments = argparse.Namespace(
  302. archive=None,
  303. json=False,
  304. find_paths=['foo.txt'],
  305. prefix=None,
  306. match_archives=None,
  307. sort_by=None,
  308. first=None,
  309. last=None,
  310. )
  311. flexmock(module.feature).should_receive('available').and_return(False)
  312. flexmock(module.rlist).should_receive('make_rlist_command').and_return(('borg', 'list', 'repo'))
  313. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  314. ('borg', 'list', 'repo'), extra_environment=None,
  315. ).and_return('archive1\narchive2').once()
  316. flexmock(module).should_receive('make_list_command').and_return(
  317. ('borg', 'list', 'repo::archive1')
  318. ).and_return(('borg', 'list', 'repo::archive2'))
  319. flexmock(module).should_receive('make_find_paths').and_return(glob_paths)
  320. flexmock(module.environment).should_receive('make_environment')
  321. flexmock(module).should_receive('execute_command').with_args(
  322. ('borg', 'list', 'repo::archive1') + glob_paths,
  323. output_log_level=module.borgmatic.logger.ANSWER,
  324. borg_local_path='borg',
  325. extra_environment=None,
  326. ).once()
  327. flexmock(module).should_receive('execute_command').with_args(
  328. ('borg', 'list', 'repo::archive2') + glob_paths,
  329. output_log_level=module.borgmatic.logger.ANSWER,
  330. borg_local_path='borg',
  331. extra_environment=None,
  332. ).once()
  333. module.list_archive(
  334. repository_path='repo',
  335. storage_config={},
  336. local_borg_version='1.2.3',
  337. list_arguments=list_arguments,
  338. )
  339. def test_list_archive_calls_borg_with_archive():
  340. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  341. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  342. flexmock(module.logger).answer = lambda message: None
  343. list_arguments = argparse.Namespace(
  344. archive='archive',
  345. paths=None,
  346. json=False,
  347. find_paths=None,
  348. prefix=None,
  349. match_archives=None,
  350. sort_by=None,
  351. first=None,
  352. last=None,
  353. )
  354. flexmock(module.feature).should_receive('available').and_return(False)
  355. flexmock(module).should_receive('make_list_command').with_args(
  356. repository_path='repo',
  357. storage_config={},
  358. local_borg_version='1.2.3',
  359. list_arguments=list_arguments,
  360. local_path='borg',
  361. remote_path=None,
  362. ).and_return(('borg', 'list', 'repo::archive'))
  363. flexmock(module).should_receive('make_find_paths').and_return(())
  364. flexmock(module.environment).should_receive('make_environment')
  365. flexmock(module).should_receive('execute_command').with_args(
  366. ('borg', 'list', 'repo::archive'),
  367. output_log_level=module.borgmatic.logger.ANSWER,
  368. borg_local_path='borg',
  369. extra_environment=None,
  370. ).once()
  371. module.list_archive(
  372. repository_path='repo',
  373. storage_config={},
  374. local_borg_version='1.2.3',
  375. list_arguments=list_arguments,
  376. )
  377. def test_list_archive_without_archive_delegates_to_list_repository():
  378. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  379. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  380. flexmock(module.logger).answer = lambda message: None
  381. list_arguments = argparse.Namespace(
  382. archive=None,
  383. short=None,
  384. format=None,
  385. json=None,
  386. prefix=None,
  387. match_archives=None,
  388. sort_by=None,
  389. first=None,
  390. last=None,
  391. find_paths=None,
  392. )
  393. flexmock(module.feature).should_receive('available').and_return(False)
  394. flexmock(module.rlist).should_receive('list_repository')
  395. flexmock(module.environment).should_receive('make_environment').never()
  396. flexmock(module).should_receive('execute_command').never()
  397. module.list_archive(
  398. repository_path='repo',
  399. storage_config={},
  400. local_borg_version='1.2.3',
  401. list_arguments=list_arguments,
  402. )
  403. def test_list_archive_with_borg_features_without_archive_delegates_to_list_repository():
  404. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  405. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  406. flexmock(module.logger).answer = lambda message: None
  407. list_arguments = argparse.Namespace(
  408. archive=None,
  409. short=None,
  410. format=None,
  411. json=None,
  412. prefix=None,
  413. match_archives=None,
  414. sort_by=None,
  415. first=None,
  416. last=None,
  417. find_paths=None,
  418. )
  419. flexmock(module.feature).should_receive('available').and_return(True)
  420. flexmock(module.rlist).should_receive('list_repository')
  421. flexmock(module.environment).should_receive('make_environment').never()
  422. flexmock(module).should_receive('execute_command').never()
  423. module.list_archive(
  424. repository_path='repo',
  425. storage_config={},
  426. local_borg_version='1.2.3',
  427. list_arguments=list_arguments,
  428. )
  429. @pytest.mark.parametrize(
  430. 'archive_filter_flag', ('prefix', 'match_archives', 'sort_by', 'first', 'last',),
  431. )
  432. def test_list_archive_with_archive_ignores_archive_filter_flag(archive_filter_flag,):
  433. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  434. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  435. flexmock(module.logger).answer = lambda message: None
  436. default_filter_flags = {
  437. 'prefix': None,
  438. 'match_archives': None,
  439. 'sort_by': None,
  440. 'first': None,
  441. 'last': None,
  442. }
  443. altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
  444. flexmock(module.feature).should_receive('available').with_args(
  445. module.feature.Feature.RLIST, '1.2.3'
  446. ).and_return(False)
  447. flexmock(module).should_receive('make_list_command').with_args(
  448. repository_path='repo',
  449. storage_config={},
  450. local_borg_version='1.2.3',
  451. list_arguments=argparse.Namespace(
  452. archive='archive', paths=None, json=False, find_paths=None, **default_filter_flags
  453. ),
  454. local_path='borg',
  455. remote_path=None,
  456. ).and_return(('borg', 'list', 'repo::archive'))
  457. flexmock(module).should_receive('make_find_paths').and_return(())
  458. flexmock(module.environment).should_receive('make_environment')
  459. flexmock(module).should_receive('execute_command').with_args(
  460. ('borg', 'list', 'repo::archive'),
  461. output_log_level=module.borgmatic.logger.ANSWER,
  462. borg_local_path='borg',
  463. extra_environment=None,
  464. ).once()
  465. module.list_archive(
  466. repository_path='repo',
  467. storage_config={},
  468. local_borg_version='1.2.3',
  469. list_arguments=argparse.Namespace(
  470. archive='archive', paths=None, json=False, find_paths=None, **altered_filter_flags
  471. ),
  472. )
  473. @pytest.mark.parametrize(
  474. 'archive_filter_flag', ('prefix', 'match_archives', 'sort_by', 'first', 'last',),
  475. )
  476. def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes_it_to_rlist(
  477. archive_filter_flag,
  478. ):
  479. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  480. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  481. flexmock(module.logger).answer = lambda message: None
  482. default_filter_flags = {
  483. 'prefix': None,
  484. 'match_archives': None,
  485. 'sort_by': None,
  486. 'first': None,
  487. 'last': None,
  488. }
  489. altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
  490. glob_paths = ('**/*foo.txt*/**',)
  491. flexmock(module.feature).should_receive('available').and_return(True)
  492. flexmock(module.rlist).should_receive('make_rlist_command').with_args(
  493. repository_path='repo',
  494. storage_config={},
  495. local_borg_version='1.2.3',
  496. rlist_arguments=argparse.Namespace(
  497. repository='repo', short=True, format=None, json=None, **altered_filter_flags
  498. ),
  499. local_path='borg',
  500. remote_path=None,
  501. ).and_return(('borg', 'rlist', '--repo', 'repo'))
  502. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  503. ('borg', 'rlist', '--repo', 'repo'), extra_environment=None,
  504. ).and_return('archive1\narchive2').once()
  505. flexmock(module).should_receive('make_list_command').with_args(
  506. repository_path='repo',
  507. storage_config={},
  508. local_borg_version='1.2.3',
  509. list_arguments=argparse.Namespace(
  510. repository='repo',
  511. archive='archive1',
  512. paths=None,
  513. short=True,
  514. format=None,
  515. json=None,
  516. find_paths=['foo.txt'],
  517. **default_filter_flags,
  518. ),
  519. local_path='borg',
  520. remote_path=None,
  521. ).and_return(('borg', 'list', '--repo', 'repo', 'archive1'))
  522. flexmock(module).should_receive('make_list_command').with_args(
  523. repository_path='repo',
  524. storage_config={},
  525. local_borg_version='1.2.3',
  526. list_arguments=argparse.Namespace(
  527. repository='repo',
  528. archive='archive2',
  529. paths=None,
  530. short=True,
  531. format=None,
  532. json=None,
  533. find_paths=['foo.txt'],
  534. **default_filter_flags,
  535. ),
  536. local_path='borg',
  537. remote_path=None,
  538. ).and_return(('borg', 'list', '--repo', 'repo', 'archive2'))
  539. flexmock(module).should_receive('make_find_paths').and_return(glob_paths)
  540. flexmock(module.environment).should_receive('make_environment')
  541. flexmock(module).should_receive('execute_command').with_args(
  542. ('borg', 'list', '--repo', 'repo', 'archive1') + glob_paths,
  543. output_log_level=module.borgmatic.logger.ANSWER,
  544. borg_local_path='borg',
  545. extra_environment=None,
  546. ).once()
  547. flexmock(module).should_receive('execute_command').with_args(
  548. ('borg', 'list', '--repo', 'repo', 'archive2') + glob_paths,
  549. output_log_level=module.borgmatic.logger.ANSWER,
  550. borg_local_path='borg',
  551. extra_environment=None,
  552. ).once()
  553. module.list_archive(
  554. repository_path='repo',
  555. storage_config={},
  556. local_borg_version='1.2.3',
  557. list_arguments=argparse.Namespace(
  558. repository='repo',
  559. archive=None,
  560. paths=None,
  561. short=True,
  562. format=None,
  563. json=None,
  564. find_paths=['foo.txt'],
  565. **altered_filter_flags,
  566. ),
  567. )