adding latest tests

This commit is contained in:
2021-10-30 02:12:36 +01:00
parent be55e20e4d
commit 1f3fa4100d
5 changed files with 147 additions and 131 deletions

View File

@@ -50,6 +50,7 @@ def new(scope, inputs, dry_run, example):
Example: tembo new meeting my_presentation
"""
# get the name from the tembo config.yml
try:
_name_found = scope in [
@@ -86,6 +87,7 @@ def new(scope, inputs, dry_run, example):
"Key %s not found in config. yml - exiting", key_error
)
raise SystemExit(1) from key_error
# print the example to the user
if example:
tembo.logger.info(

View File

@@ -20,10 +20,10 @@ class PageCreatorOptions:
filename: str
extension: str
name: str
example: str | None
user_input: Collection[str]
template_filename: str | None
template_path: str | None
example: str | None = None
template_filename: str | None = None
template_path: str | None = None
class PageCreator:
@@ -60,7 +60,7 @@ class PageCreator:
) -> str:
# check for overriden template_path
if template_path is not None:
converted_template_path = self._convert_to_path("", template_path, "", "")
converted_template_path = pathlib.Path(template_path).expanduser()
else:
# default template_path is base_path / .templates
converted_template_path = self._convert_to_path(
@@ -132,6 +132,15 @@ class ScopedPageCreator(PageCreator):
)
return ScopedPage(path, template_contents)
def _get_template_contents(
self, template_filename: str | None, template_path: str | None
) -> str:
return (
self._load_template(self.base_path, template_filename, template_path)
if template_filename is not None
else ""
)
def _get_input_tokens(
self, template_filename: str | None, template_path: str | None
) -> list[str]:
@@ -168,15 +177,6 @@ class ScopedPageCreator(PageCreator):
)
raise SystemExit(1)
def _get_template_contents(
self, template_filename: str | None, template_path: str | None
) -> str:
return (
self._load_template(self.base_path, template_filename, template_path)
if template_filename is not None
else ""
)
def _substitute_tokens(
self,
tokenified_string: str,