mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 08:05:43 +00:00
adding latest
This commit is contained in:
@@ -43,10 +43,10 @@ def test_create_page_template_file_does_not_exist(template_path, tmpdir):
|
||||
# arrange
|
||||
options = PageCreatorOptions(
|
||||
base_path=str(tmpdir),
|
||||
page_path="",
|
||||
filename="",
|
||||
extension="",
|
||||
name="",
|
||||
page_path="some_path",
|
||||
filename="some_filename",
|
||||
extension="some_extension",
|
||||
name="some_name",
|
||||
user_input=None,
|
||||
example=None,
|
||||
template_filename="template.md.tpl",
|
||||
@@ -241,3 +241,110 @@ def test_create_tokened_page_tokens_in_filename(
|
||||
# assert
|
||||
assert scoped_page_file.exists()
|
||||
assert caplog.records[0].message == f"Saved {scoped_page_file} to disk"
|
||||
|
||||
|
||||
def test_create_tokened_page_input_tokens_preserve_order(datadir, caplog):
|
||||
# arrange
|
||||
tokened_filename = "input_token_fourth_input_first_input"
|
||||
options = PageCreatorOptions(
|
||||
base_path=str(datadir),
|
||||
page_path="some_path",
|
||||
filename="input_token_{input3}_{input0}",
|
||||
extension="md",
|
||||
name="some_name",
|
||||
user_input=("first_input", "second_input", "third_input", "fourth_input"),
|
||||
example=None,
|
||||
template_filename="some_template_input_tokens_preserve_order.md.tpl",
|
||||
template_path=None,
|
||||
)
|
||||
scoped_page_file = (
|
||||
pathlib.Path(options.base_path) / options.page_path / tokened_filename
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
assert scoped_page_file.exists()
|
||||
assert caplog.records[0].message == f"Saved {scoped_page_file} to disk"
|
||||
with scoped_page_file.open(mode="r", encoding="utf-8") as scoped_page_contents:
|
||||
assert scoped_page_contents.readline() == "third_input second_input"
|
||||
|
||||
|
||||
def test_create_page_spaces_in_path(tmpdir, caplog):
|
||||
# arrange
|
||||
options = PageCreatorOptions(
|
||||
base_path=str(tmpdir),
|
||||
page_path="some path with a space",
|
||||
filename="some filename with a space",
|
||||
extension="md",
|
||||
name="some_name",
|
||||
user_input=None,
|
||||
example=None,
|
||||
template_filename=None,
|
||||
template_path=None,
|
||||
)
|
||||
scoped_page_file = (
|
||||
pathlib.Path(options.base_path)
|
||||
/ options.page_path.replace(" ", "_")
|
||||
/ options.filename.replace(" ", "_")
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
assert scoped_page_file.exists()
|
||||
assert caplog.records[0].message == f"Saved {scoped_page_file} to disk"
|
||||
|
||||
|
||||
def test_create_page_dot_in_extension(tmpdir, caplog):
|
||||
# arrange
|
||||
options = PageCreatorOptions(
|
||||
base_path=str(tmpdir),
|
||||
page_path="some_path",
|
||||
filename="some_filename",
|
||||
extension=".md",
|
||||
name="some_name",
|
||||
user_input=None,
|
||||
example=None,
|
||||
template_filename=None,
|
||||
template_path=None,
|
||||
)
|
||||
scoped_page_file = (
|
||||
pathlib.Path(options.base_path) / options.page_path / options.filename
|
||||
).with_suffix(f".{options.extension[1:]}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
assert scoped_page_file.exists()
|
||||
assert caplog.records[0].message == f"Saved {scoped_page_file} to disk"
|
||||
|
||||
|
||||
def test_create_page_str_representation(tmpdir):
|
||||
# arrange
|
||||
options = PageCreatorOptions(
|
||||
base_path=str(tmpdir),
|
||||
page_path="some_path",
|
||||
filename="some_filename",
|
||||
extension="md",
|
||||
name="some_name",
|
||||
user_input=None,
|
||||
example=None,
|
||||
template_filename=None,
|
||||
template_path=None,
|
||||
)
|
||||
scoped_page_file = (
|
||||
pathlib.Path(options.base_path) / options.page_path / options.filename
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
|
||||
# assert
|
||||
assert str(scoped_page) == f"ScopedPage({scoped_page_file})"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{input2} {input1}
|
||||
Reference in New Issue
Block a user