diff --git a/swh/deposit/api/common.py b/swh/deposit/api/common.py --- a/swh/deposit/api/common.py +++ b/swh/deposit/api/common.py @@ -1047,23 +1047,17 @@ ) def get( - self, request: Request, collection_name: str, deposit_id: int + self, request: Request, *args, **kwargs ) -> Union[HttpResponse, FileResponse]: return self._basic_not_allowed_method(request, "GET") - def post( - self, request: Request, collection_name: str, deposit_id: Optional[int] = None - ) -> HttpResponse: + def post(self, request: Request, *args, **kwargs) -> HttpResponse: return self._basic_not_allowed_method(request, "POST") - def put( - self, request: Request, collection_name: str, deposit_id: int - ) -> HttpResponse: + def put(self, request: Request, *args, **kwargs) -> HttpResponse: return self._basic_not_allowed_method(request, "PUT") - def delete( - self, request: Request, collection_name: str, deposit_id: Optional[int] = None - ) -> HttpResponse: + def delete(self, request: Request, *args, **kwargs) -> HttpResponse: return self._basic_not_allowed_method(request, "DELETE") @@ -1072,7 +1066,7 @@ """ - def get( + def get( # type: ignore self, request: Request, collection_name: str, deposit_id: int ) -> Union[HttpResponse, FileResponse]: """Endpoint to create/add resources to deposit. @@ -1118,7 +1112,7 @@ """ - def post( + def post( # type: ignore self, request: Request, collection_name: str, deposit_id: Optional[int] = None ) -> HttpResponse: """Endpoint to create/add resources to deposit. @@ -1201,7 +1195,7 @@ """ - def put( + def put( # type: ignore self, request: Request, collection_name: str, deposit_id: int ) -> HttpResponse: """Endpoint to update deposit resources. @@ -1243,7 +1237,7 @@ """ - def delete( + def delete( # type: ignore self, request: Request, collection_name: str, deposit_id: Optional[int] = None ) -> HttpResponse: """Endpoint to delete some deposit's resources (archives, deposit). diff --git a/swh/deposit/api/content.py b/swh/deposit/api/content.py --- a/swh/deposit/api/content.py +++ b/swh/deposit/api/content.py @@ -20,7 +20,9 @@ """ - def get(self, req, collection_name: str, deposit_id: int) -> HttpResponse: + def get( # type: ignore + self, req, collection_name: str, deposit_id: int + ) -> HttpResponse: deposit = get_deposit_by_id(deposit_id, collection_name) self.checks(req, collection_name, deposit) diff --git a/swh/deposit/api/state.py b/swh/deposit/api/state.py --- a/swh/deposit/api/state.py +++ b/swh/deposit/api/state.py @@ -21,7 +21,9 @@ """ - def get(self, req, collection_name: str, deposit_id: int) -> HttpResponse: + def get( # type: ignore + self, req, collection_name: str, deposit_id: int + ) -> HttpResponse: deposit = get_deposit_by_id(deposit_id, collection_name) self.checks(req, collection_name, deposit) diff --git a/swh/deposit/tests/api/test_collection.py b/swh/deposit/tests/api/test_collection.py --- a/swh/deposit/tests/api/test_collection.py +++ b/swh/deposit/tests/api/test_collection.py @@ -44,6 +44,18 @@ assert msg in response.content.decode("utf-8") +def test_put_on_col_iri_not_supported(authenticated_client, deposit_collection): + """Delete on col iri should return a 405 response + + """ + url = reverse(COL_IRI, args=[deposit_collection.name]) + response = authenticated_client.put(url) + assert response.status_code == status.HTTP_405_METHOD_NOT_ALLOWED + assert "PUT method is not supported on this endpoint" in response.content.decode( + "utf-8" + ) + + def test_delete_on_col_iri_not_supported(authenticated_client, deposit_collection): """Delete on col iri should return a 405 response