aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-10-27 15:20:11 -0700
committerBryan Newbold <bnewbold@archive.org>2021-10-27 15:20:11 -0700
commit23458a69c2c7db89a66681843e4b9c7f643362c7 (patch)
tree34e84867092de8364d9978004fbcc051030a2117 /tests
parent6a34c0b8d5976bb35aecf3c794166e711b338f18 (diff)
downloadgrobid_tei_xml-23458a69c2c7db89a66681843e4b9c7f643362c7.tar.gz
grobid_tei_xml-23458a69c2c7db89a66681843e4b9c7f643362c7.zip
make fmt (black 21.9b0)
Diffstat (limited to 'tests')
-rw-r--r--tests/test_csl.py12
-rw-r--r--tests/test_parse.py82
2 files changed, 52 insertions, 42 deletions
diff --git a/tests/test_csl.py b/tests/test_csl.py
index 27c8c3e..e8ded91 100644
--- a/tests/test_csl.py
+++ b/tests/test_csl.py
@@ -3,7 +3,7 @@ from grobid_tei_xml import parse_document_xml
def test_small_xml_csl() -> None:
- with open('tests/files/small.xml', 'r') as f:
+ with open("tests/files/small.xml", "r") as f:
tei_xml = f.read()
d = parse_document_xml(tei_xml)
@@ -11,10 +11,7 @@ def test_small_xml_csl() -> None:
"type": "article-journal",
"title": "Dummy Example File",
"author": [
- {
- "given": "Brewster",
- "family": "Kahle"
- },
+ {"given": "Brewster", "family": "Kahle"},
{
"given": "J",
"family": "Doe",
@@ -29,10 +26,7 @@ def test_small_xml_csl() -> None:
"type": "article-journal",
"title": "Everything is Wonderful",
"author": [
- {
- "given": "A",
- "family": "Seaperson"
- },
+ {"given": "A", "family": "Seaperson"},
],
"container-title": "Letters in the Alphabet",
"issued": [[2001]],
diff --git a/tests/test_parse.py b/tests/test_parse.py
index 976d1b1..25529c4 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -11,31 +11,33 @@ from grobid_tei_xml.types import *
def test_small_xml() -> None:
- with open('tests/files/small.xml', 'r') as f:
+ with open("tests/files/small.xml", "r") as f:
tei_xml = f.read()
doc = parse_document_xml(tei_xml)
expected_body = """Introduction \nEverything starts somewhere, as somebody [1] once said. \n\n In Depth \n Meat \nYou know, for kids. \n Potatos \nQED."""
expected = GrobidDocument(
- grobid_version='0.5.1-SNAPSHOT',
- grobid_timestamp='2018-04-02T00:31+0000',
- language_code='en',
+ grobid_version="0.5.1-SNAPSHOT",
+ grobid_timestamp="2018-04-02T00:31+0000",
+ language_code="en",
header=GrobidBiblio(
title="Dummy Example File",
authors=[
- GrobidAuthor(full_name="Brewster Kahle",
- given_name="Brewster",
- surname="Kahle",
- affiliation=GrobidAffiliation(
- department="Faculty ofAgricultrial Engineering",
- laboratory="Plant Physiology Laboratory",
- institution="Technion-Israel Institute of Technology",
- address=GrobidAddress(
- post_code="32000",
- settlement="Haifa",
- country="Israel",
- ),
- )),
+ GrobidAuthor(
+ full_name="Brewster Kahle",
+ given_name="Brewster",
+ surname="Kahle",
+ affiliation=GrobidAffiliation(
+ department="Faculty ofAgricultrial Engineering",
+ laboratory="Plant Physiology Laboratory",
+ institution="Technion-Israel Institute of Technology",
+ address=GrobidAddress(
+ post_code="32000",
+ settlement="Haifa",
+ country="Israel",
+ ),
+ ),
+ ),
GrobidAuthor(
full_name="J Doe",
given_name="J",
@@ -80,9 +82,9 @@ def test_small_xml() -> None:
def test_small_xml_legacy() -> None:
- with open('tests/files/small.xml', 'r') as f:
+ with open("tests/files/small.xml", "r") as f:
tei_xml = f.read()
- with open('tests/files/small.json', 'r') as f:
+ with open("tests/files/small.json", "r") as f:
json_form = json.loads(f.read())
d = parse_document_xml(tei_xml).to_legacy_dict()
@@ -104,7 +106,7 @@ def test_invalid_xml() -> None:
def test_bytes() -> None:
- with open('tests/files/small.xml', 'rb') as f:
+ with open("tests/files/small.xml", "rb") as f:
tei_xml = f.read()
parse_document_xml(tei_xml)
@@ -113,7 +115,7 @@ def test_bytes() -> None:
def test_elementtree() -> None:
- with open('tests/files/small.xml', 'rb') as f:
+ with open("tests/files/small.xml", "rb") as f:
tei_xml = f.read()
parse_document_xml(xml.etree.ElementTree.parse(io.BytesIO(tei_xml))) # type: ignore
@@ -126,8 +128,10 @@ def test_example_grobid_tei_xml() -> None:
doc = parse_document_xml(blob)
- assert doc.header.title == \
- """Changes of patients' satisfaction with the health care services in Lithuanian Health Promoting Hospitals network"""
+ assert (
+ doc.header.title
+ == """Changes of patients' satisfaction with the health care services in Lithuanian Health Promoting Hospitals network"""
+ )
ref = [c for c in doc.citations or [] if c.id == "b12"][0]
assert ref.authors[0].full_name == "K Tasa"
@@ -138,8 +142,10 @@ def test_example_grobid_tei_xml() -> None:
assert ref.date == "1996"
assert ref.pages == "206-225"
assert ref.volume == "8"
- assert ref.unstructured == \
- """Tasa K, Baker R, Murray M. Using patient feedback for qua- lity improvement. Quality Management in Health Care 1996;8:206-19."""
+ assert (
+ ref.unstructured
+ == """Tasa K, Baker R, Murray M. Using patient feedback for qua- lity improvement. Quality Management in Health Care 1996;8:206-19."""
+ )
def test_single_citations_xml() -> None:
@@ -193,7 +199,10 @@ def test_single_citations_xml() -> None:
</biblStruct>"""
d = parse_citations_xml(citation_xml)[0]
- assert d.title == """Mesh migration following abdominal hernia repair: a comprehensive review"""
+ assert (
+ d.title
+ == """Mesh migration following abdominal hernia repair: a comprehensive review"""
+ )
assert d.authors[2].given_name == "L"
assert d.authors[2].middle_name == "R"
assert d.authors[2].surname == "Taveras"
@@ -211,7 +220,7 @@ def test_single_citations_xml() -> None:
def test_citation_list_xml() -> None:
- with open('tests/files/example_citation_list.xml', 'r') as f:
+ with open("tests/files/example_citation_list.xml", "r") as f:
tei_xml = f.read()
citations = parse_citations_xml(tei_xml)
@@ -237,17 +246,21 @@ def test_citation_list_xml() -> None:
assert citations[11].series_title == "Handbook of Optics"
assert citations[11].publisher == "McGRAW-HILL"
- assert citations[
- 12].title == "Implications of abandoned shoreline features above Glacial Lake Duluth levels along the north shore of the Superior Basin in the vicinity of the Brule River"
- assert citations[
- 12].book_title == "Paper presented at the 13th Biennial Meeting of the American Quaternary Association"
+ assert (
+ citations[12].title
+ == "Implications of abandoned shoreline features above Glacial Lake Duluth levels along the north shore of the Superior Basin in the vicinity of the Brule River"
+ )
+ assert (
+ citations[12].book_title
+ == "Paper presented at the 13th Biennial Meeting of the American Quaternary Association"
+ )
assert citations[12].institution == "University of Minnesota"
def test_grobid_070_document() -> None:
# more recent GROBID v0.7.0 output
- with open('tests/files/example_grobid_plos.tei.xml', 'r') as f:
+ with open("tests/files/example_grobid_plos.tei.xml", "r") as f:
tei_xml = f.read()
doc = parse_document_xml(tei_xml)
@@ -267,7 +280,10 @@ def test_grobid_070_document() -> None:
cite_b3 = doc.citations[3]
assert cite_b3.url == "http://unesdoc.unesco.org/ulis/"
- assert cite_b3.title == "Requirements for Global Implementation of the Strategic Plan for Coastal GOOS"
+ assert (
+ cite_b3.title
+ == "Requirements for Global Implementation of the Strategic Plan for Coastal GOOS"
+ )
assert cite_b3.authors
assert cite_b3.authors[0].surname == "Ioc-Unesco"
assert cite_b3.date == "2012"