diff --git a/tests/test_blag.py b/tests/test_blag.py index 3fff868..703a77c 100644 --- a/tests/test_blag.py +++ b/tests/test_blag.py @@ -49,3 +49,35 @@ def test_parse_args_build(): assert args.static_dir == 'foo' args = blag.parse_args(['build', '--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)