Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openaire: fixed delete task #918

Merged
merged 4 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ CELERY_TASK_ROUTES = {
"invenio_files_rest.tasks.verify_checksum": {"queue": "low"},
"invenio_rdm_records.services.iiif.tasks.generate_tiles": {"queue": "low"},
"invenio_records_resources.tasks.extract_file_metadata": {"queue": "low"},
"invenio_users_resources.services.users.tasks.execute_moderation_actions": {"queue": "low"},
}

# Flask-Babel
Expand Down
4 changes: 2 additions & 2 deletions site/tests/openaire/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_on_delete(

mocked_session.delete.assert_called_once_with(
openaire_api_endpoint,
json={
params={
"originalId": f"10.5281/zenodo.{recid}",
"collectedFromId": "opendoar____::2659",
},
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_on_restore(
delete_calls = [
call(
openaire_api_endpoint,
json={
params={
"originalId": f"10.5281/zenodo.{recid}",
"collectedFromId": "opendoar____::2659",
},
Expand Down
2 changes: 1 addition & 1 deletion site/tests/openaire/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_openaire_delete_task(
openaire_url = running_app.app.config["OPENAIRE_API_URL"]
params = {"originalId": original_id, "collectedFromId": datasource_id}

mocked_session.delete.assert_called_once_with(openaire_url, json=params)
mocked_session.delete.assert_called_once_with(openaire_url, params=params)

# Assert key is not in cache : means success
assert not current_cache.cache.has(f"openaire_direct_index:{openaire_record.id}")
8 changes: 5 additions & 3 deletions site/zenodo_rdm/openaire/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ def openaire_delete(record_id=None, retry=True):

params = {"originalId": original_id, "collectedFromId": datasource_id}
req = openaire_request_factory()
res = req.delete(current_app.config["OPENAIRE_API_URL"], json=params)
res = req.delete(current_app.config["OPENAIRE_API_URL"], params=params)

if not res.ok:
raise OpenAIRERequestError(res.text)

if current_app.config["OPENAIRE_API_URL_BETA"]:
res_beta = req.delete(
current_app.config["OPENAIRE_API_URL_BETA"], json=params
current_app.config["OPENAIRE_API_URL_BETA"], params=params
)

if not res_beta.ok:
Expand Down Expand Up @@ -157,7 +157,9 @@ def retry_openaire_failures():
for key in failed_records:
try:
record_id = key.decode().split("openaire_direct_index:")[1]
record = records_service.read(system_identity, record_id)
record = records_service.read(
system_identity, record_id, include_deleted=True
)
is_deleted = record.data["deletion_status"]["is_deleted"]

# If record was deleted, try to remove it from OpenAIRE
Expand Down
2 changes: 2 additions & 0 deletions site/zenodo_rdm/subcommunities/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@


class SubCommunityRequestPayloadShema(Schema):
"""Schema for the payload of a subcommunity request."""

project_id = fields.String()

@validates("project_id")
Expand Down
Loading