aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-21 14:10:56 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-21 14:10:56 -0800
commit1a15624e13bfe0a3bdddb1f0c5bf8940c9f04a04 (patch)
tree02029146a5bc5079ec2c85dc7dc88c47a69a5352 /python
parent42265350c9f0b7a5731103c191a807a691f8f2ef (diff)
downloadfatcat-1a15624e13bfe0a3bdddb1f0c5bf8940c9f04a04.tar.gz
fatcat-1a15624e13bfe0a3bdddb1f0c5bf8940c9f04a04.zip
more edit edgecases; editgroup status check
Diffstat (limited to 'python')
-rw-r--r--python/tests/api_entity_editing.py53
-rw-r--r--python/tests/api_entity_state.py18
-rw-r--r--python/tests/api_misc.py38
3 files changed, 108 insertions, 1 deletions
diff --git a/python/tests/api_entity_editing.py b/python/tests/api_entity_editing.py
index 3c0baa8e..d14b949b 100644
--- a/python/tests/api_entity_editing.py
+++ b/python/tests/api_entity_editing.py
@@ -40,6 +40,31 @@ def test_multiple_edits_same_group(api):
api.accept_editgroup(eg.id)
+def test_edit_after_accept(api):
+
+ c1 = CreatorEntity(display_name="test updates")
+
+ # create
+ eg = quick_eg(api)
+ c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
+ api.accept_editgroup(eg.id)
+
+ # should be unable to create an edit on an old editgroup
+ c2 = CreatorEntity(display_name="left")
+ try:
+ api.create_creator(c2, editgroup=eg.id)
+ assert False
+ except fatcat_client.rest.ApiException as e:
+ assert 400 <= e.status < 500
+ # TODO: need better message
+ #assert "accepted" in e.body
+
+ # cleanup
+ eg = quick_eg(api)
+ api.delete_creator(c1.ident)
+ api.accept_editgroup(eg.id)
+
+
def test_edit_deletion(api):
c1 = CreatorEntity(display_name="test edit updates")
@@ -88,6 +113,32 @@ def test_delete_accepted_edit(api):
api.accept_editgroup(eg.id)
# try to delete
- with pytest.raises(fatcat_client.rest.ApiException):
+ try:
api.delete_creator_edit(edit.edit_id)
+ assert False
+ except fatcat_client.rest.ApiException as e:
+ assert 400 <= e.status < 500
+ assert "accepted" in e.body
+
+
+def test_wip_revision(api):
+
+ c1 = CreatorEntity(display_name="test edit nugget")
+
+ # fetch revision before accepting
+ eg = quick_eg(api)
+ c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
+ rev = api.get_creator_revision(c1.revision)
+ assert "nugget" in rev.display_name
+ assert rev.state is None
+ assert rev.ident is None
+ assert rev.revision == c1.revision
+
+ # fetch revision after accepting
+ api.accept_editgroup(eg.id)
+ rev = api.get_creator_revision(c1.revision)
+ assert "nugget" in rev.display_name
+ assert rev.state is None
+ assert rev.ident is None
+ assert rev.revision == c1.revision
diff --git a/python/tests/api_entity_state.py b/python/tests/api_entity_state.py
index 35a8527a..43827dff 100644
--- a/python/tests/api_entity_state.py
+++ b/python/tests/api_entity_state.py
@@ -426,3 +426,21 @@ def test_required_entity_fields(api):
assert 400 <= e.status < 500
assert "title" in e.body
+def test_revert_current_status(api):
+
+ c1 = CreatorEntity(display_name="test updates")
+
+ # create
+ eg = quick_eg(api)
+ c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
+ api.accept_editgroup(eg.id)
+
+ # try to "revert" to current revision
+ eg = quick_eg(api)
+ c1_revert = CreatorEntity(revision=c1.revision)
+ try:
+ api.update_creator(c1.ident, c1_revert, editgroup=eg.id)
+ assert False
+ except fatcat_client.rest.ApiException as e:
+ assert 400 <= e.status < 500
+ assert "current" in e.body
diff --git a/python/tests/api_misc.py b/python/tests/api_misc.py
new file mode 100644
index 00000000..3510ea82
--- /dev/null
+++ b/python/tests/api_misc.py
@@ -0,0 +1,38 @@
+
+import json
+import pytest
+from copy import copy
+
+from fatcat_client import *
+from fatcat_client.rest import ApiException
+from fixtures import *
+
+
+def test_lookups(api):
+
+ api.lookup_creator(orcid='0000-0003-3118-6859')
+ api.lookup_container(issnl='1549-1277')
+ api.lookup_file(sha256='ffc1005680cb620eec4c913437dfabbf311b535cfe16cbaeb2faec1f92afc362')
+ api.lookup_release(pmid='54321')
+ api.lookup_release(isbn13='978-3-16-148410-0')
+
+def test_lookup_hide_extend(api):
+
+ r = api.lookup_release(doi='10.1371/journal.pmed.0020124')
+ assert len(r.refs) >= 2
+ assert r.files is None
+ assert r.container is None
+ assert len(r.container_id) > 10
+ assert r.abstracts == []
+
+ r = api.lookup_release(doi='10.1371/journal.pmed.0020124', expand='files', hide='refs,abstracts')
+ assert r.refs is None
+ assert len(r.files[0].sha1) == 40
+ assert r.container is None
+ assert r.abstracts is None
+
+ r = api.lookup_release(doi='10.1371/journal.pmed.0020124', expand='container,abstracts')
+ assert len(r.refs) >= 2
+ assert r.files is None
+ assert r.container.issnl
+ assert r.abstracts == []