summaryrefslogtreecommitdiffstats
path: root/python/tests/transform_toml.py
diff options
context:
space:
mode:
authorbnewbold <bnewbold@archive.org>2020-08-03 18:00:41 +0000
committerbnewbold <bnewbold@archive.org>2020-08-03 18:00:41 +0000
commit4702bee24dde8bae64df76ad411a6d8329cc9bdf (patch)
tree221ec7bd8d77bddb2dec344c19253cca65156911 /python/tests/transform_toml.py
parent5037642d7775c638d035c2faed8094537dfaf94d (diff)
parent31f59b4b0ba7ff95b685c8826a7d019fb142f65c (diff)
downloadfatcat-4702bee24dde8bae64df76ad411a6d8329cc9bdf.tar.gz
fatcat-4702bee24dde8bae64df76ad411a6d8329cc9bdf.zip
Merge branch 'bnewbold-editing' into 'master'
editing improvements See merge request webgroup/fatcat!73
Diffstat (limited to 'python/tests/transform_toml.py')
-rw-r--r--python/tests/transform_toml.py22
1 files changed, 22 insertions, 0 deletions
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