replace webob.Response with werkzeug Response
Replace webob usage in one more file. Document a TODO that should be clarified, we should probably be using json_response rather than Response() here. Modify the TestMeddleware to not rely on the content_type attribute being present, while werkzeug.wrappers Response() has it the BaseResponse() object which is often returned in tests does not have it. Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
parent
bf3b9e783d
commit
74af60bb32
@ -19,10 +19,10 @@ import logging
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from os.path import splitext
|
from os.path import splitext
|
||||||
from webob import Response
|
from werkzeug.datastructures import FileStorage
|
||||||
from werkzeug.exceptions import BadRequest, Forbidden
|
from werkzeug.exceptions import BadRequest, Forbidden
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from werkzeug.datastructures import FileStorage
|
from werkzeug.wrappers import Response
|
||||||
from celery import registry
|
from celery import registry
|
||||||
|
|
||||||
from mediagoblin.db.util import ObjectId
|
from mediagoblin.db.util import ObjectId
|
||||||
@ -136,6 +136,8 @@ def api_test(request):
|
|||||||
'username': request.user.username,
|
'username': request.user.username,
|
||||||
'email': request.user.email}
|
'email': request.user.email}
|
||||||
|
|
||||||
|
# TODO: This is the *only* thing using Response() here, should that
|
||||||
|
# not simply use json_response()?
|
||||||
return Response(json.dumps(user_data))
|
return Response(json.dumps(user_data))
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class TestingMeddleware(BaseMeddleware):
|
|||||||
|
|
||||||
def process_response(self, request, response):
|
def process_response(self, request, response):
|
||||||
# All following tests should be for html only!
|
# All following tests should be for html only!
|
||||||
if response.content_type != "text/html":
|
if getattr(response, 'content_type', None) != "text/html":
|
||||||
# Get out early
|
# Get out early
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user