summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_base_payment.py30
-rw-r--r--tests/test_paybox.py30
-rw-r--r--tests/test_systempayv2.py20
3 files changed, 79 insertions, 1 deletions
diff --git a/tests/test_base_payment.py b/tests/test_base_payment.py
index 7ea551e..bb23959 100644
--- a/tests/test_base_payment.py
+++ b/tests/test_base_payment.py
@@ -14,7 +14,22 @@ def do_mock_backend(monkeypatch):
'parameters': [
{
'name': 'capture_day',
- }
+ },
+ {
+ 'name': 'manual_validation',
+ 'caption': 'Validation manuelle',
+ 'type': bool,
+ 'default': False,
+ 'scope': 'transaction'
+ },
+ {
+ 'name': 'global_param',
+ 'caption': 'Global Param',
+ 'type': bool,
+ 'default': False,
+ 'scope': 'global'
+ },
+
]
}
@@ -64,3 +79,16 @@ def test_paris_timezone(freezer, monkeypatch):
# converted to Europe/Paris it is already 2018-10-03
# so 2018-10-03 for capture_date is invalid
payment.request(amount=12.2, capture_date=capture_date)
+
+
+def test_get_parameters(monkeypatch):
+ _, payment = do_mock_backend(monkeypatch)
+
+ global_parameters = payment.get_parameters()
+ assert len(global_parameters) == 2
+ assert global_parameters[0]['name'] == 'capture_day'
+ assert global_parameters[1]['name'] == 'global_param'
+
+ transaction_parameters = payment.get_parameters(scope='transaction')
+ assert len(transaction_parameters) == 1
+ assert transaction_parameters[0]['name'] == 'manual_validation'
diff --git a/tests/test_paybox.py b/tests/test_paybox.py
index 9f38090..443d811 100644
--- a/tests/test_paybox.py
+++ b/tests/test_paybox.py
@@ -253,3 +253,33 @@ ZdzrudBlevZXpr6iYwIDAQAB
z0Dkz0NjxvU+5WzQZh9Uuxr/egRCwV4NMRWqu0zaVVioeBvl4/5CWm4f4/1L9+0m
FBFKOZhgBJnkC+l6+XhT4aYWKaQ4ocmOMV92yjeXTE4='''
self.assertTrue(paybox.verify(data, base64.b64decode(sig64), key=pkey))
+
+ def test_request_manual_validation(self):
+ params = BACKEND_PARAMS.copy()
+ time = '2018-08-21T10:26:32+02:00'
+ email = 'user@entrouvert.com'
+ order_id = '20180821'
+ transaction = '1234'
+ amount = '42.99'
+
+ backend = eopayment.Payment('paybox', params)
+
+ transaction_id, kind, what = backend.request(
+ Decimal(amount), email=email, orderid=order_id,
+ transaction_id=transaction, time=time)
+ root = ET.fromstring(str(what))
+ form_params = dict((
+ (node.attrib['name'], node.attrib['value']) for node in root
+ if node.attrib['type'] == 'hidden'))
+ self.assertIn('PBX_AUTOSEULE', form_params)
+ self.assertEqual(form_params['PBX_AUTOSEULE'], 'N')
+
+ transaction_id, kind, what = backend.request(
+ Decimal(amount), email=email, orderid=order_id,
+ transaction_id=transaction, time=time, manual_validation=True)
+ root = ET.fromstring(str(what))
+ form_params = dict((
+ (node.attrib['name'], node.attrib['value']) for node in root
+ if node.attrib['type'] == 'hidden'))
+ self.assertIn('PBX_AUTOSEULE', form_params)
+ self.assertEqual(form_params['PBX_AUTOSEULE'], 'O')
diff --git a/tests/test_systempayv2.py b/tests/test_systempayv2.py
index 1df7282..c6f9188 100644
--- a/tests/test_systempayv2.py
+++ b/tests/test_systempayv2.py
@@ -98,3 +98,23 @@ def test_systempayv2_deferred_payment():
data['capture_date'] = (datetime.now().date() + timedelta(days=4))
transaction_id, f, form = p.request(**data)
assert get_field(form, 'vads_capture_delay')['value'] == '4'
+
+
+def test_manual_validation():
+ params = {
+ 'secret_test': u'1122334455667788',
+ 'vads_site_id': u'12345678',
+ 'vads_ctx_mode': u'TEST',
+ }
+ data = {
+ 'amount': 15.24, 'orderid': '654321', 'first_name': u'John',
+ 'last_name': u'Doe'
+ }
+
+ backend = eopayment.Payment('systempayv2', params)
+ transaction_id, f, form = backend.request(**data.copy())
+ assert get_field(form, 'vads_validation_mode')['value'] == ''
+
+ data['manual_validation'] = True
+ transaction_id, f, form = backend.request(**data.copy())
+ assert get_field(form, 'vads_validation_mode')['value'] == '1'