beware the unicode devil (bug 604857)
This commit is contained in:
Родитель
3b8572c74d
Коммит
b52e7efcfb
|
@ -4,6 +4,7 @@ import urllib
|
|||
import urlparse
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.http import urlencode
|
||||
|
||||
|
||||
def check_paypal_id(name):
|
||||
|
@ -21,7 +22,7 @@ def check_paypal_id(name):
|
|||
method='BMCreateButton',
|
||||
l_buttonvar0='business=%s' % name)
|
||||
with socket_timeout(10):
|
||||
r = urllib.urlopen(settings.PAYPAL_API_URL, urllib.urlencode(d))
|
||||
r = urllib.urlopen(settings.PAYPAL_API_URL, urlencode(d))
|
||||
response = dict(urlparse.parse_qsl(r.read()))
|
||||
valid = response['ACK'] == 'Success'
|
||||
msg = None if valid else response['L_LONGMESSAGE0']
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
from cStringIO import StringIO
|
||||
|
||||
import mock
|
||||
from nose.tools import eq_
|
||||
|
||||
import paypal
|
||||
|
||||
|
||||
@mock.patch('paypal.urllib.urlopen')
|
||||
def test_check_paypal_id(urlopen_mock):
|
||||
urlopen_mock.return_value = StringIO('ACK=Success')
|
||||
val = paypal.check_paypal_id(u'\u30d5\u30a9\u30af\u3059\u3051')
|
||||
eq_(val, (True, None))
|
Загрузка…
Ссылка в новой задаче