cope with missing currencies
This commit is contained in:
Родитель
e789347fdb
Коммит
8be4b7d86d
|
@ -60,13 +60,12 @@ class CurrencyError(PaypalError):
|
|||
|
||||
def __str__(self):
|
||||
default = _('There was an error with this currency.')
|
||||
if self.paypal_data:
|
||||
if self.paypal_data and 'currencyCode' in self.paypal_data:
|
||||
return (messages.get(self.id) %
|
||||
amo.PAYPAL_CURRENCIES[self.paypal_data['currencyCode']])
|
||||
return default
|
||||
|
||||
|
||||
|
||||
errors = {'520003': AuthError}
|
||||
# See http://bit.ly/vWV525 for information on these values.
|
||||
# Note that if you have and invalid preapproval key you get 580022, but this
|
||||
|
|
|
@ -95,6 +95,17 @@ class TestPayKey(amo.tests.TestCase):
|
|||
else:
|
||||
raise ValueError('No PaypalError was raised')
|
||||
|
||||
@mock.patch('urllib2.OpenerDirector.open')
|
||||
def test_error_no_currency(self, opener):
|
||||
opener.return_value = StringIO(other_error.replace('520001', '559044'))
|
||||
try:
|
||||
data = self.data.copy()
|
||||
paypal.get_paykey(data)
|
||||
except paypal.PaypalError as error:
|
||||
eq_(error.id, '559044')
|
||||
else:
|
||||
raise ValueError('No PaypalError was raised')
|
||||
|
||||
@mock.patch('urllib2.OpenerDirector.open')
|
||||
def test_other_fails(self, opener):
|
||||
opener.return_value = StringIO(other_error)
|
||||
|
|
Загрузка…
Ссылка в новой задаче