test_list.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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'),
  315. extra_environment=None,
  316. ).and_return('archive1\narchive2').once()
  317. flexmock(module).should_receive('make_list_command').and_return(
  318. ('borg', 'list', 'repo::archive1')
  319. ).and_return(('borg', 'list', 'repo::archive2'))
  320. flexmock(module).should_receive('make_find_paths').and_return(glob_paths)
  321. flexmock(module.environment).should_receive('make_environment')
  322. flexmock(module).should_receive('execute_command').with_args(
  323. ('borg', 'list', 'repo::archive1') + glob_paths,
  324. output_log_level=module.borgmatic.logger.ANSWER,
  325. borg_local_path='borg',
  326. extra_environment=None,
  327. ).once()
  328. flexmock(module).should_receive('execute_command').with_args(
  329. ('borg', 'list', 'repo::archive2') + glob_paths,
  330. output_log_level=module.borgmatic.logger.ANSWER,
  331. borg_local_path='borg',
  332. extra_environment=None,
  333. ).once()
  334. module.list_archive(
  335. repository_path='repo',
  336. storage_config={},
  337. local_borg_version='1.2.3',
  338. list_arguments=list_arguments,
  339. )
  340. def test_list_archive_calls_borg_with_archive():
  341. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  342. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  343. flexmock(module.logger).answer = lambda message: None
  344. list_arguments = argparse.Namespace(
  345. archive='archive',
  346. paths=None,
  347. json=False,
  348. find_paths=None,
  349. prefix=None,
  350. match_archives=None,
  351. sort_by=None,
  352. first=None,
  353. last=None,
  354. )
  355. flexmock(module.feature).should_receive('available').and_return(False)
  356. flexmock(module).should_receive('make_list_command').with_args(
  357. repository_path='repo',
  358. storage_config={},
  359. local_borg_version='1.2.3',
  360. list_arguments=list_arguments,
  361. local_path='borg',
  362. remote_path=None,
  363. ).and_return(('borg', 'list', 'repo::archive'))
  364. flexmock(module).should_receive('make_find_paths').and_return(())
  365. flexmock(module.environment).should_receive('make_environment')
  366. flexmock(module).should_receive('execute_command').with_args(
  367. ('borg', 'list', 'repo::archive'),
  368. output_log_level=module.borgmatic.logger.ANSWER,
  369. borg_local_path='borg',
  370. extra_environment=None,
  371. ).once()
  372. module.list_archive(
  373. repository_path='repo',
  374. storage_config={},
  375. local_borg_version='1.2.3',
  376. list_arguments=list_arguments,
  377. )
  378. def test_list_archive_without_archive_delegates_to_list_repository():
  379. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  380. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  381. flexmock(module.logger).answer = lambda message: None
  382. list_arguments = argparse.Namespace(
  383. archive=None,
  384. short=None,
  385. format=None,
  386. json=None,
  387. prefix=None,
  388. match_archives=None,
  389. sort_by=None,
  390. first=None,
  391. last=None,
  392. find_paths=None,
  393. )
  394. flexmock(module.feature).should_receive('available').and_return(False)
  395. flexmock(module.rlist).should_receive('list_repository')
  396. flexmock(module.environment).should_receive('make_environment').never()
  397. flexmock(module).should_receive('execute_command').never()
  398. module.list_archive(
  399. repository_path='repo',
  400. storage_config={},
  401. local_borg_version='1.2.3',
  402. list_arguments=list_arguments,
  403. )
  404. def test_list_archive_with_borg_features_without_archive_delegates_to_list_repository():
  405. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  406. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  407. flexmock(module.logger).answer = lambda message: None
  408. list_arguments = argparse.Namespace(
  409. archive=None,
  410. short=None,
  411. format=None,
  412. json=None,
  413. prefix=None,
  414. match_archives=None,
  415. sort_by=None,
  416. first=None,
  417. last=None,
  418. find_paths=None,
  419. )
  420. flexmock(module.feature).should_receive('available').and_return(True)
  421. flexmock(module.rlist).should_receive('list_repository')
  422. flexmock(module.environment).should_receive('make_environment').never()
  423. flexmock(module).should_receive('execute_command').never()
  424. module.list_archive(
  425. repository_path='repo',
  426. storage_config={},
  427. local_borg_version='1.2.3',
  428. list_arguments=list_arguments,
  429. )
  430. @pytest.mark.parametrize(
  431. 'archive_filter_flag',
  432. (
  433. 'prefix',
  434. 'match_archives',
  435. 'sort_by',
  436. 'first',
  437. 'last',
  438. ),
  439. )
  440. def test_list_archive_with_archive_ignores_archive_filter_flag(
  441. archive_filter_flag,
  442. ):
  443. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  444. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  445. flexmock(module.logger).answer = lambda message: None
  446. default_filter_flags = {
  447. 'prefix': None,
  448. 'match_archives': None,
  449. 'sort_by': None,
  450. 'first': None,
  451. 'last': None,
  452. }
  453. altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
  454. flexmock(module.feature).should_receive('available').with_args(
  455. module.feature.Feature.RLIST, '1.2.3'
  456. ).and_return(False)
  457. flexmock(module).should_receive('make_list_command').with_args(
  458. repository_path='repo',
  459. storage_config={},
  460. local_borg_version='1.2.3',
  461. list_arguments=argparse.Namespace(
  462. archive='archive', paths=None, json=False, find_paths=None, **default_filter_flags
  463. ),
  464. local_path='borg',
  465. remote_path=None,
  466. ).and_return(('borg', 'list', 'repo::archive'))
  467. flexmock(module).should_receive('make_find_paths').and_return(())
  468. flexmock(module.environment).should_receive('make_environment')
  469. flexmock(module).should_receive('execute_command').with_args(
  470. ('borg', 'list', 'repo::archive'),
  471. output_log_level=module.borgmatic.logger.ANSWER,
  472. borg_local_path='borg',
  473. extra_environment=None,
  474. ).once()
  475. module.list_archive(
  476. repository_path='repo',
  477. storage_config={},
  478. local_borg_version='1.2.3',
  479. list_arguments=argparse.Namespace(
  480. archive='archive', paths=None, json=False, find_paths=None, **altered_filter_flags
  481. ),
  482. )
  483. @pytest.mark.parametrize(
  484. 'archive_filter_flag',
  485. (
  486. 'prefix',
  487. 'match_archives',
  488. 'sort_by',
  489. 'first',
  490. 'last',
  491. ),
  492. )
  493. def test_list_archive_with_find_paths_allows_archive_filter_flag_but_only_passes_it_to_rlist(
  494. archive_filter_flag,
  495. ):
  496. flexmock(module.borgmatic.logger).should_receive('add_custom_log_levels')
  497. flexmock(module.logging).ANSWER = module.borgmatic.logger.ANSWER
  498. flexmock(module.logger).answer = lambda message: None
  499. default_filter_flags = {
  500. 'prefix': None,
  501. 'match_archives': None,
  502. 'sort_by': None,
  503. 'first': None,
  504. 'last': None,
  505. }
  506. altered_filter_flags = {**default_filter_flags, **{archive_filter_flag: 'foo'}}
  507. glob_paths = ('**/*foo.txt*/**',)
  508. flexmock(module.feature).should_receive('available').and_return(True)
  509. flexmock(module.rlist).should_receive('make_rlist_command').with_args(
  510. repository_path='repo',
  511. storage_config={},
  512. local_borg_version='1.2.3',
  513. rlist_arguments=argparse.Namespace(
  514. repository='repo', short=True, format=None, json=None, **altered_filter_flags
  515. ),
  516. local_path='borg',
  517. remote_path=None,
  518. ).and_return(('borg', 'rlist', '--repo', 'repo'))
  519. flexmock(module).should_receive('execute_command_and_capture_output').with_args(
  520. ('borg', 'rlist', '--repo', 'repo'),
  521. extra_environment=None,
  522. ).and_return('archive1\narchive2').once()
  523. flexmock(module).should_receive('make_list_command').with_args(
  524. repository_path='repo',
  525. storage_config={},
  526. local_borg_version='1.2.3',
  527. list_arguments=argparse.Namespace(
  528. repository='repo',
  529. archive='archive1',
  530. paths=None,
  531. short=True,
  532. format=None,
  533. json=None,
  534. find_paths=['foo.txt'],
  535. **default_filter_flags,
  536. ),
  537. local_path='borg',
  538. remote_path=None,
  539. ).and_return(('borg', 'list', '--repo', 'repo', 'archive1'))
  540. flexmock(module).should_receive('make_list_command').with_args(
  541. repository_path='repo',
  542. storage_config={},
  543. local_borg_version='1.2.3',
  544. list_arguments=argparse.Namespace(
  545. repository='repo',
  546. archive='archive2',
  547. paths=None,
  548. short=True,
  549. format=None,
  550. json=None,
  551. find_paths=['foo.txt'],
  552. **default_filter_flags,
  553. ),
  554. local_path='borg',
  555. remote_path=None,
  556. ).and_return(('borg', 'list', '--repo', 'repo', 'archive2'))
  557. flexmock(module).should_receive('make_find_paths').and_return(glob_paths)
  558. flexmock(module.environment).should_receive('make_environment')
  559. flexmock(module).should_receive('execute_command').with_args(
  560. ('borg', 'list', '--repo', 'repo', 'archive1') + glob_paths,
  561. output_log_level=module.borgmatic.logger.ANSWER,
  562. borg_local_path='borg',
  563. extra_environment=None,
  564. ).once()
  565. flexmock(module).should_receive('execute_command').with_args(
  566. ('borg', 'list', '--repo', 'repo', 'archive2') + glob_paths,
  567. output_log_level=module.borgmatic.logger.ANSWER,
  568. borg_local_path='borg',
  569. extra_environment=None,
  570. ).once()
  571. module.list_archive(
  572. repository_path='repo',
  573. storage_config={},
  574. local_borg_version='1.2.3',
  575. list_arguments=argparse.Namespace(
  576. repository='repo',
  577. archive=None,
  578. paths=None,
  579. short=True,
  580. format=None,
  581. json=None,
  582. find_paths=['foo.txt'],
  583. **altered_filter_flags,
  584. ),
  585. )