mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 07:45:44 +00:00
updating tests
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import pathlib
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tembo.journal.pages import PageCreator
|
from tembo.journal.pages import PageCreator
|
||||||
@@ -8,24 +10,58 @@ def test_page_creator_convert_to_path_missing_base_path(caplog):
|
|||||||
base_path = "/some/nonexistent/path"
|
base_path = "/some/nonexistent/path"
|
||||||
page_path = "some_page"
|
page_path = "some_page"
|
||||||
filename = "some_filename"
|
filename = "some_filename"
|
||||||
extension = "some_extension"
|
extension = "ex"
|
||||||
|
|
||||||
# act
|
# act
|
||||||
with pytest.raises(SystemExit) as system_exit:
|
with pytest.raises(SystemExit) as system_exit:
|
||||||
PageCreator._convert_to_path(
|
PageCreator._convert_to_path(
|
||||||
base_path=base_path, page_path=page_path, filename=filename, extension=extension
|
base_path=base_path,
|
||||||
|
page_path=page_path,
|
||||||
|
filename=filename,
|
||||||
|
extension=extension,
|
||||||
)
|
)
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
assert system_exit.value.code == 1
|
assert system_exit.value.code == 1
|
||||||
assert caplog.records[0].levelname == "CRITICAL"
|
assert caplog.records[0].levelname == "CRITICAL"
|
||||||
assert caplog.records[0].message == "Tembo base path of /some/nonexistent/path does not exist - exiting"
|
assert (
|
||||||
|
caplog.records[0].message
|
||||||
|
== "Tembo base path of /some/nonexistent/path does not exist - exiting"
|
||||||
|
)
|
||||||
|
|
||||||
# @pytest.mark.parametrize([])
|
|
||||||
def test_page_creator_convert_to_path(shared_datadir):
|
@pytest.mark.parametrize(
|
||||||
|
"page_path,filename,extension",
|
||||||
|
[
|
||||||
|
("some_pagepath", "some_filename", "ex"),
|
||||||
|
("some pagepath", "some filename", "ex"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_page_creator_convert_to_path_full_path_to_file(
|
||||||
|
page_path, filename, extension, tmpdir
|
||||||
|
):
|
||||||
# arrange
|
# arrange
|
||||||
|
path_to_file = (
|
||||||
|
pathlib.Path(tmpdir)
|
||||||
|
/ pathlib.Path(page_path)
|
||||||
|
/ pathlib.Path(filename).with_suffix(f".{extension}")
|
||||||
|
)
|
||||||
|
|
||||||
# act
|
# act
|
||||||
|
converted_path = PageCreator._convert_to_path(
|
||||||
|
tmpdir, page_path, filename, extension
|
||||||
|
)
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
pass
|
assert str(path_to_file).replace(" ", "_") == str(converted_path)
|
||||||
|
|
||||||
|
|
||||||
|
def test_page_creator_convert_to_path_full_path_no_file(tmpdir):
|
||||||
|
# arrange
|
||||||
|
full_path = pathlib.Path("/some/path")
|
||||||
|
|
||||||
|
# act
|
||||||
|
converted_path = PageCreator._convert_to_path("", "/some/path", "", "")
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert str(full_path).replace(" ", "_") == str(converted_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user