summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2020-04-10 09:13:05 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2020-04-10 09:56:51 (GMT)
commita414c56bd4164bb242c761ab2d2f0efbee151ca4 (patch)
treeb36438f304f3f984098d9107017f98600171d4a2
parent1a171a733d175b2858b46fae4aefdd68e8af80fc (diff)
downloadeopayment-a414c56bd4164bb242c761ab2d2f0efbee151ca4.zip
eopayment-a414c56bd4164bb242c761ab2d2f0efbee151ca4.tar.gz
eopayment-a414c56bd4164bb242c761ab2d2f0efbee151ca4.tar.bz2
tests: clear warnings about assertRaisesRegexp
-rw-r--r--tests/test_ogone.py7
-rw-r--r--tests/test_paybox.py10
-rw-r--r--tests/test_spplus.py37
3 files changed, 33 insertions, 21 deletions
diff --git a/tests/test_ogone.py b/tests/test_ogone.py
index abf472a..0aefe25 100644
--- a/tests/test_ogone.py
+++ b/tests/test_ogone.py
@@ -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):
diff --git a/tests/test_paybox.py b/tests/test_paybox.py
index 2571f04..dd11160 100644
--- a/tests/test_paybox.py
+++ b/tests/test_paybox.py
@@ -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),
diff --git a/tests/test_spplus.py b/tests/test_spplus.py
index 970a5db..968c842 100644
--- a/tests/test_spplus.py
+++ b/tests/test_spplus.py
@@ -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')