Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup (bug 806424)

  • Loading branch information...
commit 03bb0a443a14f3a5802315f628662af9b423ee66 1 parent 560ddb1
@wraithan wraithan authored
View
13 lib/solitude/api.py
@@ -2,11 +2,11 @@
from django.conf import settings
-from .errors import ERROR_STRINGS
-
from slumber import API
from slumber.exceptions import HttpClientError
+from .errors import ERROR_STRINGS
+
client = None
@@ -35,7 +35,6 @@ def _buyer_from_response(self, res):
return buyer
def parse_res(self, res):
-
if res == '':
return {}
if isinstance(res, (str, unicode)):
@@ -45,14 +44,12 @@ def parse_res(self, res):
def safe_run(self, command, *args, **kwargs):
try:
res = command(*args, **kwargs)
- return self.parse_res(res)
except HttpClientError as e:
res = self.parse_res(e.response.content)
- for key,value in res.iteritems():
- new_value = [ERROR_STRINGS[v] for v in value]
- res[key] = new_value
+ for key, value in res.iteritems():
+ res[key] = [ERROR_STRINGS[v] for v in value]
return {'errors': res}
- pass
+ return self.parse_res(res)
def create_buyer(self, uuid, pin=None):
"""Creates a buyer with an optional PIN in solitude.
View
2  lib/solitude/errors.py
@@ -1,4 +1,4 @@
-from tower import ugettext as _
+from tower import ugettext_lazy as _
ERROR_STRINGS = {
'PIN must be exactly 4 numbers long':
View
9 lib/solitude/tests.py
@@ -51,22 +51,19 @@ def test_create_buyer_with_pin(self):
assert buyer.get('id')
def test_create_buyer_with_alpha_pin(self):
- uuid = 'with_alpha_pin'
- buyer = client.create_buyer(uuid, 'lame')
+ buyer = client.create_buyer('with_alpha_pin', 'lame')
assert buyer.get('errors')
eq_(buyer['errors'].get('pin'),
[ERROR_STRINGS['PIN may only consists of numbers']])
def test_create_buyer_with_short_pin(self):
- uuid = 'with_short_pin'
- buyer = client.create_buyer(uuid, '123')
+ buyer = client.create_buyer('with_short_pin', '123')
assert buyer.get('errors')
eq_(buyer['errors'].get('pin'),
[ERROR_STRINGS['PIN must be exactly 4 numbers long']])
def test_create_buyer_with_long_pin(self):
- uuid = 'with_long_pin'
- buyer = client.create_buyer(uuid, '12345')
+ buyer = client.create_buyer('with_long_pin', '12345')
assert buyer.get('errors')
eq_(buyer['errors'].get('pin'),
[ERROR_STRINGS['PIN must be exactly 4 numbers long']])
Please sign in to comment.
Something went wrong with that request. Please try again.