tests: clear warnings about assertRaisesRegexp
This commit is contained in:
parent
1a171a733d
commit
a414c56bd4
|
@ -18,6 +18,7 @@
|
|||
from unittest import TestCase
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import six
|
||||
from six.moves.urllib import parse as urllib
|
||||
|
||||
import eopayment
|
||||
|
@ -36,6 +37,10 @@ BACKEND_PARAMS = {
|
|||
|
||||
|
||||
class OgoneTests(TestCase):
|
||||
if six.PY2:
|
||||
def assertRaisesRegex(self, *args, **kwargs):
|
||||
return self.assertRaisesRegexp(*args, **kwargs)
|
||||
|
||||
def test_request(self):
|
||||
ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS)
|
||||
amount = '42.42'
|
||||
|
@ -100,7 +105,7 @@ class OgoneTests(TestCase):
|
|||
def test_bad_response(self):
|
||||
ogone_backend = eopayment.Payment('ogone', BACKEND_PARAMS)
|
||||
data = {'payid': '32100123', 'status': 9, 'ncerror': 0}
|
||||
with self.assertRaisesRegexp(ResponseError, 'missing ORDERID, PAYID, STATUS or NCERROR'):
|
||||
with self.assertRaisesRegex(ResponseError, 'missing ORDERID, PAYID, STATUS or NCERROR'):
|
||||
ogone_backend.response(urllib.urlencode(data))
|
||||
|
||||
def test_bank_transfer_response(self):
|
||||
|
|
|
@ -21,12 +21,14 @@ from unittest import TestCase
|
|||
from decimal import Decimal
|
||||
import base64
|
||||
import mock
|
||||
import six
|
||||
from six.moves.urllib import parse as urllib
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import eopayment.paybox as paybox
|
||||
import eopayment
|
||||
|
||||
|
||||
BACKEND_PARAMS = {
|
||||
'platform': u'test',
|
||||
'site': u'12345678',
|
||||
|
@ -43,6 +45,10 @@ BACKEND_PARAMS = {
|
|||
|
||||
|
||||
class PayboxTests(TestCase):
|
||||
if six.PY2:
|
||||
def assertRaisesRegex(self, *args, **kwargs):
|
||||
return self.assertRaisesRegexp(*args, **kwargs)
|
||||
|
||||
def test_sign(self):
|
||||
key = (b'0123456789ABCDEF0123456789ABCDEF0123456789'
|
||||
b'ABCDEF0123456789ABCDEF0123456789ABCDEF0123'
|
||||
|
@ -210,7 +216,7 @@ class PayboxTests(TestCase):
|
|||
assert not response.signed
|
||||
assert response.transaction_date.isoformat() == '2020-01-01T01:01:01+01:00'
|
||||
|
||||
with self.assertRaisesRegexp(eopayment.ResponseError, 'missing erreur or reference'):
|
||||
with self.assertRaisesRegex(eopayment.ResponseError, 'missing erreur or reference'):
|
||||
backend.response('foo=bar')
|
||||
|
||||
def test_perform_operations(self):
|
||||
|
@ -278,7 +284,7 @@ class PayboxTests(TestCase):
|
|||
error_response = u"""CODEREPONSE=00015&COMMENTAIRE=PAYBOX : Transaction non trouvée"""
|
||||
response = mock.Mock(status_code=200, text=error_response)
|
||||
requests_post.return_value = response
|
||||
self.assertRaisesRegexp(
|
||||
self.assertRaisesRegex(
|
||||
eopayment.ResponseError,
|
||||
'Transaction non trouvée',
|
||||
getattr(backend, operation_name),
|
||||
|
|
|
@ -14,29 +14,30 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from unittest import TestCase
|
||||
import eopayment.spplus as spplus
|
||||
from eopayment import ResponseError
|
||||
|
||||
import pytest
|
||||
|
||||
class SPPlustTest(TestCase):
|
||||
ntkey = b'58 6d fc 9c 34 91 9b 86 3f ' \
|
||||
b'fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'
|
||||
|
||||
tests = [
|
||||
('x=coin',
|
||||
'c04f8266d6ae3ce37551cce996c751be4a95d10a'),
|
||||
('x=coin&y=toto',
|
||||
'ef008e02f8dbf5e70e83da416b0b3a345db203de'),
|
||||
('x=wdwd%20%3Fdfgfdgd&z=343&hmac=04233b78bb5aff332d920d4e89394f505ec58a2a',
|
||||
'04233b78bb5aff332d920d4e89394f505ec58a2a')
|
||||
]
|
||||
ntkey = b'58 6d fc 9c 34 91 9b 86 3f ' \
|
||||
b'fd 64 63 c9 13 4a 26 ba 29 74 1e c7 e9 80 79'
|
||||
|
||||
def test_spplus(self):
|
||||
payment = spplus.Payment({'cle': self.ntkey, 'siret': '00000000000001-01'})
|
||||
tests = [
|
||||
('x=coin',
|
||||
'c04f8266d6ae3ce37551cce996c751be4a95d10a'),
|
||||
('x=coin&y=toto',
|
||||
'ef008e02f8dbf5e70e83da416b0b3a345db203de'),
|
||||
('x=wdwd%20%3Fdfgfdgd&z=343&hmac=04233b78bb5aff332d920d4e89394f505ec58a2a',
|
||||
'04233b78bb5aff332d920d4e89394f505ec58a2a')
|
||||
]
|
||||
|
||||
for query, result in self.tests:
|
||||
self.assertEqual(spplus.sign_ntkey_query(self.ntkey, query).lower(), result)
|
||||
|
||||
with self.assertRaisesRegexp(ResponseError, 'missing reference, etat or refsfp'):
|
||||
payment.response('foo=bar')
|
||||
def test_spplus():
|
||||
payment = spplus.Payment({'cle': ntkey, 'siret': '00000000000001-01'})
|
||||
|
||||
for query, result in tests:
|
||||
assert spplus.sign_ntkey_query(ntkey, query).lower() == result
|
||||
|
||||
with pytest.raises(ResponseError, match=r'missing reference, etat or refsfp'):
|
||||
payment.response('foo=bar')
|
||||
|
|
Loading…
Reference in New Issue