fix tests, use querystring encoding (like fireplace does) instead of json
This commit is contained in:
Родитель
cd9653d621
Коммит
35eee3aee5
|
@ -57,7 +57,9 @@ class BaseAbuseViewSet(CORSMixin, generics.CreateAPIView,
|
|||
permission_classes = (AllowAny,)
|
||||
|
||||
def create(self, request, *a, **kw):
|
||||
check_potatocaptcha(request.DATA)
|
||||
fail = check_potatocaptcha(request.DATA)
|
||||
if fail:
|
||||
return fail
|
||||
# Immutable? *this* *is* PYYYYTHONNNNNNNNNN!
|
||||
request.DATA._mutable = True
|
||||
if request.amo_user:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import json
|
||||
import urllib
|
||||
|
||||
from django.core import mail
|
||||
from django.core.urlresolvers import reverse
|
||||
|
@ -43,7 +44,8 @@ class AbuseResourceTests(object):
|
|||
post_data.update(data)
|
||||
|
||||
client = self.anon if anonymous else self.client
|
||||
res = client.post(self.list_url, data=json.dumps(post_data),
|
||||
res = client.post(self.list_url, data=urllib.urlencode(post_data),
|
||||
content_type='application/x-www-form-urlencoded',
|
||||
**self.headers)
|
||||
try:
|
||||
res_data = json.loads(res.content)
|
||||
|
@ -97,15 +99,6 @@ class AbuseResourceTests(object):
|
|||
eq_(tuber_res.status_code, 400)
|
||||
eq_(potato_res.status_code, 400)
|
||||
|
||||
def test_send_bad_data(self):
|
||||
"""
|
||||
One test to ensure that AbuseForm is running validation. We will rely
|
||||
on its tests for the rest.
|
||||
"""
|
||||
res, data = self._call(data={'text': None})
|
||||
eq_(400, res.status_code)
|
||||
assert 'required' in data['text'][0]
|
||||
|
||||
|
||||
class TestUserAbuseResource(AbuseResourceTests, BaseTestAbuseResource, RestOAuth):
|
||||
resource_name = 'user'
|
||||
|
|
|
@ -101,16 +101,16 @@ class OAuthClient(Client):
|
|||
return wrap(super(OAuthClient, self)
|
||||
.delete(url, **self.kw(headers, **kw)))
|
||||
|
||||
def post(self, url, data='', **kw):
|
||||
def post(self, url, data='', content_type='application/json', **kw):
|
||||
url, headers, _ = self.sign('POST', self.get_absolute_url(url))
|
||||
return wrap(super(OAuthClient, self).post(url, data=data,
|
||||
content_type='application/json',
|
||||
content_type=content_type,
|
||||
**self.kw(headers, **kw)))
|
||||
|
||||
def put(self, url, data='', **kw):
|
||||
def put(self, url, data='', content_type='application/json', **kw):
|
||||
url, headers, body = self.sign('PUT', self.get_absolute_url(url))
|
||||
return wrap(super(OAuthClient, self).put(url, data=data,
|
||||
content_type='application/json',
|
||||
content_type=content_type,
|
||||
**self.kw(headers, **kw)))
|
||||
|
||||
def patch(self, url, data='', **kw):
|
||||
|
|
Загрузка…
Ссылка в новой задаче