Skip to content
Snippets Groups Projects
Commit daf68ede authored by Megan Henning's avatar Megan Henning
Browse files

Fix file delete error msg

parent 72ef8a99
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ from ..auth import listauth, always_ok
from ..dao import noop
from ..dao import liststorage
from ..dao import containerutil
from ..web.errors import APIStorageException
from ..web.errors import APIStorageException, APIPermissionException
from ..web.request import AccessType
......@@ -573,7 +573,8 @@ class FileListHandler(ListHandler):
analyses = containerutil.get_referring_analyses(cont_name, _id, filename=filename)
if analyses:
analysis_ids = [str(a['_id']) for a in analyses]
self.abort(400, 'Cannot delete file {} referenced by analyses {}'.format(filename, analysis_ids))
raise APIPermissionException('Cannot delete file {} referenced by analyses {}'.format(filename, analysis_ids),
errors={'reason': 'analysis_conflict'})
self.log_user_access(AccessType.delete_file, cont_name=cont_name, cont_id=_id, filename=filename)
try:
......
......@@ -1326,7 +1326,8 @@ def test_container_delete_tag(data_builder, default_payload, as_root, as_admin,
# try to delete acquisition file referenced by analysis
r = as_admin.delete('/acquisitions/' + acquisition + '/files/test.csv')
assert r.status_code == 400
assert r.status_code == 403
assert r.json()['reason'] == 'analysis_conflict'
# verify that a non-referenced file _can_ be deleted from the same acquisition
assert as_admin.delete('/acquisitions/' + acquisition + '/files/test2.csv').ok
......
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