summaryrefslogtreecommitdiffstats
path: root/python/tests/api_entity_state.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-24 16:04:53 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-24 16:15:36 -0800
commit457c1612e29730e5b9ee2820c3ea813a1d2dd405 (patch)
tree1f3bd14dd0872bd2db752142b1f35cb0296635ae /python/tests/api_entity_state.py
parentb86e007b7469ebb22a806d38aca0bccf9078e80d (diff)
downloadfatcat-457c1612e29730e5b9ee2820c3ea813a1d2dd405.tar.gz
fatcat-457c1612e29730e5b9ee2820c3ea813a1d2dd405.zip
python impl of API ident harmonization
Diffstat (limited to 'python/tests/api_entity_state.py')
-rw-r--r--python/tests/api_entity_state.py136
1 files changed, 68 insertions, 68 deletions
diff --git a/python/tests/api_entity_state.py b/python/tests/api_entity_state.py
index 7c4ea901..823084c5 100644
--- a/python/tests/api_entity_state.py
+++ b/python/tests/api_entity_state.py
@@ -37,24 +37,24 @@ def test_redirect_entity(api):
# create two creators
eg = quick_eg(api)
- c1_edit = api.create_creator(c1, editgroup=eg.id)
- c2_edit = api.create_creator(c2, editgroup=eg.id)
+ c1_edit = api.create_creator(c1, editgroup_id=eg.editgroup_id)
+ c2_edit = api.create_creator(c2, editgroup_id=eg.editgroup_id)
c1 = api.get_creator(c1_edit.ident)
c2 = api.get_creator(c2_edit.ident)
assert c1_edit.prev_revision is None
assert c2_edit.prev_revision is None
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
redirs = api.get_creator_redirects(c1.ident)
assert redirs == []
# merge second into first
c2_redirect = CreatorEntity(redirect=c1.ident)
eg = quick_eg(api)
- merge_edit = api.update_creator(c2.ident, c2_redirect, editgroup=eg.id)
+ merge_edit = api.update_creator(c2.ident, c2_redirect, editgroup_id=eg.editgroup_id)
assert merge_edit.prev_revision == c2.revision
redirs = api.get_creator_redirects(c1.ident)
assert redirs == []
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
redirs = api.get_creator_redirects(c1.ident)
assert redirs == [c2.ident, ]
@@ -76,18 +76,18 @@ def test_redirect_entity(api):
# update first; check that get on second updates
c1.display_name = "test one one"
eg = quick_eg(api)
- update_edit = api.update_creator(c1.ident, c1, editgroup=eg.id)
+ update_edit = api.update_creator(c1.ident, c1, editgroup_id=eg.editgroup_id)
assert update_edit.prev_revision == c1.revision
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c2.ident)
assert res.state == "redirect"
assert res.display_name == "test one one"
# delete first; check that second is deleted (but state is redirect)
eg = quick_eg(api)
- del_edit = api.delete_creator(c1.ident, editgroup=eg.id)
+ del_edit = api.delete_creator(c1.ident, editgroup_id=eg.editgroup_id)
assert del_edit.prev_revision == update_edit.revision
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c1.ident)
assert res.state == "deleted"
assert res.display_name is None
@@ -100,9 +100,9 @@ def test_redirect_entity(api):
# undelete first; check that second is a redirect
eg = quick_eg(api)
- undelete_edit = api.update_creator(c1.ident, c1, editgroup=eg.id)
+ undelete_edit = api.update_creator(c1.ident, c1, editgroup_id=eg.editgroup_id)
assert undelete_edit.prev_revision is None
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c2.ident)
assert res.state == "redirect"
assert res.display_name == "test one one"
@@ -113,12 +113,12 @@ def test_redirect_entity(api):
assert c2.revision
assert c2.redirect is None
eg = quick_eg(api)
- update_edit = api.update_creator(c2.ident, c2, editgroup=eg.id)
+ update_edit = api.update_creator(c2.ident, c2, editgroup_id=eg.editgroup_id)
# prev_revision should be none after an un-redirect
assert update_edit.prev_revision is None
redirs = api.get_creator_redirects(c1.ident)
assert redirs == [c2.ident, ]
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c2.ident)
assert res.state == "active"
assert res.display_name == "test two"
@@ -131,7 +131,7 @@ def test_redirect_entity(api):
eg = quick_eg(api)
api.delete_creator(c1.ident)
api.delete_creator(c2.ident)
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
def test_delete_entity(api):
@@ -151,8 +151,8 @@ def test_delete_entity(api):
# create
eg = quick_eg(api)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c1.ident)
assert res.state == "active"
assert res.display_name == "test deletable"
@@ -162,11 +162,11 @@ def test_delete_entity(api):
# delete
eg = quick_eg(api)
- api.delete_creator(c1.ident, editgroup=eg.id)
+ api.delete_creator(c1.ident, editgroup_id=eg.editgroup_id)
with pytest.raises(fatcat_client.rest.ApiException):
# can't re-delete in same editgroup
- api.delete_creator(c1.ident, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.delete_creator(c1.ident, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c1.ident)
assert res.state == "deleted"
assert res.display_name is None
@@ -177,16 +177,16 @@ def test_delete_entity(api):
eg = quick_eg(api)
try:
# can't re-delete an entity
- api.delete_creator(c1.ident, editgroup=eg.id)
- #api.accept_editgroup(eg.id)
+ api.delete_creator(c1.ident, editgroup_id=eg.editgroup_id)
+ #api.accept_editgroup(eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500 # error is 4xx
# undelete
eg = quick_eg(api)
- api.update_creator(c1.ident, c1, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_creator(c1.ident, c1, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c1.ident)
assert res.state == "active"
assert res.display_name == "test deletable"
@@ -197,7 +197,7 @@ def test_delete_entity(api):
# cleanup
eg = quick_eg(api)
api.delete_creator(c1.ident)
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
def test_recursive_redirects_entity(api):
@@ -231,27 +231,27 @@ def test_recursive_redirects_entity(api):
# create three creators
eg = quick_eg(api)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
- c2 = api.get_creator(api.create_creator(c2, editgroup=eg.id).ident)
- c3 = api.get_creator(api.create_creator(c3, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
+ c2 = api.get_creator(api.create_creator(c2, editgroup_id=eg.editgroup_id).ident)
+ c3 = api.get_creator(api.create_creator(c3, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c3.ident)
assert res.display_name == "test three"
# redirect third to second
c3_redirect = CreatorEntity(redirect=c2.ident)
eg = quick_eg(api)
- api.update_creator(c3.ident, c3_redirect, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_creator(c3.ident, c3_redirect, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c3.ident)
assert res.display_name == "test two"
# redirect second to first: should be an error at merge time
c2_redirect = CreatorEntity(redirect=c1.ident)
eg = quick_eg(api)
- api.update_creator(c2.ident, c2_redirect, editgroup=eg.id)
+ api.update_creator(c2.ident, c2_redirect, editgroup_id=eg.editgroup_id)
with pytest.raises(fatcat_client.rest.ApiException):
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c2.ident)
assert res.display_name == "test two"
with pytest.raises(fatcat_client.rest.ApiException):
@@ -262,17 +262,17 @@ def test_recursive_redirects_entity(api):
# redirect first to third: should be an error at merge time
c1_redirect = CreatorEntity(redirect=c3.ident)
eg = quick_eg(api)
- api.update_creator(c1.ident, c1_redirect, editgroup=eg.id)
+ api.update_creator(c1.ident, c1_redirect, editgroup_id=eg.editgroup_id)
with pytest.raises(fatcat_client.rest.ApiException):
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c1.ident)
assert res.display_name == "test one"
# update second; check that third updated
c2.display_name = "test two updated"
eg = quick_eg(api)
- api.update_creator(c2.ident, c2, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_creator(c2.ident, c2, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c2.ident)
c2 = res
assert res.display_name == "test two updated"
@@ -284,8 +284,8 @@ def test_recursive_redirects_entity(api):
# delete second; check that third updated
eg = quick_eg(api)
- api.delete_creator(c2.ident, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.delete_creator(c2.ident, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c2.ident)
assert res.state == "deleted"
res = api.get_creator(c3.ident)
@@ -297,8 +297,8 @@ def test_recursive_redirects_entity(api):
# undelete second; check that third updated
eg = quick_eg(api)
c2_undelete = CreatorEntity(revision=c2.revision)
- api.update_creator(c2.ident, c2_undelete, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_creator(c2.ident, c2_undelete, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c2.ident)
assert res.state == "active"
assert res.display_name == "test two updated"
@@ -308,32 +308,32 @@ def test_recursive_redirects_entity(api):
# delete third (a redirect)
eg = quick_eg(api)
- api.delete_creator(c3.ident, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.delete_creator(c3.ident, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c3.ident)
assert res.state == "deleted"
assert res.display_name is None
# re-redirect third
eg = quick_eg(api)
- api.update_creator(c3.ident, c3_redirect, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_creator(c3.ident, c3_redirect, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c3.ident)
assert res.state == "redirect"
assert res.display_name == "test two updated"
# delete second, then delete third
eg = quick_eg(api)
- api.delete_creator(c2.ident, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.delete_creator(c2.ident, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c3.ident)
assert res.state == "redirect"
assert res.display_name is None
with pytest.raises(fatcat_client.rest.ApiException):
res = api.lookup_creator(orcid=o2)
eg = quick_eg(api)
- api.delete_creator(c3.ident, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.delete_creator(c3.ident, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c3.ident)
assert res.state == "deleted"
assert res.display_name is None
@@ -343,7 +343,7 @@ def test_recursive_redirects_entity(api):
api.delete_creator(c1.ident)
# c2 already deleted
# c3 already deleted
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
def test_self_redirect(api):
@@ -352,14 +352,14 @@ def test_self_redirect(api):
# create creator
eg = quick_eg(api)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
# redirect first to itself; should error on PUT
c1_redirect = CreatorEntity(redirect=c1.ident)
eg = quick_eg(api)
with pytest.raises(fatcat_client.rest.ApiException):
- merge_edit = api.update_creator(c1.ident, c1_redirect, editgroup=eg.id)
+ merge_edit = api.update_creator(c1.ident, c1_redirect, editgroup_id=eg.editgroup_id)
def test_wip_redirect(api):
@@ -367,20 +367,20 @@ def test_wip_redirect(api):
# create first
c1 = CreatorEntity(display_name="test one")
eg = quick_eg(api)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
# start creating second entity
c2 = CreatorEntity(display_name="test two")
eg = quick_eg(api)
- c2 = api.get_creator(api.create_creator(c2, editgroup=eg.id).ident)
+ c2 = api.get_creator(api.create_creator(c2, editgroup_id=eg.editgroup_id).ident)
assert c2.state == "wip"
# redirect first to second (should fail)
eg = quick_eg(api)
c1_redirect = CreatorEntity(redirect=c2.ident)
try:
- api.update_creator(c1.ident, c1_redirect, editgroup=eg.id)
+ api.update_creator(c1.ident, c1_redirect, editgroup_id=eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500
@@ -392,14 +392,14 @@ def test_create_redirect(api):
# create first
c1 = CreatorEntity(display_name="test one")
eg = quick_eg(api)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
# create second
c2 = CreatorEntity(display_name="blah", redirect=c1.ident)
eg = quick_eg(api)
try:
- api.create_creator(c2, editgroup=eg.id)
+ api.create_creator(c2, editgroup_id=eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500
@@ -408,12 +408,12 @@ def test_create_redirect(api):
# again with releases
r1 = ReleaseEntity(title="test one")
eg = quick_eg(api)
- r1 = api.get_release(api.create_release(r1, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ r1 = api.get_release(api.create_release(r1, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
r2 = ReleaseEntity(title="blah", redirect=c1.ident)
eg = quick_eg(api)
try:
- api.create_release(r2, editgroup=eg.id)
+ api.create_release(r2, editgroup_id=eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500
@@ -426,7 +426,7 @@ def test_required_entity_fields(api):
# Creator
try:
c1 = CreatorEntity()
- api.create_creator(c1, editgroup=eg.id)
+ api.create_creator(c1, editgroup_id=eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500
@@ -435,7 +435,7 @@ def test_required_entity_fields(api):
# Container
try:
c1 = ContainerEntity()
- api.create_container(c1, editgroup=eg.id)
+ api.create_container(c1, editgroup_id=eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500
@@ -444,7 +444,7 @@ def test_required_entity_fields(api):
# Release
try:
c1 = ReleaseEntity()
- api.create_release(c1, editgroup=eg.id)
+ api.create_release(c1, editgroup_id=eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500
@@ -456,14 +456,14 @@ def test_revert_current_status(api):
# create
eg = quick_eg(api)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_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)
+ api.update_creator(c1.ident, c1_revert, editgroup_id=eg.editgroup_id)
assert False
except fatcat_client.rest.ApiException as e:
assert 400 <= e.status < 500