mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 20:52:43 +00:00
test config
This commit is contained in:
@@ -49,3 +49,35 @@ def test_parse_args_build():
|
|||||||
assert args.static_dir == 'foo'
|
assert args.static_dir == 'foo'
|
||||||
args = blag.parse_args(['build', '--static-dir', 'foo'])
|
args = blag.parse_args(['build', '--static-dir', 'foo'])
|
||||||
assert args.static_dir == 'foo'
|
assert args.static_dir == 'foo'
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_config():
|
||||||
|
config = """
|
||||||
|
[main]
|
||||||
|
base_url = https://example.com/
|
||||||
|
title = title
|
||||||
|
description = description
|
||||||
|
author = a. u. thor
|
||||||
|
"""
|
||||||
|
with TemporaryDirectory() as dir:
|
||||||
|
configfile = f'{dir}/config.ini'
|
||||||
|
with open(configfile, 'w') as fh:
|
||||||
|
fh.write(config)
|
||||||
|
|
||||||
|
config_parsed = blag.get_config(configfile)
|
||||||
|
assert config_parsed['base_url'] == 'https://example.com/'
|
||||||
|
assert config_parsed['title'] == 'title'
|
||||||
|
assert config_parsed['description'] == 'description'
|
||||||
|
assert config_parsed['author'] == 'a. u. thor'
|
||||||
|
|
||||||
|
for x in 'base_url', 'title', 'description', 'author':
|
||||||
|
config2 = '\n'.join([line
|
||||||
|
for line
|
||||||
|
in config.splitlines()
|
||||||
|
if not line.startswith(x)])
|
||||||
|
with TemporaryDirectory() as dir:
|
||||||
|
configfile = f'{dir}/config.ini'
|
||||||
|
with open(configfile, 'w') as fh:
|
||||||
|
fh.write(config2)
|
||||||
|
with pytest.raises(SystemExit):
|
||||||
|
config_parsed = blag.get_config(configfile)
|
||||||
|
|||||||
Reference in New Issue
Block a user