Skip to content
Snippets Groups Projects
Commit 3a8b26bf authored by Vuillaume's avatar Vuillaume
Browse files

Hot fix sandbox test upload new version

parent 236d4d25
No related branches found
No related tags found
1 merge request!223Hot fix sandbox test upload new version
......@@ -98,10 +98,12 @@ class TestZenodoAPITokenSandbox(unittest.TestCase):
self.zenodo.erase_entry(new_record_id)
print(f"{new_record_id} created and deleted")
# update existing one
new_record_id = self.zenodo.upload_dir_content(tmpdirname, record_id=eossr_test_lib_id, publish=False)
self.zenodo.erase_entry(new_record_id)
print(f"{new_record_id} created and deleted")
# update existing record
# Test deactivated on July 2022 as making new versions of records seems not possible anymore on sandbox,
# and I am reluctant to do unit tests directly on Zenodo.
# new_record_id = self.zenodo.upload_dir_content(tmpdirname, record_id=eossr_test_lib_id, publish=False)
# self.zenodo.erase_entry(new_record_id)
# print(f"{new_record_id} created and deleted")
@pytest.mark.skipif(
os.getenv('SANDBOX_ZENODO_TOKEN_GARCIA') is None, reason="SANDBOX_ZENODO_TOKEN_GARCIA not defined"
......
......@@ -3,8 +3,10 @@ Simple code to delete all user entries that have not been published
"""
import argparse
import os
import warnings
from eossr.api.zenodo import ZenodoAPI
from eossr.api.zenodo.http_status import HTTPStatusError
def zenodo_cleanup(token, sandbox=True):
......@@ -22,7 +24,11 @@ def zenodo_cleanup(token, sandbox=True):
for rec in use.json():
if not rec['submitted']:
print(f"Record {rec['id']} ... ")
zen.erase_entry(rec['id'])
try:
zen.erase_entry(rec['id'])
except HTTPStatusError as e:
warnings.warn(f"Error deleting record {rec['id']}:\n{e}")
continue
def build_argparser():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment