summaryrefslogtreecommitdiffstats
path: root/tests/test_tipi.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_tipi.py')
-rw-r--r--tests/test_tipi.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/test_tipi.py b/tests/test_tipi.py
index 63c3902..cf30540 100644
--- a/tests/test_tipi.py
+++ b/tests/test_tipi.py
@@ -1,7 +1,9 @@
+import datetime
from decimal import Decimal
from six.moves.urllib.parse import urlparse, parse_qs
import eopayment
+import eopayment.tipi
import pytest
@@ -32,3 +34,60 @@ def test_tipi():
with pytest.raises(eopayment.ResponseError, match='missing refdet or resultrans'):
p.response('foo=bar')
+
+
+def test_tipi_no_orderid_no_refdet():
+ p = eopayment.Payment('tipi', {'numcli': '12345'})
+ payment_id, kind, url = p.request(
+ amount=Decimal('123.12'),
+ exer=9999,
+ email='info@entrouvert.com',
+ saisie='T')
+ parsed_qs = parse_qs(urlparse(url).query)
+ assert 'objet' not in parsed_qs
+ assert parsed_qs['montant'] == ['12312']
+ assert parsed_qs['saisie'] == ['T']
+ assert parsed_qs['mel'] == ['info@entrouvert.com']
+ assert parsed_qs['numcli'] == ['12345']
+ assert parsed_qs['exer'] == ['9999']
+ assert parsed_qs['refdet'][0].startswith(datetime.datetime.now().strftime('%Y%m%d'))
+
+
+def test_tipi_orderid_refdef_compatible():
+ p = eopayment.Payment('tipi', {'numcli': '12345', 'saisie': 'A'})
+ payment_id, kind, url = p.request(
+ amount=Decimal('123.12'),
+ email='info@entrouvert.com',
+ orderid='F121212')
+ expected_url = urlparse(eopayment.tipi.TIPI_URL)
+ parsed_url = urlparse(url)
+ assert parsed_url[:3] == expected_url[:3]
+ parsed_qs = parse_qs(parsed_url.query)
+ assert 'objet' not in parsed_qs
+ assert 'exer' not in parsed_qs
+ assert parsed_qs['montant'] == ['12312']
+ assert parsed_qs['saisie'] == ['A']
+ assert parsed_qs['mel'] == ['info@entrouvert.com']
+ assert parsed_qs['numcli'] == ['12345']
+ assert parsed_qs['refdet'] == ['F121212']
+
+
+def test_tipi_orderid_not_refdef_compatible():
+ p = eopayment.Payment('tipi', {'numcli': '12345', 'saisie': 'A'})
+ payment_id, kind, url = p.request(
+ amount=Decimal('123.12'),
+ email='info@entrouvert.com',
+ objet='coucou',
+ orderid='F12-12-12')
+ expected_url = urlparse(eopayment.tipi.TIPI_URL)
+ parsed_url = urlparse(url)
+ assert parsed_url[:3] == expected_url[:3]
+ parsed_qs = parse_qs(parsed_url.query)
+ assert 'exer' not in parsed_qs
+ assert parsed_qs['montant'] == ['12312']
+ assert parsed_qs['saisie'] == ['A']
+ assert parsed_qs['mel'] == ['info@entrouvert.com']
+ assert parsed_qs['numcli'] == ['12345']
+ assert parsed_qs['refdet'][0].startswith(datetime.datetime.now().strftime('%Y%m%d'))
+ assert 'coucou' in parsed_qs['objet'][0]
+ assert 'F12-12-12' in parsed_qs['objet'][0]