stages/email: add test for non-existent directory

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-12-18 14:46:54 +01:00
parent 2ea7bd86e8
commit ac6afb2b82
2 changed files with 2 additions and 2 deletions

View File

@ -37,7 +37,7 @@ def get_template_choices():
dirs = [Path(x) for x in settings.TEMPLATES[0]["DIRS"]]
for template_dir in dirs:
if not template_dir.exists():
if not template_dir.exists() or not template_dir.is_dir():
continue
for template in template_dir.glob("**/*.html"):
path = str(template)

View File

@ -13,7 +13,7 @@ from authentik.stages.email.models import get_template_choices
def get_templates_setting(temp_dir: str) -> dict[str, Any]:
"""Patch settings TEMPLATE's dir property"""
templates_setting = settings.TEMPLATES
templates_setting[0]["DIRS"] = [temp_dir]
templates_setting[0]["DIRS"] = [temp_dir, "foo"]
return templates_setting