Files
tembo/tests/test_journal/test_pages.py
2021-10-30 20:24:56 +01:00

32 lines
837 B
Python

import pytest
from tembo.journal.pages import PageCreatorOptions, ScopedPageCreator
def test_create_page_base_path_does_not_exist(tmpdir, caplog):
# arrange
base_path = str(tmpdir / "nonexistent" / "path")
options = PageCreatorOptions(
base_path=base_path,
page_path="",
filename="",
extension="",
name="",
user_input=None,
example=None,
template_filename=None,
template_path=None,
)
# act
with pytest.raises(SystemExit) as system_exit:
scoped_page_creator = ScopedPageCreator().create_page(options)
# assert
assert system_exit.value.code == 1
assert (
caplog.records[0].message
== f"Tembo base path of {base_path} does not exist - exiting"
)
assert caplog.records[0].levelname == "CRITICAL"