1
0
mirror of https://github.com/venthur/blag.git synced 2025-11-25 20:52:43 +00:00

test parse_args

This commit is contained in:
Bastian Venthur
2021-02-22 21:38:15 +01:00
parent 2dcad8d8c0
commit 5639b38da3
2 changed files with 36 additions and 3 deletions

View File

@@ -32,12 +32,12 @@ def main(args=None):
args.func(args)
def parse_args(args):
def parse_args(args=None):
"""Parse command line arguments.
Paramters
---------
args :
args : List[str]
optional parameters, used for testing
Returns
@@ -76,7 +76,7 @@ def parse_args(args):
quickstart_parser = commands.add_parser('quickstart')
quickstart_parser.set_defaults(func=quickstart)
return parser.parse_args()
return parser.parse_args(args)
def get_config(configfile):

View File

@@ -16,3 +16,36 @@ def test_generate_feed(outdir):
articles = []
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
assert os.path.exists(f'{outdir}/atom.xml')
def test_parse_args_build():
# test default args
args = blag.parse_args(['build'])
assert args.input_dir == 'content'
assert args.output_dir == 'build'
assert args.template_dir == 'templates'
assert args.static_dir == 'static'
# input dir
args = blag.parse_args(['build', '-i', 'foo'])
assert args.input_dir == 'foo'
args = blag.parse_args(['build', '--input-dir', 'foo'])
assert args.input_dir == 'foo'
# output dir
args = blag.parse_args(['build', '-o', 'foo'])
assert args.output_dir == 'foo'
args = blag.parse_args(['build', '--output-dir', 'foo'])
assert args.output_dir == 'foo'
# template dir
args = blag.parse_args(['build', '-t', 'foo'])
assert args.template_dir == 'foo'
args = blag.parse_args(['build', '--template-dir', 'foo'])
assert args.template_dir == 'foo'
# static dir
args = blag.parse_args(['build', '-s', 'foo'])
assert args.static_dir == 'foo'
args = blag.parse_args(['build', '--static-dir', 'foo'])
assert args.static_dir == 'foo'