Skip to content

Commit

Permalink
fix gitlab tests to not rely on json error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Jul 3, 2013
1 parent 99945d3 commit 59cf5ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
12 changes: 5 additions & 7 deletions master/buildbot/status/web/hooks/gitlab.py
Expand Up @@ -15,12 +15,7 @@

from twisted.python import log
from buildbot.status.web.hooks.github import process_change

try:
import json
assert json
except ImportError:
import simplejson as json
from buildbot.util import json


def getChanges(request, options=None):
Expand All @@ -31,7 +26,10 @@ def getChanges(request, options=None):
request
the http request object
"""
payload = json.load(request.content)
try:
payload = json.load(request.content)
except Exception, e:
raise ValueError("Error loading JSON: " + str(e))
user = payload['user_name']
repo = payload['repository']['name']
repo_url = payload['repository']['url']
Expand Down
Expand Up @@ -14,7 +14,7 @@
# Copyright Buildbot Team Members

import calendar

import mock
import buildbot.status.web.change_hook as change_hook
from buildbot.test.fake.web import FakeRequest

Expand Down Expand Up @@ -112,10 +112,9 @@ def testGitWithNoJson(self):
d = self.request.test_render(self.changeHook)

def check_changes(r):
expected = "No JSON object could be decoded"
self.assertEquals(len(self.request.addedChanges), 0)
self.assertEqual(self.request.written, expected)
self.request.setResponseCode.assert_called_with(400, expected)
self.assertIn("Error loading JSON:", self.request.written)
self.request.setResponseCode.assert_called_with(400, mock.ANY)

d.addCallback(check_changes)
return d

0 comments on commit 59cf5ad

Please sign in to comment.