test_arguments.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637
  1. import pytest
  2. from flexmock import flexmock
  3. from borgmatic.commands import arguments as module
  4. def test_parse_arguments_with_no_arguments_uses_defaults():
  5. config_paths = ['default']
  6. flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
  7. arguments = module.parse_arguments()
  8. global_arguments = arguments['global']
  9. assert global_arguments.config_paths == config_paths
  10. assert global_arguments.verbosity == 0
  11. assert global_arguments.syslog_verbosity == -2
  12. assert global_arguments.log_file_verbosity == 1
  13. assert global_arguments.monitoring_verbosity == 1
  14. def test_parse_arguments_with_multiple_config_flags_parses_as_list():
  15. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  16. arguments = module.parse_arguments('--config', 'myconfig', '--config', 'otherconfig')
  17. global_arguments = arguments['global']
  18. assert global_arguments.config_paths == ['myconfig', 'otherconfig']
  19. assert global_arguments.verbosity == 0
  20. assert global_arguments.syslog_verbosity == -2
  21. assert global_arguments.log_file_verbosity == 1
  22. assert global_arguments.monitoring_verbosity == 1
  23. def test_parse_arguments_with_action_after_config_path_omits_action():
  24. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  25. arguments = module.parse_arguments('--config', 'myconfig', 'list', '--json')
  26. global_arguments = arguments['global']
  27. assert global_arguments.config_paths == ['myconfig']
  28. assert 'list' in arguments
  29. assert arguments['list'].json
  30. def test_parse_arguments_with_action_after_config_path_omits_aliased_action():
  31. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  32. arguments = module.parse_arguments('--config', 'myconfig', 'init', '--encryption', 'repokey')
  33. global_arguments = arguments['global']
  34. assert global_arguments.config_paths == ['myconfig']
  35. assert 'repo-create' in arguments
  36. assert arguments['repo-create'].encryption_mode == 'repokey'
  37. def test_parse_arguments_with_action_and_positional_arguments_after_config_path_omits_action_and_arguments():
  38. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  39. arguments = module.parse_arguments('--config', 'myconfig', 'borg', 'key', 'export')
  40. global_arguments = arguments['global']
  41. assert global_arguments.config_paths == ['myconfig']
  42. assert 'borg' in arguments
  43. assert arguments['borg'].options == ['key', 'export']
  44. def test_parse_arguments_with_verbosity_overrides_default():
  45. config_paths = ['default']
  46. flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
  47. arguments = module.parse_arguments('--verbosity', '1')
  48. global_arguments = arguments['global']
  49. assert global_arguments.config_paths == config_paths
  50. assert global_arguments.verbosity == 1
  51. assert global_arguments.syslog_verbosity == -2
  52. assert global_arguments.log_file_verbosity == 1
  53. assert global_arguments.monitoring_verbosity == 1
  54. def test_parse_arguments_with_syslog_verbosity_overrides_default():
  55. config_paths = ['default']
  56. flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
  57. arguments = module.parse_arguments('--syslog-verbosity', '2')
  58. global_arguments = arguments['global']
  59. assert global_arguments.config_paths == config_paths
  60. assert global_arguments.verbosity == 0
  61. assert global_arguments.syslog_verbosity == 2
  62. assert global_arguments.log_file_verbosity == 1
  63. assert global_arguments.monitoring_verbosity == 1
  64. def test_parse_arguments_with_log_file_verbosity_overrides_default():
  65. config_paths = ['default']
  66. flexmock(module.collect).should_receive('get_default_config_paths').and_return(config_paths)
  67. arguments = module.parse_arguments('--log-file-verbosity', '-1')
  68. global_arguments = arguments['global']
  69. assert global_arguments.config_paths == config_paths
  70. assert global_arguments.verbosity == 0
  71. assert global_arguments.syslog_verbosity == -2
  72. assert global_arguments.log_file_verbosity == -1
  73. assert global_arguments.monitoring_verbosity == 1
  74. def test_parse_arguments_with_single_override_parses():
  75. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  76. arguments = module.parse_arguments('--override', 'foo.bar=baz')
  77. global_arguments = arguments['global']
  78. assert global_arguments.overrides == ['foo.bar=baz']
  79. def test_parse_arguments_with_multiple_overrides_flags_parses():
  80. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  81. arguments = module.parse_arguments(
  82. '--override', 'foo.bar=baz', '--override', 'foo.quux=7', '--override', 'this.that=8'
  83. )
  84. global_arguments = arguments['global']
  85. assert global_arguments.overrides == ['foo.bar=baz', 'foo.quux=7', 'this.that=8']
  86. def test_parse_arguments_with_list_json_overrides_default():
  87. arguments = module.parse_arguments('list', '--json')
  88. assert 'list' in arguments
  89. assert arguments['list'].json is True
  90. def test_parse_arguments_with_no_actions_defaults_to_all_actions_enabled():
  91. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  92. arguments = module.parse_arguments()
  93. assert 'prune' in arguments
  94. assert 'create' in arguments
  95. assert 'check' in arguments
  96. def test_parse_arguments_with_no_actions_passes_argument_to_relevant_actions():
  97. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  98. arguments = module.parse_arguments('--stats', '--list')
  99. assert 'prune' in arguments
  100. assert arguments['prune'].stats
  101. assert arguments['prune'].list_archives
  102. assert 'create' in arguments
  103. assert arguments['create'].stats
  104. assert arguments['create'].list_files
  105. assert 'check' in arguments
  106. def test_parse_arguments_with_help_and_no_actions_shows_global_help(capsys):
  107. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  108. with pytest.raises(SystemExit) as exit:
  109. module.parse_arguments('--help')
  110. assert exit.value.code == 0
  111. captured = capsys.readouterr()
  112. assert 'global arguments:' in captured.out
  113. assert 'actions:' in captured.out
  114. def test_parse_arguments_with_help_and_action_shows_action_help(capsys):
  115. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  116. with pytest.raises(SystemExit) as exit:
  117. module.parse_arguments('create', '--help')
  118. assert exit.value.code == 0
  119. captured = capsys.readouterr()
  120. assert 'global arguments:' not in captured.out
  121. assert 'actions:' not in captured.out
  122. assert 'create arguments:' in captured.out
  123. def test_parse_arguments_with_action_before_global_options_parses_options():
  124. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  125. arguments = module.parse_arguments('prune', '--verbosity', '2')
  126. assert 'prune' in arguments
  127. assert arguments['global'].verbosity == 2
  128. def test_parse_arguments_with_global_options_before_action_parses_options():
  129. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  130. arguments = module.parse_arguments('--verbosity', '2', 'prune')
  131. assert 'prune' in arguments
  132. assert arguments['global'].verbosity == 2
  133. def test_parse_arguments_with_prune_action_leaves_other_actions_disabled():
  134. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  135. arguments = module.parse_arguments('prune')
  136. assert 'prune' in arguments
  137. assert 'create' not in arguments
  138. assert 'check' not in arguments
  139. def test_parse_arguments_with_multiple_actions_leaves_other_action_disabled():
  140. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  141. arguments = module.parse_arguments('create', 'check')
  142. assert 'prune' not in arguments
  143. assert 'create' in arguments
  144. assert 'check' in arguments
  145. def test_parse_arguments_disallows_invalid_argument():
  146. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  147. with pytest.raises(ValueError):
  148. module.parse_arguments('--posix-me-harder')
  149. def test_parse_arguments_disallows_encryption_mode_without_init():
  150. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  151. with pytest.raises(ValueError):
  152. module.parse_arguments('--config', 'myconfig', '--encryption', 'repokey')
  153. def test_parse_arguments_allows_encryption_mode_with_init():
  154. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  155. module.parse_arguments('--config', 'myconfig', 'init', '--encryption', 'repokey')
  156. def test_parse_arguments_requires_encryption_mode_with_init():
  157. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  158. with pytest.raises(SystemExit):
  159. module.parse_arguments('--config', 'myconfig', 'init')
  160. def test_parse_arguments_disallows_append_only_without_init():
  161. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  162. with pytest.raises(ValueError):
  163. module.parse_arguments('--config', 'myconfig', '--append-only')
  164. def test_parse_arguments_disallows_storage_quota_without_init():
  165. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  166. with pytest.raises(ValueError):
  167. module.parse_arguments('--config', 'myconfig', '--storage-quota', '5G')
  168. def test_parse_arguments_allows_init_and_prune():
  169. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  170. module.parse_arguments('--config', 'myconfig', 'init', '--encryption', 'repokey', 'prune')
  171. def test_parse_arguments_allows_init_and_create():
  172. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  173. module.parse_arguments('--config', 'myconfig', 'init', '--encryption', 'repokey', 'create')
  174. def test_parse_arguments_allows_repository_with_extract():
  175. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  176. module.parse_arguments(
  177. '--config', 'myconfig', 'extract', '--repository', 'test.borg', '--archive', 'test'
  178. )
  179. def test_parse_arguments_allows_repository_with_mount():
  180. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  181. module.parse_arguments(
  182. '--config',
  183. 'myconfig',
  184. 'mount',
  185. '--repository',
  186. 'test.borg',
  187. '--archive',
  188. 'test',
  189. '--mount-point',
  190. '/mnt',
  191. )
  192. def test_parse_arguments_allows_repository_with_list():
  193. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  194. module.parse_arguments('--config', 'myconfig', 'list', '--repository', 'test.borg')
  195. def test_parse_arguments_disallows_archive_unless_action_consumes_it():
  196. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  197. with pytest.raises(ValueError):
  198. module.parse_arguments('--config', 'myconfig', '--archive', 'test')
  199. def test_parse_arguments_disallows_paths_unless_action_consumes_it():
  200. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  201. with pytest.raises(ValueError):
  202. module.parse_arguments('--config', 'myconfig', '--path', 'test')
  203. def test_parse_arguments_disallows_other_actions_with_config_bootstrap():
  204. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  205. with pytest.raises(ValueError):
  206. module.parse_arguments('config', 'bootstrap', '--repository', 'test.borg', 'list')
  207. def test_parse_arguments_allows_archive_with_extract():
  208. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  209. module.parse_arguments('--config', 'myconfig', 'extract', '--archive', 'test')
  210. def test_parse_arguments_allows_archive_with_mount():
  211. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  212. module.parse_arguments(
  213. '--config', 'myconfig', 'mount', '--archive', 'test', '--mount-point', '/mnt'
  214. )
  215. def test_parse_arguments_allows_archive_with_restore():
  216. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  217. module.parse_arguments('--config', 'myconfig', 'restore', '--archive', 'test')
  218. def test_parse_arguments_allows_archive_with_list():
  219. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  220. module.parse_arguments('--config', 'myconfig', 'list', '--archive', 'test')
  221. def test_parse_arguments_requires_archive_with_extract():
  222. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  223. with pytest.raises(SystemExit):
  224. module.parse_arguments('--config', 'myconfig', 'extract')
  225. def test_parse_arguments_requires_archive_with_restore():
  226. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  227. with pytest.raises(SystemExit):
  228. module.parse_arguments('--config', 'myconfig', 'restore')
  229. def test_parse_arguments_requires_mount_point_with_mount():
  230. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  231. with pytest.raises(SystemExit):
  232. module.parse_arguments('--config', 'myconfig', 'mount', '--archive', 'test')
  233. def test_parse_arguments_requires_mount_point_with_umount():
  234. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  235. with pytest.raises(SystemExit):
  236. module.parse_arguments('--config', 'myconfig', 'umount')
  237. def test_parse_arguments_allows_progress_before_create():
  238. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  239. module.parse_arguments('--progress', 'create', 'list')
  240. def test_parse_arguments_allows_progress_after_create():
  241. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  242. module.parse_arguments('create', '--progress', 'list')
  243. def test_parse_arguments_allows_progress_and_extract():
  244. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  245. module.parse_arguments('--progress', 'extract', '--archive', 'test', 'list')
  246. def test_parse_arguments_disallows_progress_without_create():
  247. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  248. with pytest.raises(ValueError):
  249. module.parse_arguments('--progress', 'list')
  250. def test_parse_arguments_with_stats_and_create_flags_does_not_raise():
  251. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  252. module.parse_arguments('--stats', 'create', 'list')
  253. def test_parse_arguments_with_stats_and_prune_flags_does_not_raise():
  254. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  255. module.parse_arguments('--stats', 'prune', 'list')
  256. def test_parse_arguments_with_stats_flag_but_no_create_or_prune_flag_raises_value_error():
  257. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  258. with pytest.raises(ValueError):
  259. module.parse_arguments('--stats', 'list')
  260. def test_parse_arguments_with_list_and_create_flags_does_not_raise():
  261. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  262. module.parse_arguments('--list', 'create')
  263. def test_parse_arguments_with_list_and_prune_flags_does_not_raise():
  264. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  265. module.parse_arguments('--list', 'prune')
  266. def test_parse_arguments_with_list_flag_but_no_relevant_action_raises_value_error():
  267. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  268. with pytest.raises(SystemExit):
  269. module.parse_arguments('--list', 'repo-create')
  270. def test_parse_arguments_disallows_list_with_progress_for_create_action():
  271. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  272. with pytest.raises(ValueError):
  273. module.parse_arguments('create', '--list', '--progress')
  274. def test_parse_arguments_disallows_list_with_json_for_create_action():
  275. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  276. with pytest.raises(ValueError):
  277. module.parse_arguments('create', '--list', '--json')
  278. def test_parse_arguments_allows_json_with_list_or_info():
  279. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  280. module.parse_arguments('list', '--json')
  281. module.parse_arguments('info', '--json')
  282. def test_parse_arguments_disallows_json_with_both_list_and_info():
  283. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  284. with pytest.raises(ValueError):
  285. module.parse_arguments('list', 'info', '--json')
  286. def test_parse_arguments_disallows_json_with_both_list_and_repo_info():
  287. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  288. with pytest.raises(ValueError):
  289. module.parse_arguments('list', 'repo-info', '--json')
  290. def test_parse_arguments_disallows_json_with_both_repo_info_and_info():
  291. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  292. with pytest.raises(ValueError):
  293. module.parse_arguments('repo-info', 'info', '--json')
  294. def test_parse_arguments_disallows_transfer_with_both_archive_and_match_archives():
  295. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  296. with pytest.raises(ValueError):
  297. module.parse_arguments(
  298. 'transfer',
  299. '--source-repository',
  300. 'source.borg',
  301. '--archive',
  302. 'foo',
  303. '--match-archives',
  304. 'sh:*bar',
  305. )
  306. def test_parse_arguments_disallows_list_with_both_prefix_and_match_archives():
  307. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  308. with pytest.raises(ValueError):
  309. module.parse_arguments('list', '--prefix', 'foo', '--match-archives', 'sh:*bar')
  310. def test_parse_arguments_disallows_repo_list_with_both_prefix_and_match_archives():
  311. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  312. with pytest.raises(ValueError):
  313. module.parse_arguments('repo-list', '--prefix', 'foo', '--match-archives', 'sh:*bar')
  314. def test_parse_arguments_disallows_info_with_both_archive_and_match_archives():
  315. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  316. with pytest.raises(ValueError):
  317. module.parse_arguments('info', '--archive', 'foo', '--match-archives', 'sh:*bar')
  318. def test_parse_arguments_disallows_info_with_both_archive_and_prefix():
  319. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  320. with pytest.raises(ValueError):
  321. module.parse_arguments('info', '--archive', 'foo', '--prefix', 'bar')
  322. def test_parse_arguments_disallows_info_with_both_prefix_and_match_archives():
  323. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  324. with pytest.raises(ValueError):
  325. module.parse_arguments('info', '--prefix', 'foo', '--match-archives', 'sh:*bar')
  326. def test_parse_arguments_check_only_extract_does_not_raise_extract_subparser_error():
  327. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  328. module.parse_arguments('check', '--only', 'extract')
  329. def test_parse_arguments_extract_archive_check_does_not_raise_check_subparser_error():
  330. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  331. module.parse_arguments('extract', '--archive', 'check')
  332. def test_parse_arguments_extract_with_check_only_extract_does_not_raise():
  333. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  334. module.parse_arguments('extract', '--archive', 'name', 'check', '--only', 'extract')
  335. def test_parse_arguments_bootstrap_without_config_errors():
  336. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  337. with pytest.raises(ValueError):
  338. module.parse_arguments('bootstrap')
  339. def test_parse_arguments_config_with_no_subaction_errors():
  340. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  341. with pytest.raises(ValueError):
  342. module.parse_arguments('config')
  343. def test_parse_arguments_config_with_help_shows_config_help(capsys):
  344. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  345. with pytest.raises(SystemExit) as exit:
  346. module.parse_arguments('config', '--help')
  347. assert exit.value.code == 0
  348. captured = capsys.readouterr()
  349. assert 'global arguments:' not in captured.out
  350. assert 'config arguments:' in captured.out
  351. assert 'config sub-actions:' in captured.out
  352. def test_parse_arguments_config_with_subaction_but_missing_flags_errors():
  353. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  354. with pytest.raises(SystemExit) as exit:
  355. module.parse_arguments('config', 'bootstrap')
  356. assert exit.value.code == 2
  357. def test_parse_arguments_config_with_subaction_and_help_shows_subaction_help(capsys):
  358. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  359. with pytest.raises(SystemExit) as exit:
  360. module.parse_arguments('config', 'bootstrap', '--help')
  361. assert exit.value.code == 0
  362. captured = capsys.readouterr()
  363. assert 'config bootstrap arguments:' in captured.out
  364. def test_parse_arguments_config_with_subaction_and_required_flags_does_not_raise():
  365. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  366. module.parse_arguments('config', 'bootstrap', '--repository', 'repo.borg')
  367. def test_parse_arguments_config_with_subaction_and_global_flags_at_start_does_not_raise():
  368. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  369. module.parse_arguments('--verbosity', '1', 'config', 'bootstrap', '--repository', 'repo.borg')
  370. def test_parse_arguments_config_with_subaction_and_global_flags_at_end_does_not_raise():
  371. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  372. module.parse_arguments('config', 'bootstrap', '--repository', 'repo.borg', '--verbosity', '1')
  373. def test_parse_arguments_config_with_subaction_and_explicit_config_file_does_not_raise():
  374. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  375. module.parse_arguments(
  376. 'config', 'bootstrap', '--repository', 'repo.borg', '--config', 'test.yaml'
  377. )
  378. def test_parse_arguments_with_borg_action_and_dry_run_raises():
  379. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  380. with pytest.raises(ValueError):
  381. module.parse_arguments('--dry-run', 'borg', 'list')
  382. def test_parse_arguments_with_borg_action_and_no_dry_run_does_not_raise():
  383. flexmock(module.collect).should_receive('get_default_config_paths').and_return(['default'])
  384. module.parse_arguments('borg', 'list')