From ff673bc6be7098efb5a6297d990955761bffc7e6 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 22 Oct 2021 13:45:47 -0700 Subject: to_legacy_dict() helper, and start adding some new fields --- tests/files/small.json | 20 ++------------------ tests/test_parse.py | 15 ++------------- 2 files changed, 4 insertions(+), 31 deletions(-) (limited to 'tests') diff --git a/tests/files/small.json b/tests/files/small.json index aa0da78..9dc8fba 100644 --- a/tests/files/small.json +++ b/tests/files/small.json @@ -27,34 +27,18 @@ "date": "2001", "id": "b0", "index": 0, - "issue": null, "journal": "Letters in the Alphabet", - "publisher": null, "title": "Everything is Wonderful", - "url": null, "volume": "20", - "unstructured": null, - "arxiv_id": null, - "doi": null, - "pages": "1-11", - "pmcid": null, - "pmid": null + "pages": "1-11" }, { "authors": [], "date": "2011-03-28", "id": "b1", "index": 1, - "issue": null, "journal": "The Dictionary", - "publisher": null, "title": "All about Facts", - "url": null, - "volume": "14", - "unstructured": null, - "arxiv_id": null, - "doi": null, - "pmcid": null, - "pmid": null + "volume": "14" } ], "abstract": "Everything you ever wanted to know about nothing", diff --git a/tests/test_parse.py b/tests/test_parse.py index 30b2926..825b561 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -75,25 +75,14 @@ def test_small_xml() -> None: assert doc == expected -def test_small_xml_json() -> None: +def test_small_xml_legacy() -> None: with open('tests/files/small.xml', 'r') as f: tei_xml = f.read() with open('tests/files/small.json', 'r') as f: json_form = json.loads(f.read()) - d = parse_document_xml(tei_xml).to_dict() - - # munge back to the old JSON format - d.update(d.pop('header')) - addr = d['authors'][0]['affiliation']['address'] - addr['postCode'] = addr.pop('post_code') - - # remove nulls from old JSON - for c in json_form['citations']: - for k in list(c.keys()): - if c[k] is None: - c.pop(k) + d = parse_document_xml(tei_xml).to_legacy_dict() assert d == json_form -- cgit v1.2.3