test_arguments.py 23 KB

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