summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/fatcat_tools/importers/common.py12
-rw-r--r--python/fatcat_tools/importers/crossref.py14
-rw-r--r--python/fatcat_tools/importers/grobid_metadata.py10
-rw-r--r--python/fatcat_tools/importers/issn.py8
-rw-r--r--python/fatcat_tools/importers/matched.py20
-rw-r--r--python/fatcat_tools/importers/orcid.py8
-rw-r--r--python/tests/api_entity_editing.py52
-rw-r--r--python/tests/api_entity_state.py136
-rw-r--r--python/tests/import_grobid_metadata.py2
-rw-r--r--python/tests/import_matched.py2
-rw-r--r--python/tests/subentity_state.py82
11 files changed, 173 insertions, 173 deletions
diff --git a/python/fatcat_tools/importers/common.py b/python/fatcat_tools/importers/common.py
index 65976a21..e31cabf8 100644
--- a/python/fatcat_tools/importers/common.py
+++ b/python/fatcat_tools/importers/common.py
@@ -54,11 +54,11 @@ class FatcatImporter:
print("Processed {} lines, inserted {}, updated {}.".format(
self.counts['processed_lines'], self.counts['insert'], self.counts['update']))
- def create_row(self, row, editgroup=None):
+ def create_row(self, row, editgroup_id=None):
# sub-classes expected to implement this
raise NotImplementedError
- def create_batch(self, rows, editgroup=None):
+ def create_batch(self, rows, editgroup_id=None):
# sub-classes expected to implement this
raise NotImplementedError
@@ -68,14 +68,14 @@ class FatcatImporter:
fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
i = 0
for i, row in enumerate(source):
- self.create_row(row, editgroup=eg.id)
+ self.create_row(row, editgroup_id=eg.editgroup_id)
if i > 0 and (i % group_size) == 0:
- self.api.accept_editgroup(eg.id)
+ self.api.accept_editgroup(eg.editgroup_id)
eg = self.api.create_editgroup(
fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
self.counts['processed_lines'] += 1
if i == 0 or (i % group_size) != 0:
- self.api.accept_editgroup(eg.id)
+ self.api.accept_editgroup(eg.editgroup_id)
def process_batch(self, source, size=50, decode_kafka=False):
"""Reads and processes in batches (not API-call-per-)"""
@@ -85,7 +85,7 @@ class FatcatImporter:
self.counts['processed_lines'] += len(rows)
eg = self.api.create_editgroup(
fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
- self.create_batch(rows, editgroup=eg.id)
+ self.create_batch(rows, editgroup_id=eg.editgroup_id)
def process_csv_source(self, source, group_size=100, delimiter=','):
reader = csv.DictReader(source, delimiter=delimiter)
diff --git a/python/fatcat_tools/importers/crossref.py b/python/fatcat_tools/importers/crossref.py
index 13179207..d4d0de68 100644
--- a/python/fatcat_tools/importers/crossref.py
+++ b/python/fatcat_tools/importers/crossref.py
@@ -287,7 +287,7 @@ class CrossrefImporter(FatcatImporter):
extra=dict(crossref=extra))
return (re, ce)
- def create_row(self, row, editgroup=None):
+ def create_row(self, row, editgroup_id=None):
if row is None:
return
obj = json.loads(row)
@@ -295,13 +295,13 @@ class CrossrefImporter(FatcatImporter):
if entities is not None:
(re, ce) = entities
if ce is not None:
- container = self.api.create_container(ce, editgroup=editgroup)
+ container = self.api.create_container(ce, editgroup_id=editgroup_id)
re.container_id = container.ident
self._issnl_id_map[ce.issnl] = container.ident
- self.api.create_release(re, editgroup=editgroup)
+ self.api.create_release(re, editgroup_id=editgroup_id)
self.counts['insert'] += 1
- def create_batch(self, batch, editgroup=None):
+ def create_batch(self, batch, editgroup_id=None):
"""Current work/release pairing disallows batch creation of releases.
Could do batch work creation and then match against releases, but meh."""
release_batch = []
@@ -315,10 +315,10 @@ class CrossrefImporter(FatcatImporter):
if ce is not None:
ce_eg = self.api.create_editgroup(
fatcat_client.Editgroup(editor_id='aaaaaaaaaaaabkvkaaaaaaaaae'))
- container = self.api.create_container(ce, editgroup=ce_eg.id)
- self.api.accept_editgroup(ce_eg.id)
+ container = self.api.create_container(ce, editgroup_id=ce_eg.editgroup_id)
+ self.api.accept_editgroup(ce_eg.editgroup_id)
re.container_id = container.ident
self._issnl_id_map[ce.issnl] = container.ident
release_batch.append(re)
- self.api.create_release_batch(release_batch, autoaccept="true", editgroup=editgroup)
+ self.api.create_release_batch(release_batch, autoaccept="true", editgroup_id=editgroup_id)
self.counts['insert'] += len(release_batch)
diff --git a/python/fatcat_tools/importers/grobid_metadata.py b/python/fatcat_tools/importers/grobid_metadata.py
index 47a753a6..2cb97b01 100644
--- a/python/fatcat_tools/importers/grobid_metadata.py
+++ b/python/fatcat_tools/importers/grobid_metadata.py
@@ -130,7 +130,7 @@ class GrobidMetadataImporter(FatcatImporter):
sha1=sha1,
size=int(file_size),
mimetype=mimetype,
- releases=[],
+ release_ids=[],
urls=[],
)
@@ -147,7 +147,7 @@ class GrobidMetadataImporter(FatcatImporter):
return fe
- def create_row(self, row, editgroup=None):
+ def create_row(self, row, editgroup_id=None):
if not row:
return
fields = row.split('\t')
@@ -159,11 +159,11 @@ class GrobidMetadataImporter(FatcatImporter):
fe = self.parse_file_metadata(sha1_key, cdx, mimetype, file_size)
re = self.parse_grobid_json(grobid_meta)
if fe and re:
- release_entity = self.api.create_release(re, editgroup=editgroup)
+ release_entity = self.api.create_release(re, editgroup_id=editgroup_id)
# release ident can't already be in release list because we just
# created it
- fe.releases.append(release_entity.ident)
- file_entity = self.api.create_file(fe, editgroup=editgroup)
+ fe.release_ids.append(release_entity.ident)
+ file_entity = self.api.create_file(fe, editgroup_id=editgroup_id)
self.counts['insert'] += 1
# NB: batch mode not implemented
diff --git a/python/fatcat_tools/importers/issn.py b/python/fatcat_tools/importers/issn.py
index f702dc60..9b9ca63f 100644
--- a/python/fatcat_tools/importers/issn.py
+++ b/python/fatcat_tools/importers/issn.py
@@ -64,16 +64,16 @@ class IssnImporter(FatcatImporter):
extra=extra)
return ce
- def create_row(self, row, editgroup=None):
+ def create_row(self, row, editgroup_id=None):
ce = self.parse_issn_row(row)
if ce is not None:
- self.api.create_container(ce, editgroup=editgroup)
+ self.api.create_container(ce, editgroup_id=editgroup_id)
self.counts['insert'] += 1
- def create_batch(self, batch, editgroup=None):
+ def create_batch(self, batch, editgroup_id=None):
"""Reads and processes in batches (not API-call-per-line)"""
objects = [self.parse_issn_row(l)
for l in batch if (l is not None)]
objects = [o for o in objects if (o is not None)]
- self.api.create_container_batch(objects, autoaccept="true", editgroup=editgroup)
+ self.api.create_container_batch(objects, autoaccept="true", editgroup_id=editgroup_id)
self.counts['insert'] += len(objects)
diff --git a/python/fatcat_tools/importers/matched.py b/python/fatcat_tools/importers/matched.py
index 6f83dd23..5dbda27c 100644
--- a/python/fatcat_tools/importers/matched.py
+++ b/python/fatcat_tools/importers/matched.py
@@ -70,7 +70,7 @@ class MatchedImporter(FatcatImporter):
if fe is None:
fe = fatcat_client.FileEntity(
sha1=sha1,
- releases=[],
+ release_ids=[],
urls=[],
)
@@ -89,10 +89,10 @@ class MatchedImporter(FatcatImporter):
re_list.add(re.ident)
if len(re_list) == 0:
return None
- if fe.releases == set(re_list):
+ if fe.release_ids == set(re_list):
return None
- re_list.update(fe.releases)
- fe.releases = list(re_list)
+ re_list.update(fe.release_ids)
+ fe.release_ids = list(re_list)
# parse URLs and CDX
existing_urls = [feu.url for feu in fe.urls]
@@ -125,26 +125,26 @@ class MatchedImporter(FatcatImporter):
fe.mimetype = obj.get('mimetype')
return fe
- def create_row(self, row, editgroup=None):
+ def create_row(self, row, editgroup_id=None):
obj = json.loads(row)
fe = self.parse_matched_dict(obj)
if fe is not None:
if fe.ident is None:
- self.api.create_file(fe, editgroup=editgroup)
+ self.api.create_file(fe, editgroup_id=editgroup_id)
self.counts['insert'] += 1
else:
- self.api.update_file(fe.ident, fe, editgroup=editgroup)
+ self.api.update_file(fe.ident, fe, editgroup_id=editgroup_id)
self.counts['update'] += 1
- def create_batch(self, batch, editgroup=None):
+ def create_batch(self, batch, editgroup_id=None):
"""Reads and processes in batches (not API-call-per-line)"""
objects = [self.parse_matched_dict(json.loads(l))
for l in batch if l != None]
new_objects = [o for o in objects if o != None and o.ident == None]
update_objects = [o for o in objects if o != None and o.ident != None]
for obj in update_objects:
- self.api.update_file(obj.ident, obj, editgroup=editgroup)
+ self.api.update_file(obj.ident, obj, editgroup_id=editgroup_id)
if len(new_objects) > 0:
- self.api.create_file_batch(new_objects, autoaccept="true", editgroup=editgroup)
+ self.api.create_file_batch(new_objects, autoaccept="true", editgroup_id=editgroup_id)
self.counts['update'] += len(update_objects)
self.counts['insert'] += len(new_objects)
diff --git a/python/fatcat_tools/importers/orcid.py b/python/fatcat_tools/importers/orcid.py
index 9e4767f9..fc4562d0 100644
--- a/python/fatcat_tools/importers/orcid.py
+++ b/python/fatcat_tools/importers/orcid.py
@@ -57,17 +57,17 @@ class OrcidImporter(FatcatImporter):
extra=extra)
return ce
- def create_row(self, row, editgroup=None):
+ def create_row(self, row, editgroup_id=None):
obj = json.loads(row)
ce = self.parse_orcid_dict(obj)
if ce is not None:
- self.api.create_creator(ce, editgroup=editgroup)
+ self.api.create_creator(ce, editgroup_id=editgroup_id)
self.counts['insert'] += 1
- def create_batch(self, batch, editgroup=None):
+ def create_batch(self, batch, editgroup_id=None):
"""Reads and processes in batches (not API-call-per-line)"""
objects = [self.parse_orcid_dict(json.loads(l))
for l in batch if l != None]
objects = [o for o in objects if o != None]
- self.api.create_creator_batch(objects, autoaccept="true", editgroup=editgroup)
+ self.api.create_creator_batch(objects, autoaccept="true", editgroup_id=editgroup_id)
self.counts['insert'] += len(objects)
diff --git a/python/tests/api_entity_editing.py b/python/tests/api_entity_editing.py
index d14b949b..377d47a8 100644
--- a/python/tests/api_entity_editing.py
+++ b/python/tests/api_entity_editing.py
@@ -14,30 +14,30 @@ def test_multiple_edits_same_group(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 multiple edits in the same group
eg = quick_eg(api)
c2 = CreatorEntity(display_name="left")
c3 = CreatorEntity(display_name="right")
- edit = api.update_creator(c1.ident, c2, editgroup=eg.id)
+ edit = api.update_creator(c1.ident, c2, editgroup_id=eg.editgroup_id)
# should fail with existing
with pytest.raises(fatcat_client.rest.ApiException):
- api.update_creator(c1.ident, c3, editgroup=eg.id)
+ api.update_creator(c1.ident, c3, editgroup_id=eg.editgroup_id)
# ... but succeed after deleting
api.delete_creator_edit(edit.edit_id)
- api.update_creator(c1.ident, c3, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_creator(c1.ident, c3, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c1.ident)
assert res.display_name == "right"
- eg = api.get_editgroup(eg.id)
+ eg = api.get_editgroup(eg.editgroup_id)
assert len(eg.edits.creators) == 1
# cleanup
eg = quick_eg(api)
api.delete_creator(c1.ident)
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
def test_edit_after_accept(api):
@@ -46,13 +46,13 @@ def test_edit_after_accept(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)
# should be unable to create an edit on an old editgroup
c2 = CreatorEntity(display_name="left")
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
@@ -62,7 +62,7 @@ def test_edit_after_accept(api):
# cleanup
eg = quick_eg(api)
api.delete_creator(c1.ident)
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
def test_edit_deletion(api):
@@ -71,36 +71,36 @@ def test_edit_deletion(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 multiple edits in the same group
c2 = CreatorEntity(display_name="update one")
eg = quick_eg(api)
- eg = api.get_editgroup(eg.id)
+ eg = api.get_editgroup(eg.editgroup_id)
assert len(eg.edits.creators) == 0
- edit = api.update_creator(c1.ident, c2, editgroup=eg.id)
- eg = api.get_editgroup(eg.id)
+ edit = api.update_creator(c1.ident, c2, editgroup_id=eg.editgroup_id)
+ eg = api.get_editgroup(eg.editgroup_id)
assert len(eg.edits.creators) == 1
api.delete_creator_edit(edit.edit_id)
- eg = api.get_editgroup(eg.id)
+ eg = api.get_editgroup(eg.editgroup_id)
assert len(eg.edits.creators) == 0
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
res = api.get_creator(c1.ident)
assert res.display_name == "test edit updates"
- eg = api.get_editgroup(eg.id)
+ eg = api.get_editgroup(eg.editgroup_id)
assert len(eg.edits.creators) == 0
# cleanup
eg = quick_eg(api)
api.delete_creator(c1.ident)
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
def test_empty_editgroup(api):
eg = quick_eg(api)
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
def test_delete_accepted_edit(api):
@@ -109,8 +109,8 @@ def test_delete_accepted_edit(api):
# create
eg = quick_eg(api)
- edit = api.create_creator(c1, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ edit = api.create_creator(c1, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
# try to delete
try:
@@ -127,7 +127,7 @@ def test_wip_revision(api):
# fetch revision before accepting
eg = quick_eg(api)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
rev = api.get_creator_revision(c1.revision)
assert "nugget" in rev.display_name
assert rev.state is None
@@ -135,7 +135,7 @@ def test_wip_revision(api):
assert rev.revision == c1.revision
# fetch revision after accepting
- api.accept_editgroup(eg.id)
+ api.accept_editgroup(eg.editgroup_id)
rev = api.get_creator_revision(c1.revision)
assert "nugget" in rev.display_name
assert rev.state is None
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
diff --git a/python/tests/import_grobid_metadata.py b/python/tests/import_grobid_metadata.py
index ee7040c9..459b247b 100644
--- a/python/tests/import_grobid_metadata.py
+++ b/python/tests/import_grobid_metadata.py
@@ -49,7 +49,7 @@ def test_file_metadata_parse(grobid_metadata_importer):
assert fe.urls[1].rel == "web"
assert fe.urls[0].url.startswith("https://web.archive.org/")
assert fe.urls[0].rel == "webarchive"
- assert len(fe.releases) == 0
+ assert len(fe.release_ids) == 0
def test_grobid_metadata_importer(grobid_metadata_importer):
with open('tests/files/example_grobid_metadata_lines.tsv', 'r') as f:
diff --git a/python/tests/import_matched.py b/python/tests/import_matched.py
index 4f2f0867..46a9ef85 100644
--- a/python/tests/import_matched.py
+++ b/python/tests/import_matched.py
@@ -31,4 +31,4 @@ def test_matched_dict_parse(matched_importer):
assert u.url.startswith("http://journals.plos.org")
if u.rel == "webarchive":
assert u.url.startswith("https://web.archive.org/")
- assert len(f.releases) == 1
+ assert len(f.release_ids) == 1
diff --git a/python/tests/subentity_state.py b/python/tests/subentity_state.py
index 74fce208..03362686 100644
--- a/python/tests/subentity_state.py
+++ b/python/tests/subentity_state.py
@@ -22,7 +22,7 @@ Current set of such references:
=> work -> release
"""
-def test_relation_stats(api, app):
+def test_relation_states(api, app):
j1 = ContainerEntity(name="test journal")
j2 = ContainerEntity(name="another test journal")
@@ -34,21 +34,21 @@ def test_relation_stats(api, app):
# WIP container
eg = quick_eg(api)
- j2 = api.get_container(api.create_container(j2, editgroup=eg.id).ident)
+ j2 = api.get_container(api.create_container(j2, editgroup_id=eg.editgroup_id).ident)
rv = app.get('/container/{}'.format(j2.ident))
assert rv.status_code == 200
# create inter-related entities
eg = quick_eg(api)
- j1 = api.get_container(api.create_container(j1, editgroup=eg.id).ident)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
+ j1 = api.get_container(api.create_container(j1, editgroup_id=eg.editgroup_id).ident)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
r1.container_id = j1.ident
r1.contribs = [ReleaseContrib(creator_id=c1.ident)]
- r1 = api.get_release(api.create_release(r1, editgroup=eg.id).ident)
- r2 = api.get_release(api.create_release(r2, editgroup=eg.id).ident)
- f1.releases = [r1.ident]
- f1 = api.get_file(api.create_file(f1, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ r1 = api.get_release(api.create_release(r1, editgroup_id=eg.editgroup_id).ident)
+ r2 = api.get_release(api.create_release(r2, editgroup_id=eg.editgroup_id).ident)
+ f1.release_ids = [r1.ident]
+ f1 = api.get_file(api.create_file(f1, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
r1 = api.get_release(r1.ident, expand="container,creators,files")
assert r1.container.name == "test journal"
@@ -61,8 +61,8 @@ def test_relation_stats(api, app):
# delete creator
eg = quick_eg(api)
- 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)
rv = app.get('/creator/{}'.format(c1.ident))
assert rv.status_code == 200 # TODO: HTTP status "Gone"?
@@ -82,8 +82,8 @@ def test_relation_stats(api, app):
# wip container
eg = quick_eg(api)
r1.container_id = j2.ident
- api.update_release(r1.ident, r1, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_release(r1.ident, r1, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
r1 = api.get_release(r1.ident, expand="container,creators,files")
assert r1.container_id == j2.ident
@@ -100,10 +100,10 @@ def test_relation_stats(api, app):
r2 = api.get_release(r2.ident, expand="container,creators,files")
assert r2.files == []
eg = quick_eg(api)
- api.update_release(r2.ident, ReleaseEntity(redirect=r1.ident), editgroup=eg.id)
- f2.releases = [r2.ident]
- f2 = api.get_file(api.create_file(f2, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ api.update_release(r2.ident, ReleaseEntity(redirect=r1.ident), editgroup_id=eg.editgroup_id)
+ f2.release_ids = [r2.ident]
+ f2 = api.get_file(api.create_file(f2, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
r2 = api.get_release(r2.ident, expand="container,creators,files")
assert r2.container_id == j2.ident
assert r2.container.name == "another test journal"
@@ -120,8 +120,8 @@ def test_relation_stats(api, app):
# delete release
eg = quick_eg(api)
- api.delete_release(r2.ident, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.delete_release(r2.ident, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
r2 = api.get_release(r2.ident, expand="container,creators,files")
assert r2.container_id is None
assert r2.container is None
@@ -147,27 +147,27 @@ def test_app_entity_states(api, app):
# create inter-related entities
eg = quick_eg(api)
- j1 = api.get_container(api.create_container(j1, editgroup=eg.id).ident)
- j2 = api.get_container(api.create_container(j2, editgroup=eg.id).ident)
- c1 = api.get_creator(api.create_creator(c1, editgroup=eg.id).ident)
- c2 = api.get_creator(api.create_creator(c2, editgroup=eg.id).ident)
+ j1 = api.get_container(api.create_container(j1, editgroup_id=eg.editgroup_id).ident)
+ j2 = api.get_container(api.create_container(j2, editgroup_id=eg.editgroup_id).ident)
+ 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)
r1.container_id = j1.ident
r1.contribs = [ReleaseContrib(creator_id=c1.ident)]
- r1 = api.get_release(api.create_release(r1, editgroup=eg.id).ident)
- r2 = api.get_release(api.create_release(r2, editgroup=eg.id).ident)
- f1.releases = [r1.ident]
- f1 = api.get_file(api.create_file(f1, editgroup=eg.id).ident)
- f2 = api.get_file(api.create_file(f2, editgroup=eg.id).ident)
- api.accept_editgroup(eg.id)
+ r1 = api.get_release(api.create_release(r1, editgroup_id=eg.editgroup_id).ident)
+ r2 = api.get_release(api.create_release(r2, editgroup_id=eg.editgroup_id).ident)
+ f1.release_ids = [r1.ident]
+ f1 = api.get_file(api.create_file(f1, editgroup_id=eg.editgroup_id).ident)
+ f2 = api.get_file(api.create_file(f2, editgroup_id=eg.editgroup_id).ident)
+ api.accept_editgroup(eg.editgroup_id)
# create redirects
eg = quick_eg(api)
- api.update_container(j2.ident, ContainerEntity(redirect=j1.ident), editgroup=eg.id)
- api.update_creator(c2.ident, CreatorEntity(redirect=c1.ident), editgroup=eg.id)
- api.update_file(f2.ident, FileEntity(redirect=f1.ident), editgroup=eg.id)
- api.update_release(r2.ident, ReleaseEntity(redirect=r1.ident), editgroup=eg.id)
- api.update_work(r2.work_id, WorkEntity(redirect=r1.work_id), editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.update_container(j2.ident, ContainerEntity(redirect=j1.ident), editgroup_id=eg.editgroup_id)
+ api.update_creator(c2.ident, CreatorEntity(redirect=c1.ident), editgroup_id=eg.editgroup_id)
+ api.update_file(f2.ident, FileEntity(redirect=f1.ident), editgroup_id=eg.editgroup_id)
+ api.update_release(r2.ident, ReleaseEntity(redirect=r1.ident), editgroup_id=eg.editgroup_id)
+ api.update_work(r2.work_id, WorkEntity(redirect=r1.work_id), editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
# all entities
rv = app.get('/container/{}'.format(j1.ident))
@@ -193,12 +193,12 @@ def test_app_entity_states(api, app):
# delete targets
eg = quick_eg(api)
- api.delete_container(j1.ident, editgroup=eg.id)
- api.delete_creator(c1.ident, editgroup=eg.id)
- api.delete_file(f1.ident, editgroup=eg.id)
- api.delete_release(r1.ident, editgroup=eg.id)
- api.delete_work(r1.work_id, editgroup=eg.id)
- api.accept_editgroup(eg.id)
+ api.delete_container(j1.ident, editgroup_id=eg.editgroup_id)
+ api.delete_creator(c1.ident, editgroup_id=eg.editgroup_id)
+ api.delete_file(f1.ident, editgroup_id=eg.editgroup_id)
+ api.delete_release(r1.ident, editgroup_id=eg.editgroup_id)
+ api.delete_work(r1.work_id, editgroup_id=eg.editgroup_id)
+ api.accept_editgroup(eg.editgroup_id)
# all entities
rv = app.get('/container/{}'.format(j1.ident))