test: Fix formatting and annotation tests
This commit is contained in:
parent
ee4690f52b
commit
1e29642cba
3 changed files with 77 additions and 52 deletions
|
|
@ -1,25 +1,23 @@
|
|||
from papis.document import Document
|
||||
import pytest
|
||||
from papis_extract.annotation_data import Annotation
|
||||
from papis_extract.templating import Custom
|
||||
from papis_extract.annotation import Annotation
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"fmt_string,expected",
|
||||
[
|
||||
(Custom(string="{{quote}}"), "I am the text value"),
|
||||
("{{quote}}", "I am the text value"),
|
||||
(
|
||||
Custom(string="> {{quote}}\n{{#note}}Note: {{note}}{{/note}}"),
|
||||
"> {{quote}}\n{{#note}}Note: {{note}}{{/note}}",
|
||||
"> I am the text value\nNote: Whereas I represent the note",
|
||||
),
|
||||
(
|
||||
Custom(
|
||||
string="{{#note}}Note: {{note}}{{/note}}{{#page}}, p. {{page}}{{/page}}"
|
||||
),
|
||||
"{{#note}}Note: {{note}}{{/note}}{{#page}}, p. {{page}}{{/page}}",
|
||||
"Note: Whereas I represent the note",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_formatting(fmt_string, expected):
|
||||
def test_formatting_replacements(fmt_string, expected):
|
||||
sut = Annotation(
|
||||
"myfile",
|
||||
text="I am the text value",
|
||||
|
|
@ -28,6 +26,23 @@ def test_formatting(fmt_string, expected):
|
|||
|
||||
assert sut.format(fmt_string) == expected
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"fmt_string,expected",
|
||||
[
|
||||
("{{doc.title}}", "document-title"),
|
||||
("{{doc.title}}-{{doc.author}}", "document-title-document-author"),
|
||||
("{{quote}} ({{doc.author}})", "I am the text value (document-author)"),
|
||||
]
|
||||
)
|
||||
def test_formatting_document_access(fmt_string, expected):
|
||||
sut = Annotation(
|
||||
"myfile",
|
||||
text="I am the text value",
|
||||
content="Whereas I represent the note",
|
||||
)
|
||||
doc = Document(data= {"title": "document-title", "author": "document-author"})
|
||||
|
||||
assert sut.format(fmt_string, doc=doc) == expected
|
||||
|
||||
def test_colorname_matches_exact():
|
||||
sut = Annotation("testfile", colors=(1.0, 0.0, 0.0), minimum_similarity_color=1.0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue