summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-10-22 19:04:16 -0700
committerBryan Newbold <bnewbold@archive.org>2021-10-22 19:04:16 -0700
commitfa1e2b68fdc8426b0e6239c65361b605eba5fe7b (patch)
tree0649acda1c606b2483a67f5c5c4a1168f03afc5b /tests
parent3456336d3e4324a542c16b91734a8ebd8ef99ab9 (diff)
downloadgrobid_tei_xml-fa1e2b68fdc8426b0e6239c65361b605eba5fe7b.tar.gz
grobid_tei_xml-fa1e2b68fdc8426b0e6239c65361b605eba5fe7b.zip
initial CSL conversion test
Diffstat (limited to 'tests')
-rw-r--r--tests/test_csl.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_csl.py b/tests/test_csl.py
new file mode 100644
index 0000000..9c8bd5f
--- /dev/null
+++ b/tests/test_csl.py
@@ -0,0 +1,40 @@
+from grobid_tei_xml import parse_document_xml
+
+
+def test_small_xml_csl() -> None:
+
+ with open('tests/files/small.xml', 'r') as f:
+ tei_xml = f.read()
+
+ d = parse_document_xml(tei_xml)
+ assert d.to_csl_dict() == {
+ "type": "article-journal",
+ "title": "Dummy Example File",
+ "author": [
+ {
+ "given": "Brewster",
+ "family": "Kahle"
+ },
+ {
+ "given": "J",
+ "family": "Doe",
+ },
+ ],
+ "container-title": "Dummy Example File. Journal of Fake News. pp. 1-2. ISSN 1234-5678",
+ "issued": [[2000]],
+ }
+
+ assert d.citations[0].to_csl_dict() == {
+ "type": "article-journal",
+ "title": "Everything is Wonderful",
+ "author": [
+ {
+ "given": "A",
+ "family": "Seaperson"
+ },
+ ],
+ "container-title": "Letters in the Alphabet",
+ "issued": [[2001]],
+ "volume": 20,
+ "page": "1-11",
+ }