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:
@@ -32,12 +32,12 @@ def main(args=None):
|
|||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
||||||
|
|
||||||
def parse_args(args):
|
def parse_args(args=None):
|
||||||
"""Parse command line arguments.
|
"""Parse command line arguments.
|
||||||
|
|
||||||
Paramters
|
Paramters
|
||||||
---------
|
---------
|
||||||
args :
|
args : List[str]
|
||||||
optional parameters, used for testing
|
optional parameters, used for testing
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
@@ -76,7 +76,7 @@ def parse_args(args):
|
|||||||
quickstart_parser = commands.add_parser('quickstart')
|
quickstart_parser = commands.add_parser('quickstart')
|
||||||
quickstart_parser.set_defaults(func=quickstart)
|
quickstart_parser.set_defaults(func=quickstart)
|
||||||
|
|
||||||
return parser.parse_args()
|
return parser.parse_args(args)
|
||||||
|
|
||||||
|
|
||||||
def get_config(configfile):
|
def get_config(configfile):
|
||||||
|
|||||||
@@ -16,3 +16,36 @@ def test_generate_feed(outdir):
|
|||||||
articles = []
|
articles = []
|
||||||
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
|
blag.generate_feed(articles, outdir, ' ', ' ', ' ', ' ')
|
||||||
assert os.path.exists(f'{outdir}/atom.xml')
|
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'
|
||||||
|
|||||||
Reference in New Issue
Block a user