From 69e281deaf601b39e8ef51d603e3e5e16dc71777 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 29 Jul 2020 19:27:35 -0700 Subject: basic toml transform helper --- python/tests/transform_toml.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 python/tests/transform_toml.py (limited to 'python/tests') diff --git a/python/tests/transform_toml.py b/python/tests/transform_toml.py new file mode 100644 index 00000000..d12ba027 --- /dev/null +++ b/python/tests/transform_toml.py @@ -0,0 +1,22 @@ + +import json + +from fatcat_tools import * +from fatcat_openapi_client import * +from import_crossref import crossref_importer +from fixtures import * + + +def test_basic_toml(crossref_importer): + with open('tests/files/crossref-works.single.json', 'r') as f: + # not a single line + raw = json.loads(f.read()) + r = crossref_importer.parse_record(raw) + r.state = 'active' + toml_str = entity_to_toml(r) + r2 = entity_from_toml(toml_str, ReleaseEntity) + assert r == r2 + + toml_str = entity_to_toml(r, pop_fields=['ident', 'revision', 'blah', 'extra']) + r3 = entity_from_toml(toml_str, ReleaseEntity) + assert r != r3 -- cgit v1.2.3