refactor: Move templating to separate file

This commit is contained in:
Marty Oehme 2023-09-19 17:35:39 +02:00
parent e633c0335e
commit 4eb983d9e3
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
7 changed files with 97 additions and 41 deletions

View file

@ -1,14 +1,49 @@
import chevron
from papis_extract.annotation_data import Markdown
from papis_extract.templating import Markdown, Csv
def test_template_markers():
...
def test_markdown_default():
fmt = Markdown()
assert chevron.render(fmt.string, {
"file": "somefile/somewhere.pdf",
"quote": "I am quote",
"note": "and including note.",
"page": 46,
"tag": "important",
"type": "highlight",
}) == "#important\n> I am quote [p. 46]\n NOTE: and including note."
assert (
chevron.render(
fmt.string,
{
"file": "somefile/somewhere.pdf",
"quote": "I am quote",
"note": "and including note.",
"page": 46,
"tag": "important",
"type": "highlight",
},
)
== "#important\n> I am quote [p. 46]\n NOTE: and including note."
)
def test_csv_string():
fmt = Csv()
assert (
chevron.render(
fmt.string,
{
"file": "somefile/somewhere.pdf",
"quote": "I am quote",
"note": "and including note.",
"page": 46,
"tag": "important",
"type": "highlight",
},
)
== "highlight, important, 46, "
"I am quote, and including note., somefile/somewhere.pdf"
)
def test_csv_header():
fmt = Csv()
assert chevron.render(fmt.header, {}) == "type, tag, page, quote, note, file"