summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-20 15:24:22 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-20 15:24:22 -0700
commit29b31d042cbfde67d47213a9cd80aec0a8af6837 (patch)
tree7e9ab55f5236b31bb367bedb98f21b63193bcfc9 /python
parent6a6d7997d23bc667c23b03e1fa9119e47033a118 (diff)
downloadfatcat-29b31d042cbfde67d47213a9cd80aec0a8af6837.tar.gz
fatcat-29b31d042cbfde67d47213a9cd80aec0a8af6837.zip
entity create edit_extra tests
Diffstat (limited to 'python')
-rw-r--r--python/tests/api_containers.py2
-rw-r--r--python/tests/api_creators.py12
-rw-r--r--python/tests/api_files.py5
-rw-r--r--python/tests/api_filesets.py4
-rw-r--r--python/tests/api_releases.py4
-rw-r--r--python/tests/api_webcaptures.py4
6 files changed, 29 insertions, 2 deletions
diff --git a/python/tests/api_containers.py b/python/tests/api_containers.py
index 435c76af..ed2b2675 100644
--- a/python/tests/api_containers.py
+++ b/python/tests/api_containers.py
@@ -19,9 +19,11 @@ def test_container(api):
issnl="1234-567X",
wikidata_qid="Q954248",
extra=dict(a=1, b=2),
+ edit_extra=dict(test_key="containers rule"),
)
c1edit = api.create_container(eg.editgroup_id, c1)
+ assert c1edit.extra == c1.edit_extra
api.accept_editgroup(eg.editgroup_id)
c2 = api.get_container(c1edit.ident)
diff --git a/python/tests/api_creators.py b/python/tests/api_creators.py
index b3e1194c..28be6a91 100644
--- a/python/tests/api_creators.py
+++ b/python/tests/api_creators.py
@@ -19,9 +19,11 @@ def test_creators(api):
orcid="0000-0002-1825-0097",
wikidata_qid="Q9542248",
extra=dict(a=1, b=5),
+ edit_extra=dict(test_key="creators rule"),
)
c1edit = api.create_creator(eg.editgroup_id, c1)
+ assert c1edit.extra == c1.edit_extra
api.accept_editgroup(eg.editgroup_id)
c2 = api.get_creator(c1edit.ident)
@@ -41,10 +43,20 @@ def test_creators(api):
# get redirects (none)
assert api.get_creator_redirects(c2.ident) == []
+
+ # also try a batch insert
+ c3_eg = api.create_creator_auto_batch(CreatorAutoBatch(Editgroup(), [c1]))
+ c3edit = c3_eg.edits.creators[0]
+ assert c3edit.extra == c1.edit_extra
+ c3 = api.get_creator(c3edit.ident)
+
+ assert c1.display_name == c3.display_name
+ assert c1.extra == c3.extra
# delete
eg = quick_eg(api)
api.delete_creator(eg.editgroup_id, c2.ident)
+ api.delete_creator(eg.editgroup_id, c3.ident)
api.accept_editgroup(eg.editgroup_id)
c2 = api.get_creator(c2.ident)
assert c2.state == "deleted"
diff --git a/python/tests/api_files.py b/python/tests/api_files.py
index 8d7c94d5..5675071e 100644
--- a/python/tests/api_files.py
+++ b/python/tests/api_files.py
@@ -19,14 +19,16 @@ def test_file(api):
sha1="027e7ed3ea1a40e92dd2657a1e3c992b5dc45dd2",
sha256="f1f4f18a904e76818863ccbc6141fce92b0dcb47b0d6041aec98bc6806e393c3",
mimetype="application/pdf",
- extra=dict(a=2, b=5),
urls=[
FileUrl(url="https://web.archive.org/web/12345542/something.com/blah.pdf", rel="webarchive"),
],
release_ids=[],
+ extra=dict(a=2, b=5),
+ edit_extra=dict(test_key="files rule"),
)
f1edit = api.create_file(eg.editgroup_id, f1)
+ assert f1edit.extra == f1.edit_extra
api.accept_editgroup(eg.editgroup_id)
f2 = api.get_file(f1edit.ident)
@@ -39,6 +41,7 @@ def test_file(api):
assert f1.extra == f2.extra
assert f1.urls == f2.urls
assert f1.release_ids == f2.release_ids
+ assert f1.extra == f2.extra
# get revision
f2_rev = api.get_file_revision(f1edit.revision)
diff --git a/python/tests/api_filesets.py b/python/tests/api_filesets.py
index 4ed3d877..735eb72c 100644
--- a/python/tests/api_filesets.py
+++ b/python/tests/api_filesets.py
@@ -38,9 +38,12 @@ def test_fileset(api):
FilesetUrl(url="https://humble-host.com/~user123/dataset/", rel="web"),
],
release_ids = [r1edit.ident],
+ extra=dict(t=4, u=9),
+ edit_extra=dict(test_key="filesets rule"),
)
fs1edit = api.create_fileset(eg.editgroup_id, fs1)
+ assert fs1edit.extra == fs1.edit_extra
api.accept_editgroup(eg.editgroup_id)
fs2 = api.get_fileset(fs1edit.ident)
@@ -53,6 +56,7 @@ def test_fileset(api):
assert fs1.urls == fs2.urls
assert fs1.manifest == fs2.manifest
assert fs1.release_ids == fs2.release_ids
+ assert fs1.extra == fs2.extra
# expansion
r1 = api.get_release(r1edit.ident, expand="filesets")
diff --git a/python/tests/api_releases.py b/python/tests/api_releases.py
index 9e72eb65..c0c4ef90 100644
--- a/python/tests/api_releases.py
+++ b/python/tests/api_releases.py
@@ -45,7 +45,6 @@ def test_release(api):
publisher="some publisher",
language="en",
license_slug="CC-0",
- extra=dict(a=1, b=2),
contribs=[
ReleaseContrib(
given_name="Paul",
@@ -68,10 +67,13 @@ def test_release(api):
mimetype="text/plain",
lang="de"),
],
+ extra=dict(a=1, b=2),
+ edit_extra=dict(test_key="releases rule"),
)
r1.bogus = "asdf"
r1edit = api.create_release(eg.editgroup_id, r1)
+ assert r1edit.extra == r1.edit_extra
api.accept_editgroup(eg.editgroup_id)
r2 = api.get_release(r1edit.ident)
diff --git a/python/tests/api_webcaptures.py b/python/tests/api_webcaptures.py
index 2b3deb95..394d0e47 100644
--- a/python/tests/api_webcaptures.py
+++ b/python/tests/api_webcaptures.py
@@ -47,9 +47,12 @@ def test_webcapture(api):
FileUrl(rel="wayback", url="https://web.archive.org/web/"),
],
release_ids = [r1edit.ident],
+ extra=dict(c=1, b=2),
+ edit_extra=dict(test_key="webcaptures rule"),
)
wc1edit = api.create_webcapture(eg.editgroup_id, wc1)
+ assert wc1edit.extra == wc1.edit_extra
api.accept_editgroup(eg.editgroup_id)
wc2 = api.get_webcapture(wc1edit.ident)
@@ -72,6 +75,7 @@ def test_webcapture(api):
assert wc1.release_ids == wc2.release_ids
assert wc1.timestamp == wc2.timestamp
assert wc1.original_url == wc2.original_url
+ assert wc1.extra == wc2.extra
# TODO: check release expansion
r1 = api.get_release(r1edit.ident, expand="webcaptures")