test: Add tests for formatter sad paths

This commit is contained in:
Marty Oehme 2023-10-12 19:27:16 +02:00
parent f67ac8cdb3
commit c9736a5f32
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -6,6 +6,7 @@ from papis_extract.formatter import (
format_csv,
format_markdown,
format_markdown_atx,
format_markdown_setext,
)
an_doc: AnnotatedDocument = AnnotatedDocument(
@ -15,12 +16,7 @@ an_doc: AnnotatedDocument = AnnotatedDocument(
Annotation("myfile.pdf", text="my second text", content="with note"),
],
)
def test_markdown_default():
fmt = format_markdown
assert fmt([an_doc]) == (
"""============== ---------------
md_default_output = """============== ---------------
document-title - document-author
============== ---------------
@ -28,7 +24,11 @@ document-title - document-author
> my second text
NOTE: with note"""
)
def test_markdown_default():
fmt = format_markdown
assert fmt([an_doc]) == md_default_output
def test_markdown_atx():
@ -43,6 +43,11 @@ def test_markdown_atx():
)
def test_markdown_setext():
fmt = format_markdown_setext
assert fmt([an_doc]) == md_default_output
def test_count_default():
fmt = format_count
assert fmt([an_doc]) == ("""document-author - document-title: 2""")
@ -57,3 +62,19 @@ def test_csv_default():
'Highlight,,0,"my second text","with note","document-author",'
'"document-title","","myfile.pdf"'
)
# sadpath - no annotations contained for each format
def test_markdown_no_annotations():
d: AnnotatedDocument = AnnotatedDocument(Document(data={}), [])
assert format_markdown([d]) == ""
def test_count_no_annotations():
d: AnnotatedDocument = AnnotatedDocument(Document(data={}), [])
assert format_count([d]) == ""
def test_csv_no_annotations():
d: AnnotatedDocument = AnnotatedDocument(Document(data={}), [])
assert format_csv([d]) == "type,tag,page,quote,note,author,title,ref,file"