1
0
mirror of https://github.com/venthur/blag.git synced 2025-11-25 12:42:41 +00:00

test for automatically appending trailing slash to base_url

This commit is contained in:
Bastian Venthur
2021-02-22 22:19:32 +01:00
parent e9a7da13e6
commit 3874d19371

View File

@@ -59,6 +59,7 @@ title = title
description = description description = description
author = a. u. thor author = a. u. thor
""" """
# happy path
with TemporaryDirectory() as dir: with TemporaryDirectory() as dir:
configfile = f'{dir}/config.ini' configfile = f'{dir}/config.ini'
with open(configfile, 'w') as fh: with open(configfile, 'w') as fh:
@@ -70,6 +71,7 @@ author = a. u. thor
assert config_parsed['description'] == 'description' assert config_parsed['description'] == 'description'
assert config_parsed['author'] == 'a. u. thor' assert config_parsed['author'] == 'a. u. thor'
# a missing required config causes a sys.exit
for x in 'base_url', 'title', 'description', 'author': for x in 'base_url', 'title', 'description', 'author':
config2 = '\n'.join([line config2 = '\n'.join([line
for line for line
@@ -81,3 +83,19 @@ author = a. u. thor
fh.write(config2) fh.write(config2)
with pytest.raises(SystemExit): with pytest.raises(SystemExit):
config_parsed = blag.get_config(configfile) config_parsed = blag.get_config(configfile)
# base_url gets / appended if it is missing
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/'