2015-07-27 04:06:03 +00:00
|
|
|
import os
|
2014-12-20 19:37:25 +00:00
|
|
|
|
2015-07-27 04:06:03 +00:00
|
|
|
from flexmock import flexmock
|
2016-04-10 22:59:36 +00:00
|
|
|
import pytest
|
2014-12-20 19:37:25 +00:00
|
|
|
|
2017-07-09 05:33:51 +00:00
|
|
|
from borgmatic.commands import borgmatic as module
|
2015-07-19 01:35:29 +00:00
|
|
|
|
|
|
|
|
2014-12-20 19:37:25 +00:00
|
|
|
def test_parse_arguments_with_no_arguments_uses_defaults():
|
2016-06-10 18:21:53 +00:00
|
|
|
parser = module.parse_arguments()
|
2014-12-20 19:37:25 +00:00
|
|
|
|
2016-06-10 18:21:53 +00:00
|
|
|
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME
|
2017-07-10 23:25:13 +00:00
|
|
|
assert parser.excludes_filename == None
|
2017-07-10 16:43:25 +00:00
|
|
|
assert parser.verbosity is None
|
2014-12-20 19:37:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_filename_arguments_overrides_defaults():
|
2016-06-10 18:21:53 +00:00
|
|
|
parser = module.parse_arguments('--config', 'myconfig', '--excludes', 'myexcludes')
|
2014-12-20 19:37:25 +00:00
|
|
|
|
|
|
|
assert parser.config_filename == 'myconfig'
|
|
|
|
assert parser.excludes_filename == 'myexcludes'
|
2017-07-10 16:43:25 +00:00
|
|
|
assert parser.verbosity is None
|
2014-12-20 19:37:25 +00:00
|
|
|
|
|
|
|
|
2015-07-18 04:58:50 +00:00
|
|
|
def test_parse_arguments_with_verbosity_flag_overrides_default():
|
2016-06-10 18:21:53 +00:00
|
|
|
parser = module.parse_arguments('--verbosity', '1')
|
2014-12-20 19:37:25 +00:00
|
|
|
|
2016-06-10 18:21:53 +00:00
|
|
|
assert parser.config_filename == module.DEFAULT_CONFIG_FILENAME
|
2017-07-10 23:25:13 +00:00
|
|
|
assert parser.excludes_filename == None
|
2015-07-18 04:58:50 +00:00
|
|
|
assert parser.verbosity == 1
|
2014-12-20 19:37:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_parse_arguments_with_invalid_arguments_exits():
|
2017-07-10 16:43:25 +00:00
|
|
|
with pytest.raises(SystemExit):
|
|
|
|
module.parse_arguments('--posix-me-harder')
|