turns out the builder isn't sending json

This commit is contained in:
Jeff Balogh 2011-05-31 16:40:56 -07:00
Родитель 664afcf9d1
Коммит 6d45e29f7c
2 изменённых файлов: 8 добавлений и 9 удалений

Просмотреть файл

@ -387,7 +387,7 @@ def cspreport(request):
@post_required
def builder_pingback(request):
try:
data = json.loads(request.raw_post_data)
data = dict(request.POST.items())
# We expect all these attributes to be available.
attrs = 'result msg filename location secret request'.split()
for attr in attrs:

Просмотреть файл

@ -450,19 +450,18 @@ class TestDiffViewer(FilesBase, test_utils.TestCase):
class TestBuilderPingback(test_utils.TestCase):
def post(self, data):
return self.client.post(reverse('amo.builder-pingback'), data,
content_type='application/json')
return self.client.post(reverse('amo.builder-pingback'), data)
def test_success(self):
r = self.post(json.dumps({'result': '', 'msg': '', 'filename': '',
'location': '', 'request': '',
'secret': settings.BUILDER_SECRET_KEY}))
r = self.post({'result': '', 'msg': '', 'filename': '',
'location': '', 'request': '',
'secret': settings.BUILDER_SECRET_KEY})
eq_(r.status_code, 200)
def test_bad_secret(self):
r = self.post(json.dumps({'secret': 1}))
r = self.post({'secret': 1})
eq_(r.status_code, 400)
def test_bad_json(self):
r = self.post('wut')
def test_bad_data(self):
r = self.post({'wut': 0})
eq_(r.status_code, 400)