self = <rest_framework.test.ForceAuthClientHandler object at 0x7f7f193dfc18>
request = <WSGIRequest: DELETE '/1/test/'>
def _get_response(self, request):
"""
Resolve and call the view, then apply view, exception, and
template_response middleware. This method is everything that happens
inside the request/response middleware.
"""
response = None
if hasattr(request, 'urlconf'):
urlconf = request.urlconf
set_urlconf(urlconf)
resolver = get_resolver(urlconf)
else:
resolver = get_resolver()
resolver_match = resolver.resolve(request.path_info)
callback, callback_args, callback_kwargs = resolver_match
request.resolver_match = resolver_match
# Apply view middleware
for middleware_method in self._view_middleware:
response = middleware_method(request, callback, callback_args, callback_kwargs)
if response:
break
if response is None:
wrapped_callback = self.make_view_atomic(callback)
try:
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py:113:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<WSGIRequest: DELETE '/1/test/'>,), kwargs = {'collection_name': 'test'}
def wrapped_view(*args, **kwargs):
> return view_func(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/django/views/decorators/csrf.py:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: DELETE '/1/test/'>, args = ()
kwargs = {'collection_name': 'test'}
self = <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>
def view(request, *args, **kwargs):
self = cls(**initkwargs)
if hasattr(self, 'get') and not hasattr(self, 'head'):
self.head = self.get
self.setup(request, *args, **kwargs)
if not hasattr(self, 'request'):
raise AttributeError(
"%s instance has no 'request' attribute. Did you override "
"setup() and forget to call super()?" % cls.__name__
)
> return self.dispatch(request, *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/django/views/generic/base.py:71:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>
request = <rest_framework.request.Request: DELETE '/1/test/'>, args = ()
kwargs = {'collection_name': 'test'}
handler = <bound method APIBase.delete of <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>>
def dispatch(self, request, *args, **kwargs):
"""
`.dispatch()` is pretty much the same as Django's regular dispatch,
but with extra hooks for startup, finalize, and exception handling.
"""
self.args = args
self.kwargs = kwargs
request = self.initialize_request(request, *args, **kwargs)
self.request = request
self.headers = self.default_response_headers # deprecate?
try:
self.initial(request, *args, **kwargs)
# Get the appropriate handler method
if request.method.lower() in self.http_method_names:
handler = getattr(self, request.method.lower(),
self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
response = handler(request, *args, **kwargs)
except Exception as exc:
> response = self.handle_exception(exc)
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:509:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>
exc = DepositError(<rest_framework.request.Request: DELETE '/1/test/'>, 'method-not-allowed', 'DELETE method is not supported on this endpoint')
def handle_exception(self, exc):
"""
Handle any exception that occurs, by returning an appropriate response,
or re-raising the error.
"""
if isinstance(exc, (exceptions.NotAuthenticated,
exceptions.AuthenticationFailed)):
# WWW-Authenticate header for 401 responses, else coerce to 403
auth_header = self.get_authenticate_header(self.request)
if auth_header:
exc.auth_header = auth_header
else:
exc.status_code = status.HTTP_403_FORBIDDEN
exception_handler = self.get_exception_handler()
context = self.get_exception_handler_context()
response = exception_handler(exc, context)
if response is None:
> self.raise_uncaught_exception(exc)
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:469:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>
exc = DepositError(<rest_framework.request.Request: DELETE '/1/test/'>, 'method-not-allowed', 'DELETE method is not supported on this endpoint')
def raise_uncaught_exception(self, exc):
if settings.DEBUG:
request = self.request
renderer_format = getattr(request.accepted_renderer, 'format')
use_plaintext_traceback = renderer_format not in ('html', 'api', 'admin')
request.force_plaintext_errors(use_plaintext_traceback)
> raise exc
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:480:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>
request = <rest_framework.request.Request: DELETE '/1/test/'>, args = ()
kwargs = {'collection_name': 'test'}
handler = <bound method APIBase.delete of <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>>
def dispatch(self, request, *args, **kwargs):
"""
`.dispatch()` is pretty much the same as Django's regular dispatch,
but with extra hooks for startup, finalize, and exception handling.
"""
self.args = args
self.kwargs = kwargs
request = self.initialize_request(request, *args, **kwargs)
self.request = request
self.headers = self.default_response_headers # deprecate?
try:
self.initial(request, *args, **kwargs)
# Get the appropriate handler method
if request.method.lower() in self.http_method_names:
handler = getattr(self, request.method.lower(),
self.http_method_not_allowed)
else:
handler = self.http_method_not_allowed
> response = handler(request, *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/rest_framework/views.py:506:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>
request = <rest_framework.request.Request: DELETE '/1/test/'>
collection_name = 'test', deposit_id = None
def delete(
self, request: Request, collection_name: str, deposit_id: Optional[int] = None
) -> HttpResponse:
> return self._basic_not_allowed_method(request, "DELETE")
.tox/py3/lib/python3.7/site-packages/swh/deposit/api/common.py:967:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.deposit.api.collection.CollectionAPI object at 0x7f7f193fa390>
request = <rest_framework.request.Request: DELETE '/1/test/'>, method = 'DELETE'
def _basic_not_allowed_method(self, request: Request, method: str):
raise DepositError(
request,
METHOD_NOT_ALLOWED,
> f"{method} method is not supported on this endpoint",
)
E swh.deposit.errors.DepositError: (<rest_framework.request.Request: DELETE '/1/test/'>, 'method-not-allowed', 'DELETE method is not supported on this endpoint')
.tox/py3/lib/python3.7/site-packages/swh/deposit/api/common.py:946: DepositError
During handling of the above exception, another exception occurred:
authenticated_client = <rest_framework.test.APIClient object at 0x7f7f193fae10>
deposit_collection = <DepositCollection: {'id': 3, 'name': 'test'}>
def test_delete_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.delete(url)
.tox/py3/lib/python3.7/site-packages/swh/deposit/tests/api/test_collection.py:52:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:320: in delete
path, data=data, format=format, content_type=content_type, **extra)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:221: in delete
return self.generic('DELETE', path, data, content_type, **extra)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:234: in generic
method, path, data, content_type, secure, **extra)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:422: in generic
return self.request(**r)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:285: in request
return super().request(**kwargs)
.tox/py3/lib/python3.7/site-packages/rest_framework/test.py:237: in request
request = super().request(**kwargs)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:503: in request
raise exc_value
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34: in inner
response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py:115: in _get_response
response = self.process_exception_by_middleware(e, request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py:155: in process_exception_by_middleware
response = middleware_method(request, exception)
.tox/py3/lib/python3.7/site-packages/swh/deposit/errors.py:199: in process_exception
return make_error_response_from_dict(request, exception.to_dict()["error"])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
req = <WSGIRequest: DELETE '/1/test/'>
error = {'key': <rest_framework.request.Request: DELETE '/1/test/'>, 'summary': 'method-not-allowed', 'verboseDescription': 'DELETE method is not supported on this endpoint'}
def make_error_response_from_dict(req, error):
"""Utility function to return an http response with error detail.
Args:
req (Request): original request
error (dict): Error described as dict, typically generated
from the make_error_dict function.
Returns:
HttpResponse with detailed error.
"""
> error_information = ERRORS[error["key"]]
E KeyError: <rest_framework.request.Request: DELETE '/1/test/'>
.tox/py3/lib/python3.7/site-packages/swh/deposit/errors.py:124: KeyError
TEST RESULT
TEST RESULT
- Run At
- Nov 18 2020, 2:18 PM