mirror of
https://github.com/dtomlinson91/tembo.git
synced 2025-12-22 06:15:45 +00:00
adding latest
This commit is contained in:
@@ -13,6 +13,7 @@ Documentation:
|
||||
☐ Document using `__main__.py` and `cli.py`
|
||||
Use Duty as an example
|
||||
|
||||
☐ Document regex usage
|
||||
☐ Write documentation using `mkdocs`
|
||||
☐ Look at how to use github actions
|
||||
Use <https://github.com/pdm-project/pdm/tree/main/.github/workflows> for an example
|
||||
|
||||
@@ -43,6 +43,7 @@ class PageCreatorOptions:
|
||||
|
||||
|
||||
class PageCreator:
|
||||
@abstractmethod
|
||||
def __init__(self, options: PageCreatorOptions) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -52,7 +53,7 @@ class PageCreator:
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def create_page(self, options: PageCreatorOptions) -> Page:
|
||||
def create_page(self) -> Page:
|
||||
raise NotImplementedError
|
||||
|
||||
def _check_base_path_exists(self) -> None:
|
||||
@@ -111,16 +112,15 @@ class ScopedPageCreator(PageCreator):
|
||||
extension (str): extension of file.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
def __init__(self, options: PageCreatorOptions) -> None:
|
||||
self._all_input_tokens: list[str] = []
|
||||
self._options: PageCreatorOptions
|
||||
self._options = options
|
||||
|
||||
@property
|
||||
def options(self) -> PageCreatorOptions:
|
||||
return self._options
|
||||
|
||||
def create_page(self, options: PageCreatorOptions) -> Page:
|
||||
self._options = options
|
||||
def create_page(self) -> Page:
|
||||
self._check_base_path_exists()
|
||||
|
||||
self._all_input_tokens = self._get_input_tokens()
|
||||
@@ -130,7 +130,7 @@ class ScopedPageCreator(PageCreator):
|
||||
path = pathlib.Path(self._substitute_tokens(str(path)))
|
||||
|
||||
template_contents = self._load_template()
|
||||
if options.template_filename is not None:
|
||||
if self.options.template_filename is not None:
|
||||
template_contents = self._substitute_tokens(template_contents)
|
||||
|
||||
return ScopedPage(path, template_contents)
|
||||
|
||||
@@ -29,7 +29,7 @@ def test_create_page_base_path_does_not_exist(tmpdir):
|
||||
with pytest.raises(
|
||||
exceptions.BasePathDoesNotExistError
|
||||
) as base_path_does_not_exist_error:
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
|
||||
# assert
|
||||
assert (
|
||||
@@ -57,7 +57,7 @@ def test_create_page_template_file_does_not_exist(template_path, tmpdir):
|
||||
with pytest.raises(
|
||||
exceptions.TemplateFileNotFoundError
|
||||
) as template_file_not_found_error:
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
|
||||
# assert
|
||||
if template_path is None:
|
||||
@@ -88,7 +88,7 @@ def test_create_page_already_exists(datadir):
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
with pytest.raises(exceptions.ScopedPageAlreadyExists) as page_already_exists:
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
@@ -118,7 +118,7 @@ def test_create_page_without_template(tmpdir, caplog):
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
@@ -146,7 +146,7 @@ def test_create_page_with_template(datadir, caplog):
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
@@ -192,7 +192,7 @@ def test_create_tokened_page_tokens_in_template(
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
@@ -235,7 +235,7 @@ def test_create_tokened_page_tokens_in_filename(
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
@@ -262,7 +262,7 @@ def test_create_tokened_page_input_tokens_preserve_order(datadir, caplog):
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
@@ -292,7 +292,7 @@ def test_create_page_spaces_in_path(tmpdir, caplog):
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
@@ -318,7 +318,7 @@ def test_create_page_dot_in_extension(tmpdir, caplog):
|
||||
).with_suffix(f".{options.extension[1:]}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
scoped_page.save_to_disk()
|
||||
|
||||
# assert
|
||||
@@ -344,7 +344,7 @@ def test_create_page_str_representation(tmpdir):
|
||||
).with_suffix(f".{options.extension}")
|
||||
|
||||
# act
|
||||
scoped_page = ScopedPageCreator().create_page(options)
|
||||
scoped_page = ScopedPageCreator(options).create_page()
|
||||
|
||||
# assert
|
||||
assert str(scoped_page) == f"ScopedPage({scoped_page_file})"
|
||||
|
||||
Reference in New Issue
Block a user