adding latest tests

This commit is contained in:
2021-10-30 20:24:56 +01:00
parent a6ec5a9f35
commit 86ec115c9f
6 changed files with 94 additions and 48 deletions

View File

@@ -15,7 +15,7 @@ def test_page_creator_convert_to_path_missing_base_path(caplog):
# act
with pytest.raises(SystemExit) as system_exit:
PageCreator._convert_to_path(
PageCreator._convert_base_path_to_path(
base_path=base_path,
page_path=page_path,
filename=filename,
@@ -50,7 +50,7 @@ def test_page_creator_convert_to_path_full_path_to_file(
base_path = tmpdir
# act
converted_path = PageCreator._convert_to_path(
converted_path = PageCreator._convert_base_path_to_path(
base_path, page_path, filename, extension
)
@@ -67,7 +67,7 @@ def test_page_creator_convert_to_path_full_path_no_file(tmpdir):
extension = ""
# act
converted_path = PageCreator._convert_to_path(
converted_path = PageCreator._convert_base_path_to_path(
base_path, page_path, filename, extension
)

View File

@@ -1,13 +1,31 @@
import pytest
from tembo.journal.pages import PageCreatorOptions
from tembo.journal.pages import PageCreatorOptions, ScopedPageCreator
def test_scoped_page_creator_create_page_missing_base_path():
def test_create_page_base_path_does_not_exist(tmpdir, caplog):
# arrange
options = PageCreatorOptions()
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
pass
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"