diff --git a/TODO.todo b/TODO.todo index 773c760..afa3906 100644 --- a/TODO.todo +++ b/TODO.todo @@ -21,6 +21,9 @@ Documentation: Use for an example ☐ Build the docs using a github action. + ☐ Document how to use pytest to read a logging message + + Functionality: ✔ Move any `tembo.CONFIG` calls out of `pages.py` and ensure these are passed in from the cli. @done(21-10-28 19:44) ✔ Make `config scope` a dict in `cli.py`. @done(21-10-28 19:44) @@ -28,6 +31,7 @@ Functionality: ✔ Add the `--example` output to the miscounted token message so the user knows the correct command to use. @done(21-10-29 00:15) ✔ Page options dataclass @done(21-10-28 20:09) ☐ Replace loggers with `click.echo` for command outputs. Keep logging messages for actual logging messages? + ☐ Replace scoped page creator inputs so that the whole class uses the options dict rather than the variables passed around. ☐ Use the python runner Duty ☐ Run tests diff --git a/poetry.lock b/poetry.lock index 389d4c6..1e1bc16 100644 --- a/poetry.lock +++ b/poetry.lock @@ -38,7 +38,7 @@ wrapt = ">=1.11,<1.14" name = "atomicwrites" version = "1.4.0" description = "Atomic file writes." -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -46,7 +46,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" name = "attrs" version = "21.2.0" description = "Classes Without Boilerplate" -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" @@ -181,7 +181,7 @@ typing-extensions = {version = ">=3.7.4.3", markers = "python_version < \"3.10\" name = "iniconfig" version = "1.1.1" description = "iniconfig: brain-dead simple config-ini parsing" -category = "dev" +category = "main" optional = false python-versions = "*" @@ -277,7 +277,7 @@ python-versions = "*" name = "packaging" version = "21.0" description = "Core utilities for Python packages" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -367,7 +367,7 @@ test = ["appdirs (==1.4.4)", "pytest (>=6)", "pytest-cov (>=2.7)", "pytest-mock name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -422,7 +422,7 @@ python-versions = "*" name = "py" version = "1.10.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "dev" +category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -555,7 +555,7 @@ pylint = ">=1.7" name = "pyparsing" version = "3.0.1" description = "Python parsing module" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -566,7 +566,7 @@ diagrams = ["jinja2", "railroad-diagrams"] name = "pytest" version = "6.2.5" description = "pytest: simple powerful testing with Python" -category = "dev" +category = "main" optional = false python-versions = ">=3.6" @@ -583,6 +583,17 @@ toml = "*" [package.extras] testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] +[[package]] +name = "pytest-datadir" +version = "1.3.1" +description = "pytest plugin for test data directories and files" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" + +[package.dependencies] +pytest = ">=2.7.0" + [[package]] name = "python-dateutil" version = "2.8.2" @@ -702,7 +713,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "d34e6da39ccdc2c892d1e9c263384b3b0a3ea59aaf0efb57c0b7d52d23635b56" +content-hash = "21a4ccbcf449e8ef748f7fffef2b07f245e58df5dc5c119591758f907c3c1b65" [metadata.files] altgraph = [ @@ -1026,6 +1037,10 @@ pytest = [ {file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"}, {file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"}, ] +pytest-datadir = [ + {file = "pytest-datadir-1.3.1.tar.gz", hash = "sha256:d3af1e738df87515ee509d6135780f25a15959766d9c2b2dbe02bf4fb979cb18"}, + {file = "pytest_datadir-1.3.1-py2.py3-none-any.whl", hash = "sha256:1847ed0efe0bc54cac40ab3fba6d651c2f03d18dd01f2a582979604d32e7621e"}, +] python-dateutil = [ {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, diff --git a/pyproject.toml b/pyproject.toml index 64759d9..2080f55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ click = "^8.0.3" pendulum = "^2.1.2" Jinja2 = "^3.0.2" panaetius = { path = "../panaetius", develop = true } +pytest-datadir = "^1.3.1" [tool.poetry.dev-dependencies] pytest = "^6.2.5" diff --git a/tembo/cli.py b/tembo/cli.py index f1685e9..973eccc 100644 --- a/tembo/cli.py +++ b/tembo/cli.py @@ -1,10 +1,9 @@ -import sys - import click import tembo from tembo.journal import pages + CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) diff --git a/tembo/journal/pages.py b/tembo/journal/pages.py index 5774942..c987e6e 100644 --- a/tembo/journal/pages.py +++ b/tembo/journal/pages.py @@ -6,9 +6,9 @@ import pathlib import re from typing import Collection +import pendulum import jinja2 from jinja2.exceptions import TemplateNotFound -import pendulum import tembo diff --git a/tests/test_journal/test_pages.py b/tests/test_journal/test_pages.py index e69de29..89c5d25 100644 --- a/tests/test_journal/test_pages.py +++ b/tests/test_journal/test_pages.py @@ -0,0 +1,31 @@ +import pytest + +from tembo.journal.pages import PageCreator + + +def test_page_creator_convert_to_path_missing_base_path(caplog): + # arrange + base_path = "/some/nonexistent/path" + page_path = "some_page" + filename = "some_filename" + extension = "some_extension" + + # act + with pytest.raises(SystemExit) as system_exit: + PageCreator._convert_to_path( + base_path=base_path, page_path=page_path, filename=filename, extension=extension + ) + + # assert + assert system_exit.value.code == 1 + assert caplog.records[0].levelname == "CRITICAL" + 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): + # arrange + + # act + + # assert + pass