test_check.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. import logging
  2. import pytest
  3. from flexmock import flexmock
  4. from borgmatic.borg import check as module
  5. from ..test_verbosity import insert_logging_mock
  6. def insert_execute_command_mock(command):
  7. flexmock(module.environment).should_receive('make_environment')
  8. flexmock(module).should_receive('execute_command').with_args(
  9. command, extra_environment=None
  10. ).once()
  11. def insert_execute_command_never():
  12. flexmock(module).should_receive('execute_command').never()
  13. def test_parse_checks_returns_them_as_tuple():
  14. checks = module.parse_checks({'checks': [{'name': 'foo'}, {'name': 'bar'}]})
  15. assert checks == ('foo', 'bar')
  16. def test_parse_checks_with_missing_value_returns_defaults():
  17. checks = module.parse_checks({})
  18. assert checks == ('repository', 'archives')
  19. def test_parse_checks_with_empty_list_returns_defaults():
  20. checks = module.parse_checks({'checks': []})
  21. assert checks == ('repository', 'archives')
  22. def test_parse_checks_with_none_value_returns_defaults():
  23. checks = module.parse_checks({'checks': None})
  24. assert checks == ('repository', 'archives')
  25. def test_parse_checks_with_disabled_returns_no_checks():
  26. checks = module.parse_checks({'checks': [{'name': 'foo'}, {'name': 'disabled'}]})
  27. assert checks == ()
  28. def test_parse_checks_prefers_override_checks_to_configured_checks():
  29. checks = module.parse_checks(
  30. {'checks': [{'name': 'archives'}]}, only_checks=['repository', 'extract']
  31. )
  32. assert checks == ('repository', 'extract')
  33. @pytest.mark.parametrize(
  34. 'frequency,expected_result',
  35. (
  36. (None, None),
  37. ('always', None),
  38. ('1 hour', module.datetime.timedelta(hours=1)),
  39. ('2 hours', module.datetime.timedelta(hours=2)),
  40. ('1 day', module.datetime.timedelta(days=1)),
  41. ('2 days', module.datetime.timedelta(days=2)),
  42. ('1 week', module.datetime.timedelta(weeks=1)),
  43. ('2 weeks', module.datetime.timedelta(weeks=2)),
  44. ('1 month', module.datetime.timedelta(days=30)),
  45. ('2 months', module.datetime.timedelta(days=60)),
  46. ('1 year', module.datetime.timedelta(days=365)),
  47. ('2 years', module.datetime.timedelta(days=365 * 2)),
  48. ),
  49. )
  50. def test_parse_frequency_parses_into_timedeltas(frequency, expected_result):
  51. assert module.parse_frequency(frequency) == expected_result
  52. @pytest.mark.parametrize(
  53. 'frequency', ('sometime', 'x days', '3 decades',),
  54. )
  55. def test_parse_frequency_raises_on_parse_error(frequency):
  56. with pytest.raises(ValueError):
  57. module.parse_frequency(frequency)
  58. def test_filter_checks_on_frequency_without_config_uses_default_checks():
  59. flexmock(module).should_receive('parse_frequency').and_return(
  60. module.datetime.timedelta(weeks=4)
  61. )
  62. flexmock(module).should_receive('make_check_time_path')
  63. flexmock(module).should_receive('read_check_time').and_return(None)
  64. assert module.filter_checks_on_frequency(
  65. location_config={},
  66. consistency_config={},
  67. borg_repository_id='repo',
  68. checks=('repository', 'archives'),
  69. force=False,
  70. ) == ('repository', 'archives')
  71. def test_filter_checks_on_frequency_retains_unconfigured_check():
  72. assert module.filter_checks_on_frequency(
  73. location_config={},
  74. consistency_config={},
  75. borg_repository_id='repo',
  76. checks=('data',),
  77. force=False,
  78. ) == ('data',)
  79. def test_filter_checks_on_frequency_retains_check_without_frequency():
  80. flexmock(module).should_receive('parse_frequency').and_return(None)
  81. assert module.filter_checks_on_frequency(
  82. location_config={},
  83. consistency_config={'checks': [{'name': 'archives'}]},
  84. borg_repository_id='repo',
  85. checks=('archives',),
  86. force=False,
  87. ) == ('archives',)
  88. def test_filter_checks_on_frequency_retains_check_with_elapsed_frequency():
  89. flexmock(module).should_receive('parse_frequency').and_return(
  90. module.datetime.timedelta(hours=1)
  91. )
  92. flexmock(module).should_receive('make_check_time_path')
  93. flexmock(module).should_receive('read_check_time').and_return(
  94. module.datetime.datetime(year=module.datetime.MINYEAR, month=1, day=1)
  95. )
  96. assert module.filter_checks_on_frequency(
  97. location_config={},
  98. consistency_config={'checks': [{'name': 'archives', 'frequency': '1 hour'}]},
  99. borg_repository_id='repo',
  100. checks=('archives',),
  101. force=False,
  102. ) == ('archives',)
  103. def test_filter_checks_on_frequency_retains_check_with_missing_check_time_file():
  104. flexmock(module).should_receive('parse_frequency').and_return(
  105. module.datetime.timedelta(hours=1)
  106. )
  107. flexmock(module).should_receive('make_check_time_path')
  108. flexmock(module).should_receive('read_check_time').and_return(None)
  109. assert module.filter_checks_on_frequency(
  110. location_config={},
  111. consistency_config={'checks': [{'name': 'archives', 'frequency': '1 hour'}]},
  112. borg_repository_id='repo',
  113. checks=('archives',),
  114. force=False,
  115. ) == ('archives',)
  116. def test_filter_checks_on_frequency_skips_check_with_unelapsed_frequency():
  117. flexmock(module).should_receive('parse_frequency').and_return(
  118. module.datetime.timedelta(hours=1)
  119. )
  120. flexmock(module).should_receive('make_check_time_path')
  121. flexmock(module).should_receive('read_check_time').and_return(module.datetime.datetime.now())
  122. assert (
  123. module.filter_checks_on_frequency(
  124. location_config={},
  125. consistency_config={'checks': [{'name': 'archives', 'frequency': '1 hour'}]},
  126. borg_repository_id='repo',
  127. checks=('archives',),
  128. force=False,
  129. )
  130. == ()
  131. )
  132. def test_filter_checks_on_frequency_restains_check_with_unelapsed_frequency_and_force():
  133. assert module.filter_checks_on_frequency(
  134. location_config={},
  135. consistency_config={'checks': [{'name': 'archives', 'frequency': '1 hour'}]},
  136. borg_repository_id='repo',
  137. checks=('archives',),
  138. force=True,
  139. ) == ('archives',)
  140. def test_make_check_flags_with_repository_check_returns_flag():
  141. flags = module.make_check_flags(('repository',))
  142. assert flags == ('--repository-only',)
  143. def test_make_check_flags_with_archives_check_returns_flag():
  144. flags = module.make_check_flags(('archives',))
  145. assert flags == ('--archives-only',)
  146. def test_make_check_flags_with_data_check_returns_flag_and_implies_archives():
  147. flags = module.make_check_flags(('data',))
  148. assert flags == ('--archives-only', '--verify-data',)
  149. def test_make_check_flags_with_extract_omits_extract_flag():
  150. flags = module.make_check_flags(('extract',))
  151. assert flags == ()
  152. def test_make_check_flags_with_repository_and_data_checks_does_not_return_repository_only():
  153. flags = module.make_check_flags(('repository', 'data',))
  154. assert flags == ('--verify-data',)
  155. def test_make_check_flags_with_default_checks_and_default_prefix_returns_default_flags():
  156. flags = module.make_check_flags(('repository', 'archives'), prefix=module.DEFAULT_PREFIX)
  157. assert flags == ('--glob-archives', f'{module.DEFAULT_PREFIX}*')
  158. def test_make_check_flags_with_all_checks_and_default_prefix_returns_default_flags():
  159. flags = module.make_check_flags(
  160. ('repository', 'archives', 'extract'), prefix=module.DEFAULT_PREFIX
  161. )
  162. assert flags == ('--glob-archives', f'{module.DEFAULT_PREFIX}*')
  163. def test_make_check_flags_with_archives_check_and_last_includes_last_flag():
  164. flags = module.make_check_flags(('archives',), check_last=3)
  165. assert flags == ('--archives-only', '--last', '3')
  166. def test_make_check_flags_with_repository_check_and_last_omits_last_flag():
  167. flags = module.make_check_flags(('repository',), check_last=3)
  168. assert flags == ('--repository-only',)
  169. def test_make_check_flags_with_default_checks_and_last_includes_last_flag():
  170. flags = module.make_check_flags(('repository', 'archives'), check_last=3)
  171. assert flags == ('--last', '3')
  172. def test_make_check_flags_with_archives_check_and_prefix_includes_glob_archives_flag():
  173. flags = module.make_check_flags(('archives',), prefix='foo-')
  174. assert flags == ('--archives-only', '--glob-archives', 'foo-*')
  175. def test_make_check_flags_with_archives_check_and_empty_prefix_omits_glob_archives_flag():
  176. flags = module.make_check_flags(('archives',), prefix='')
  177. assert flags == ('--archives-only',)
  178. def test_make_check_flags_with_archives_check_and_none_prefix_omits_glob_archives_flag():
  179. flags = module.make_check_flags(('archives',), prefix=None)
  180. assert flags == ('--archives-only',)
  181. def test_make_check_flags_with_repository_check_and_prefix_omits_glob_archives_flag():
  182. flags = module.make_check_flags(('repository',), prefix='foo-')
  183. assert flags == ('--repository-only',)
  184. def test_make_check_flags_with_default_checks_and_prefix_includes_glob_archives_flag():
  185. flags = module.make_check_flags(('repository', 'archives'), prefix='foo-')
  186. assert flags == ('--glob-archives', 'foo-*')
  187. def test_read_check_time_does_not_raise():
  188. flexmock(module.os).should_receive('stat').and_return(flexmock(st_mtime=123))
  189. assert module.read_check_time('/path')
  190. def test_read_check_time_on_missing_file_does_not_raise():
  191. flexmock(module.os).should_receive('stat').and_raise(FileNotFoundError)
  192. assert module.read_check_time('/path') is None
  193. def test_check_archives_with_progress_calls_borg_with_progress_parameter():
  194. checks = ('repository',)
  195. consistency_config = {'check_last': None}
  196. flexmock(module).should_receive('parse_checks')
  197. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  198. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  199. '{"repository": {"id": "repo"}}'
  200. )
  201. flexmock(module).should_receive('make_check_flags').and_return(())
  202. flexmock(module).should_receive('execute_command').never()
  203. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  204. flexmock(module.environment).should_receive('make_environment')
  205. flexmock(module).should_receive('execute_command').with_args(
  206. ('borg', 'check', '--progress', 'repo'),
  207. output_file=module.DO_NOT_CAPTURE,
  208. extra_environment=None,
  209. ).once()
  210. flexmock(module).should_receive('make_check_time_path')
  211. flexmock(module).should_receive('write_check_time')
  212. module.check_archives(
  213. repository='repo',
  214. location_config={},
  215. storage_config={},
  216. consistency_config=consistency_config,
  217. local_borg_version='1.2.3',
  218. progress=True,
  219. )
  220. def test_check_archives_with_repair_calls_borg_with_repair_parameter():
  221. checks = ('repository',)
  222. consistency_config = {'check_last': None}
  223. flexmock(module).should_receive('parse_checks')
  224. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  225. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  226. '{"repository": {"id": "repo"}}'
  227. )
  228. flexmock(module).should_receive('make_check_flags').and_return(())
  229. flexmock(module).should_receive('execute_command').never()
  230. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  231. flexmock(module.environment).should_receive('make_environment')
  232. flexmock(module).should_receive('execute_command').with_args(
  233. ('borg', 'check', '--repair', 'repo'),
  234. output_file=module.DO_NOT_CAPTURE,
  235. extra_environment=None,
  236. ).once()
  237. flexmock(module).should_receive('make_check_time_path')
  238. flexmock(module).should_receive('write_check_time')
  239. module.check_archives(
  240. repository='repo',
  241. location_config={},
  242. storage_config={},
  243. consistency_config=consistency_config,
  244. local_borg_version='1.2.3',
  245. repair=True,
  246. )
  247. @pytest.mark.parametrize(
  248. 'checks',
  249. (
  250. ('repository',),
  251. ('archives',),
  252. ('repository', 'archives'),
  253. ('repository', 'archives', 'other'),
  254. ),
  255. )
  256. def test_check_archives_calls_borg_with_parameters(checks):
  257. check_last = flexmock()
  258. consistency_config = {'check_last': check_last}
  259. flexmock(module).should_receive('parse_checks')
  260. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  261. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  262. '{"repository": {"id": "repo"}}'
  263. )
  264. flexmock(module).should_receive('make_check_flags').with_args(
  265. checks, check_last, module.DEFAULT_PREFIX
  266. ).and_return(())
  267. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  268. insert_execute_command_mock(('borg', 'check', 'repo'))
  269. flexmock(module).should_receive('make_check_time_path')
  270. flexmock(module).should_receive('write_check_time')
  271. module.check_archives(
  272. repository='repo',
  273. location_config={},
  274. storage_config={},
  275. consistency_config=consistency_config,
  276. local_borg_version='1.2.3',
  277. )
  278. def test_check_archives_with_json_error_raises():
  279. checks = ('archives',)
  280. check_last = flexmock()
  281. consistency_config = {'check_last': check_last}
  282. flexmock(module).should_receive('parse_checks')
  283. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  284. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  285. '{"unexpected": {"id": "repo"}}'
  286. )
  287. with pytest.raises(ValueError):
  288. module.check_archives(
  289. repository='repo',
  290. location_config={},
  291. storage_config={},
  292. consistency_config=consistency_config,
  293. local_borg_version='1.2.3',
  294. )
  295. def test_check_archives_with_missing_json_keys_raises():
  296. checks = ('archives',)
  297. check_last = flexmock()
  298. consistency_config = {'check_last': check_last}
  299. flexmock(module).should_receive('parse_checks')
  300. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  301. flexmock(module.rinfo).should_receive('display_repository_info').and_return('{invalid JSON')
  302. with pytest.raises(ValueError):
  303. module.check_archives(
  304. repository='repo',
  305. location_config={},
  306. storage_config={},
  307. consistency_config=consistency_config,
  308. local_borg_version='1.2.3',
  309. )
  310. def test_check_archives_with_extract_check_calls_extract_only():
  311. checks = ('extract',)
  312. check_last = flexmock()
  313. consistency_config = {'check_last': check_last}
  314. flexmock(module).should_receive('parse_checks')
  315. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  316. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  317. '{"repository": {"id": "repo"}}'
  318. )
  319. flexmock(module).should_receive('make_check_flags').never()
  320. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  321. flexmock(module.extract).should_receive('extract_last_archive_dry_run').once()
  322. flexmock(module).should_receive('write_check_time')
  323. insert_execute_command_never()
  324. module.check_archives(
  325. repository='repo',
  326. location_config={},
  327. storage_config={},
  328. consistency_config=consistency_config,
  329. local_borg_version='1.2.3',
  330. )
  331. def test_check_archives_with_log_info_calls_borg_with_info_parameter():
  332. checks = ('repository',)
  333. consistency_config = {'check_last': None}
  334. flexmock(module).should_receive('parse_checks')
  335. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  336. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  337. '{"repository": {"id": "repo"}}'
  338. )
  339. flexmock(module).should_receive('make_check_flags').and_return(())
  340. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  341. insert_logging_mock(logging.INFO)
  342. insert_execute_command_mock(('borg', 'check', '--info', 'repo'))
  343. flexmock(module).should_receive('make_check_time_path')
  344. flexmock(module).should_receive('write_check_time')
  345. module.check_archives(
  346. repository='repo',
  347. location_config={},
  348. storage_config={},
  349. consistency_config=consistency_config,
  350. local_borg_version='1.2.3',
  351. )
  352. def test_check_archives_with_log_debug_calls_borg_with_debug_parameter():
  353. checks = ('repository',)
  354. consistency_config = {'check_last': None}
  355. flexmock(module).should_receive('parse_checks')
  356. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  357. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  358. '{"repository": {"id": "repo"}}'
  359. )
  360. flexmock(module).should_receive('make_check_flags').and_return(())
  361. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  362. insert_logging_mock(logging.DEBUG)
  363. insert_execute_command_mock(('borg', 'check', '--debug', '--show-rc', 'repo'))
  364. flexmock(module).should_receive('make_check_time_path')
  365. flexmock(module).should_receive('write_check_time')
  366. module.check_archives(
  367. repository='repo',
  368. location_config={},
  369. storage_config={},
  370. consistency_config=consistency_config,
  371. local_borg_version='1.2.3',
  372. )
  373. def test_check_archives_without_any_checks_bails():
  374. consistency_config = {'check_last': None}
  375. flexmock(module).should_receive('parse_checks')
  376. flexmock(module).should_receive('filter_checks_on_frequency').and_return(())
  377. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  378. '{"repository": {"id": "repo"}}'
  379. )
  380. insert_execute_command_never()
  381. module.check_archives(
  382. repository='repo',
  383. location_config={},
  384. storage_config={},
  385. consistency_config=consistency_config,
  386. local_borg_version='1.2.3',
  387. )
  388. def test_check_archives_with_local_path_calls_borg_via_local_path():
  389. checks = ('repository',)
  390. check_last = flexmock()
  391. consistency_config = {'check_last': check_last}
  392. flexmock(module).should_receive('parse_checks')
  393. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  394. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  395. '{"repository": {"id": "repo"}}'
  396. )
  397. flexmock(module).should_receive('make_check_flags').with_args(
  398. checks, check_last, module.DEFAULT_PREFIX
  399. ).and_return(())
  400. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  401. insert_execute_command_mock(('borg1', 'check', 'repo'))
  402. flexmock(module).should_receive('make_check_time_path')
  403. flexmock(module).should_receive('write_check_time')
  404. module.check_archives(
  405. repository='repo',
  406. location_config={},
  407. storage_config={},
  408. consistency_config=consistency_config,
  409. local_borg_version='1.2.3',
  410. local_path='borg1',
  411. )
  412. def test_check_archives_with_remote_path_calls_borg_with_remote_path_parameters():
  413. checks = ('repository',)
  414. check_last = flexmock()
  415. consistency_config = {'check_last': check_last}
  416. flexmock(module).should_receive('parse_checks')
  417. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  418. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  419. '{"repository": {"id": "repo"}}'
  420. )
  421. flexmock(module).should_receive('make_check_flags').with_args(
  422. checks, check_last, module.DEFAULT_PREFIX
  423. ).and_return(())
  424. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  425. insert_execute_command_mock(('borg', 'check', '--remote-path', 'borg1', 'repo'))
  426. flexmock(module).should_receive('make_check_time_path')
  427. flexmock(module).should_receive('write_check_time')
  428. module.check_archives(
  429. repository='repo',
  430. location_config={},
  431. storage_config={},
  432. consistency_config=consistency_config,
  433. local_borg_version='1.2.3',
  434. remote_path='borg1',
  435. )
  436. def test_check_archives_with_lock_wait_calls_borg_with_lock_wait_parameters():
  437. checks = ('repository',)
  438. check_last = flexmock()
  439. consistency_config = {'check_last': check_last}
  440. flexmock(module).should_receive('parse_checks')
  441. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  442. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  443. '{"repository": {"id": "repo"}}'
  444. )
  445. flexmock(module).should_receive('make_check_flags').with_args(
  446. checks, check_last, module.DEFAULT_PREFIX
  447. ).and_return(())
  448. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  449. insert_execute_command_mock(('borg', 'check', '--lock-wait', '5', 'repo'))
  450. flexmock(module).should_receive('make_check_time_path')
  451. flexmock(module).should_receive('write_check_time')
  452. module.check_archives(
  453. repository='repo',
  454. location_config={},
  455. storage_config={'lock_wait': 5},
  456. consistency_config=consistency_config,
  457. local_borg_version='1.2.3',
  458. )
  459. def test_check_archives_with_retention_prefix():
  460. checks = ('repository',)
  461. check_last = flexmock()
  462. prefix = 'foo-'
  463. consistency_config = {'check_last': check_last, 'prefix': prefix}
  464. flexmock(module).should_receive('parse_checks')
  465. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  466. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  467. '{"repository": {"id": "repo"}}'
  468. )
  469. flexmock(module).should_receive('make_check_flags').with_args(
  470. checks, check_last, prefix
  471. ).and_return(())
  472. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  473. insert_execute_command_mock(('borg', 'check', 'repo'))
  474. flexmock(module).should_receive('make_check_time_path')
  475. flexmock(module).should_receive('write_check_time')
  476. module.check_archives(
  477. repository='repo',
  478. location_config={},
  479. storage_config={},
  480. consistency_config=consistency_config,
  481. local_borg_version='1.2.3',
  482. )
  483. def test_check_archives_with_extra_borg_options_calls_borg_with_extra_options():
  484. checks = ('repository',)
  485. consistency_config = {'check_last': None}
  486. flexmock(module).should_receive('parse_checks')
  487. flexmock(module).should_receive('filter_checks_on_frequency').and_return(checks)
  488. flexmock(module.rinfo).should_receive('display_repository_info').and_return(
  489. '{"repository": {"id": "repo"}}'
  490. )
  491. flexmock(module).should_receive('make_check_flags').and_return(())
  492. flexmock(module.flags).should_receive('make_repository_flags').and_return(('repo',))
  493. insert_execute_command_mock(('borg', 'check', '--extra', '--options', 'repo'))
  494. flexmock(module).should_receive('make_check_time_path')
  495. flexmock(module).should_receive('write_check_time')
  496. module.check_archives(
  497. repository='repo',
  498. location_config={},
  499. storage_config={'extra_borg_options': {'check': '--extra --options'}},
  500. consistency_config=consistency_config,
  501. local_borg_version='1.2.3',
  502. )