From 7b181305c6ec08e97b69c1e549e3e8545114548b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 25 Jul 2018 18:23:02 +0200 Subject: [PATCH] add basic unit test for dummy --- eopayment/dummy.py | 18 ------------------ tests/test_dummy.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 tests/test_dummy.py diff --git a/eopayment/dummy.py b/eopayment/dummy.py index ef08517..330a618 100644 --- a/eopayment/dummy.py +++ b/eopayment/dummy.py @@ -149,21 +149,3 @@ class Payment(PaymentCommon): def cancel(self, amount, bank_data, **kwargs): return {} - -if __name__ == '__main__': - options = { - 'direct_notification_url': 'http://example.com/direct_notification_url', - 'siret': '1234', - 'origin': 'Mairie de Perpette-les-oies' - } - p = Payment(options) - retour = 'http://example.com/retour?amount=10.0&direct_notification_url=http%3A%2F%2Fexample.com%2Fdirect_notification_url&email=toto%40example.com&transaction_id=6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T&return_url=http%3A%2F%2Fexample.com%2Fretour&nok=1' - r = p.response(retour.split('?',1)[1]) - assert not r[0] - assert r[1] == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T' - assert r[3] is None - retour = 'http://example.com/retour?amount=10.0&direct_notification_url=http%3A%2F%2Fexample.com%2Fdirect_notification_url&email=toto%40example.com&transaction_id=6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T&return_url=http%3A%2F%2Fexample.com%2Fretour&ok=1&signed=1' - r = p.response(retour.split('?',1)[1]) - assert r[0] - assert r[1] == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T' - assert r[3] == 'signature ok' diff --git a/tests/test_dummy.py b/tests/test_dummy.py new file mode 100644 index 0000000..caac610 --- /dev/null +++ b/tests/test_dummy.py @@ -0,0 +1,19 @@ +import eopayment + +def test_dummy(): + options = { + 'direct_notification_url': 'http://example.com/direct_notification_url', + 'siret': '1234', + 'origin': 'Mairie de Perpette-les-oies' + } + p = eopayment.Payment('dummy', options) + retour = 'http://example.com/retour?amount=10.0&direct_notification_url=http%3A%2F%2Fexample.com%2Fdirect_notification_url&email=toto%40example.com&transaction_id=6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T&return_url=http%3A%2F%2Fexample.com%2Fretour&nok=1' + r = p.response(retour.split('?',1)[1]) + assert not r.signed + assert r.transaction_id == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T' + assert r.return_content is None + retour = 'http://example.com/retour?amount=10.0&direct_notification_url=http%3A%2F%2Fexample.com%2Fdirect_notification_url&email=toto%40example.com&transaction_id=6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T&return_url=http%3A%2F%2Fexample.com%2Fretour&ok=1&signed=1' + r = p.response(retour.split('?',1)[1]) + assert r.signed + assert r.transaction_id == '6Tfw2e1bPyYnz7CedZqvdHt7T9XX6T' + assert r.return_content == 'signature ok'