Conversation
8bdd52f to
39618ef
Compare
chris-allan
left a comment
There was a problem hiding this comment.
We should add some test cases to ensure that the PUT and POST restrictions are accurate.
| POST to create a new Object and PUT to replace existing one. | ||
| """ | ||
|
|
||
| can_put = ['Project', 'Dataset', 'Screen'] |
There was a problem hiding this comment.
As these are constants, let's uppercase them.
|
Conflicting PR. Removed from build OMERO-DEV-merge-push#577. See the console output for more details.
|
|
Conflicting PR. Removed from build OMERO-DEV-merge-push#579. See the console output for more details.
|
|
Conflicting PR. Removed from build OMERO-DEV-merge-push#580. See the console output for more details.
|
|
Conflicting PR. Removed from build OMERO-DEV-merge-push#581. See the console output for more details.
|
b22828f to
0303161
Compare
Since this test is really the counterpart to test_container_crud() above
| from django.http import JsonResponse | ||
| from functools import update_wrapper | ||
| from api_exceptions import NotFoundError, BadRequestError, CreatedObject | ||
| from api_exceptions import NotFoundError, BadRequestError, CreatedObject, \ |
There was a problem hiding this comment.
one per line and alphabetical order
| @@ -75,7 +76,7 @@ def handle_error(self, ex, trace): | |||
| # But we try to handle all 'expected' errors appropriately | |||
| # TODO: handle omero.ConcurrencyException | |||
There was a problem hiding this comment.
Will you do that in another PR? i.e. TODO
There was a problem hiding this comment.
Yes. Hard to see that we need to support ConcurrencyException since we are doing very simple get/set queries now and no stateful services.
| from omeroweb.connector import Server | ||
| from omeroweb.api.api_exceptions import BadRequestError, NotFoundError, \ | ||
| CreatedObject | ||
| CreatedObject, MethodNotSupportedError |
| @pytest.mark.parametrize("dtype", ['Plate', 'Image', 'Well', | ||
| 'Channel', 'foo']) | ||
| def test_crud_unsupported(self, user1, dtype): | ||
| """Test create, update & delete are rejected for unsupported types.""" |
There was a problem hiding this comment.
I think you should split the test and not have post/put/delete tests in the same one
|
Need to fix failing ```test_api_errors.py```` tests in https://ci.openmicroscopy.org/view/Failing/job/OMERO-DEV-breaking-integration-Python27/164/testReport/ |
Single test for PUT, POST & DELETE is spilt into separate tests for each method. To try and reduce code duplication, PUT and POST are covered by parametrizing method in a single test.
|
@jburel After those last commits, this is going to conflict with #5058, so we'll need to get that merged ASAP. I still have 3 further api PRs waiting after this one. |
|
Conflicting PR. Removed from build OMERO-DEV-merge-push#592. See the console output for more details.
|
chris-allan
left a comment
There was a problem hiding this comment.
Looks great aside from the exception feedback above.
|
|
||
| status = 405 | ||
|
|
||
| def __init__(self, message, stacktrace=None): |
There was a problem hiding this comment.
I'm not seeing any use of the stacktrace keyword argument in the implementation. Is it your intention to use it for something? If so, what? If you want to have a unified constructor prototype that is similar to the other exceptions you have above then I would suggest making a class hierarchy so you are not having to implement, and document, this every time.
|
@chris-allan Thanks. Fixed in eb18edc |
|
Exception code fixed. |
What this PR does
Restricts Save (PUT or POST) to a "whitelist" of supported object types.
In the
SaveViewclass that handles PUT and POST, we use a whitelist of supported typesProject, Dataset, Screen.In the
ObjectViewsubclasses that handle DELETE of various objects we use a CAN_DELETE attribute that is True is the base class and False in subclasses where Delete is NOT supportedPlate, Image, Well.Testing this PR
Related reading
Discussed at web meeting on 2017-01-24