aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/tests/api_entity_editing.py39
-rw-r--r--python/tests/fixtures.py39
2 files changed, 78 insertions, 0 deletions
diff --git a/python/tests/api_entity_editing.py b/python/tests/api_entity_editing.py
index bb45b280..eff0ca30 100644
--- a/python/tests/api_entity_editing.py
+++ b/python/tests/api_entity_editing.py
@@ -142,3 +142,42 @@ def test_wip_revision(api):
assert rev.ident is None
assert rev.revision == c1.revision
+
+def test_edit_get_all(api_dummy_entities):
+
+ ade = api_dummy_entities
+ api = ade['api']
+ eg = api.get_editgroup(ade['editgroup'].editgroup_id)
+
+ assert api.get_creator_edit(eg.edits.creators[0].edit_id)
+ assert api.get_container_edit(eg.edits.containers[0].edit_id)
+ assert api.get_file_edit(eg.edits.files[0].edit_id)
+ assert api.get_fileset_edit(eg.edits.filesets[0].edit_id)
+ assert api.get_webcapture_edit(eg.edits.webcaptures[0].edit_id)
+ assert api.get_release_edit(eg.edits.releases[0].edit_id)
+ assert api.get_work_edit(eg.edits.works[0].edit_id)
+
+def test_edit_delete_all(api_dummy_entities):
+
+ ade = api_dummy_entities
+ api = ade['api']
+ eg = api.get_editgroup(ade['editgroup'].editgroup_id)
+
+ api.delete_creator_edit(eg.edits.creators[0].edit_id)
+ api.delete_container_edit(eg.edits.containers[0].edit_id)
+ api.delete_file_edit(eg.edits.files[0].edit_id)
+ api.delete_fileset_edit(eg.edits.filesets[0].edit_id)
+ api.delete_webcapture_edit(eg.edits.webcaptures[0].edit_id)
+ api.delete_release_edit(eg.edits.releases[0].edit_id)
+ api.delete_work_edit(eg.edits.works[0].edit_id)
+
+ # verify deletion
+ eg = api.get_editgroup(ade['editgroup'].editgroup_id)
+ assert len(eg.edits.creators) == 0
+ assert len(eg.edits.containers) == 0
+ assert len(eg.edits.files) == 0
+ assert len(eg.edits.filesets) == 0
+ assert len(eg.edits.webcaptures) == 0
+ assert len(eg.edits.releases) == 0
+ assert len(eg.edits.works) == 0
+
diff --git a/python/tests/fixtures.py b/python/tests/fixtures.py
index 478fdd79..9d4caac5 100644
--- a/python/tests/fixtures.py
+++ b/python/tests/fixtures.py
@@ -8,6 +8,7 @@ from dotenv import load_dotenv
import fatcat_web
import fatcat_client
+from fatcat_client import *
from fatcat_tools import authenticated_api
@pytest.fixture
@@ -38,6 +39,44 @@ def api():
api_client.editor_id = "aaaaaaaaaaaabkvkaaaaaaaaae"
return api_client
+@pytest.fixture
+def api_dummy_entities(api):
+ """
+ This is a sort of bleh fixture. Should probably create an actual
+ object/class with create/accept/clean-up methods?
+ """
+
+ c1 = CreatorEntity(display_name="test creator deletion")
+ j1 = ContainerEntity(name="test journal deletion")
+ r1 = ReleaseEntity(title="test release creator deletion")
+ f1 = FileEntity()
+ fs1 = FilesetEntity()
+ wc1 = WebcaptureEntity(
+ timestamp="2000-01-01T12:34:56Z",
+ original_url="http://example.com/",
+ )
+
+ eg = quick_eg(api)
+ c1 = api.get_creator(api.create_creator(c1, editgroup_id=eg.editgroup_id).ident)
+ j1 = api.get_container(api.create_container(j1, editgroup_id=eg.editgroup_id).ident)
+ r1 = api.get_release(api.create_release(r1, editgroup_id=eg.editgroup_id).ident)
+ w1 = api.get_work(r1.work_id)
+ f1 = api.get_file(api.create_file(f1, editgroup_id=eg.editgroup_id).ident)
+ fs1 = api.get_fileset(api.create_fileset(fs1, editgroup_id=eg.editgroup_id).ident)
+ wc1 = api.get_webcapture(api.create_webcapture(wc1, editgroup_id=eg.editgroup_id).ident)
+
+ return {
+ "api": api,
+ "editgroup": eg,
+ "creator": c1,
+ "container": j1,
+ "file": f1,
+ "fileset": fs1,
+ "webcapture": wc1,
+ "release": r1,
+ "work": w1,
+ }
+
def test_get_changelog_entry(api):
"""Check that fixture is working"""
cl = api.get_changelog_entry(1)