Add tests for colors in configs

- Identifying invalid color configs
- Upgrading config from no colors -> colors
This commit is contained in:
Aaron Lichtman 2019-11-06 02:49:47 +01:00
parent 8053d250f4
commit eb1ed3c0cd
No known key found for this signature in database
GPG key ID: 22368077DE9F9903
5 changed files with 54 additions and 7 deletions

View file

@ -8,6 +8,7 @@ from dateutil import parser as date_parser
from ansiwrap import strip_color
from collections import defaultdict
import os
import ast
import json
import yaml
import keyring
@ -234,12 +235,17 @@ def journal_doesnt_exist(context, journal_name="default"):
@then('the config should have "{key}" set to "{value}"')
@then('the config for journal "{journal}" should have "{key}" set to "{value}"')
def config_var(context, key, value, journal=None):
t, value = value.split(":")
value = {
"bool": lambda v: v.lower() == "true",
"int": int,
"str": str
}[t](value)
if not value[0] == "{":
t, value = value.split(":")
value = {
"bool": lambda v: v.lower() == "true",
"int": int,
"str": str
}[t](value)
else:
# Handle value being a dictionary
value = ast.literal_eval(value)
config = util.load_config(install.CONFIG_FILE_PATH)
if journal:
config = config["journals"][journal]