Skip to content
This repository was archived by the owner on Jan 25, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions webpay/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ def setUp(self):
'notes': {}
}

def post(self, data=None, req=None, mcc='423', mnc='555'):
def post(self, data=None, req=None, mcc='423', mnc='555', **kwargs):
if data is None:
data = {}
if req is None:
req = self.request()
data = {'req': req, 'mnc': mnc, 'mcc': mcc}
return self.client.post(self.url, data=data)
return self.client.post(self.url, data=data, **kwargs)

def test_bad(self):
res = self.post(data={})
Expand All @@ -291,9 +291,12 @@ def test_stores_mnc_mcc(self):
args = self.start_pay.delay.call_args[0][1]
eq_(args['network'], {'mnc': '423', 'mcc': '555'})

def test_invalid__mcc(self):
res = self.post(mcc='abc')
def test_invalid_mcc(self):
accept = 'application/json, text/javascript, */*; q=0.01'
res = self.post(mcc='abc', HTTP_ACCEPT=accept)
eq_(res.status_code, 400)
errors = json.loads(res.content)
ok_('error_code' in errors)

def test_missing_mcc(self):
res = self.post(mcc=None)
Expand Down
2 changes: 1 addition & 1 deletion webpay/base/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def system_error(request, **kw):

def custom_error(request, user_message, code=None, status=400):
error = {'error': user_message, 'error_code': code}
if request.META.get('HTTP_ACCEPT') == 'application/json':
if 'application/json' in request.META.get('HTTP_ACCEPT'):
return HttpResponse(
content=json.dumps(error),
content_type='application/json; charset=utf-8',
Expand Down