Completed test coverage of commands (except for main()s).
This commit is contained in:
parent
d49be19544
commit
17c87f8758
5 changed files with 30 additions and 3 deletions
|
@ -39,7 +39,7 @@ def parse_arguments(*arguments):
|
||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(): # pragma: no cover
|
||||||
try:
|
try:
|
||||||
# TODO: Detect whether only legacy config is present. If so, inform the user about how to
|
# TODO: Detect whether only legacy config is present. If so, inform the user about how to
|
||||||
# upgrade, then exet.
|
# upgrade, then exet.
|
||||||
|
|
|
@ -11,6 +11,7 @@ from borgmatic.config import convert, generate, legacy, validate
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_SOURCE_CONFIG_FILENAME = '/etc/borgmatic/config'
|
DEFAULT_SOURCE_CONFIG_FILENAME = '/etc/borgmatic/config'
|
||||||
|
# TODO: Fold excludes into the YAML config file.
|
||||||
DEFAULT_SOURCE_EXCLUDES_FILENAME = '/etc/borgmatic/excludes'
|
DEFAULT_SOURCE_EXCLUDES_FILENAME = '/etc/borgmatic/excludes'
|
||||||
DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'
|
DEFAULT_DESTINATION_CONFIG_FILENAME = '/etc/borgmatic/config.yaml'
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ def parse_arguments(*arguments):
|
||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(): # pragma: no cover
|
||||||
try:
|
try:
|
||||||
args = parse_arguments(*sys.argv[1:])
|
args = parse_arguments(*sys.argv[1:])
|
||||||
source_config = legacy.parse_configuration(args.source_filename, legacy.CONFIG_FORMAT)
|
source_config = legacy.parse_configuration(args.source_filename, legacy.CONFIG_FORMAT)
|
||||||
|
|
|
@ -29,7 +29,7 @@ def parse_arguments(*arguments):
|
||||||
return parser.parse_args(arguments)
|
return parser.parse_args(arguments)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(): # pragma: no cover
|
||||||
try:
|
try:
|
||||||
args = parse_arguments(*sys.argv[1:])
|
args = parse_arguments(*sys.argv[1:])
|
||||||
|
|
||||||
|
|
14
borgmatic/tests/integration/commands/test_convert_config.py
Normal file
14
borgmatic/tests/integration/commands/test_convert_config.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
from borgmatic.commands import convert_config as module
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_arguments_with_no_arguments_uses_defaults():
|
||||||
|
parser = module.parse_arguments()
|
||||||
|
|
||||||
|
assert parser.source_filename == module.DEFAULT_SOURCE_CONFIG_FILENAME
|
||||||
|
assert parser.destination_filename == module.DEFAULT_DESTINATION_CONFIG_FILENAME
|
||||||
|
|
||||||
|
def test_parse_arguments_with_filename_arguments_overrides_defaults():
|
||||||
|
parser = module.parse_arguments('--source', 'config', '--destination', 'config.yaml')
|
||||||
|
|
||||||
|
assert parser.source_filename == 'config'
|
||||||
|
assert parser.destination_filename == 'config.yaml'
|
12
borgmatic/tests/integration/commands/test_generate_config.py
Normal file
12
borgmatic/tests/integration/commands/test_generate_config.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
from borgmatic.commands import generate_config as module
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_arguments_with_no_arguments_uses_defaults():
|
||||||
|
parser = module.parse_arguments()
|
||||||
|
|
||||||
|
assert parser.destination_filename == module.DEFAULT_DESTINATION_CONFIG_FILENAME
|
||||||
|
|
||||||
|
def test_parse_arguments_with_filename_argument_overrides_defaults():
|
||||||
|
parser = module.parse_arguments('--destination', 'config.yaml')
|
||||||
|
|
||||||
|
assert parser.destination_filename == 'config.yaml'
|
Loading…
Reference in a new issue