summaryrefslogtreecommitdiff
path: root/payments
diff options
context:
space:
mode:
authorAdam Bogdał <adam@bogdal.pl>2015-12-04 15:32:08 +0100
committerAdam Bogdał <adam@bogdal.pl>2015-12-04 15:32:08 +0100
commita9c4b60196abef6be315909651c237b0f1605e68 (patch)
treef8a653478ac2873c7a303aa5c26f413c740fb3c7 /payments
parent3857129fa271e265338d7843dea580506b393883 (diff)
downloaddjango-payments-taler-a9c4b60196abef6be315909651c237b0f1605e68.tar.gz
django-payments-taler-a9c4b60196abef6be315909651c237b0f1605e68.tar.bz2
django-payments-taler-a9c4b60196abef6be315909651c237b0f1605e68.zip
Check existence of provider links
Diffstat (limited to 'payments')
-rw-r--r--payments/paypal/test_paypal.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/payments/paypal/test_paypal.py b/payments/paypal/test_paypal.py
index 20221f7..2bd7816 100644
--- a/payments/paypal/test_paypal.py
+++ b/payments/paypal/test_paypal.py
@@ -217,7 +217,7 @@ class TestPaypalProvider(TestCase):
class TestPaypalCardProvider(TestCase):
def setUp(self):
- self.payment = Payment()
+ self.payment = Payment(extra_data='')
self.provider = PaypalCardProvider(secret=SECRET, client_id=CLIENT_ID)
def test_provider_raises_redirect_needed_on_success_captured_payment(self):
@@ -227,7 +227,13 @@ class TestPaypalCardProvider(TestCase):
data.return_value = {
'id': transaction_id,
'token_type': 'test_token_type',
- 'access_token': 'test_access_token'}
+ 'access_token': 'test_access_token',
+ 'transactions': [
+ {'related_resources': [
+ {'sale': {'links': [
+ {'rel': 'refund', 'href': 'http://refund.com'}]}}
+ ]}
+ ]}
post = MagicMock()
post.json = data
post.status_code = 200
@@ -236,9 +242,11 @@ class TestPaypalCardProvider(TestCase):
self.provider.get_form(
payment=self.payment, data=PROCESS_DATA)
self.assertEqual(exc.args[0], self.payment.get_success_url())
+ links = self.provider._get_links(self.payment)
self.assertEqual(self.payment.status, 'confirmed')
self.assertEqual(self.payment.captured_amount, self.payment.total)
self.assertEqual(self.payment.transaction_id, transaction_id)
+ self.assertTrue('refund' in links)
def test_provider_raises_redirect_needed_on_success_preauth_payment(self):
provider = PaypalCardProvider(
@@ -249,7 +257,14 @@ class TestPaypalCardProvider(TestCase):
data.return_value = {
'id': transaction_id,
'token_type': 'test_token_type',
- 'access_token': 'test_access_token'}
+ 'access_token': 'test_access_token',
+ 'transactions': [
+ {'related_resources': [
+ {'authorization': {'links': [
+ {'rel': 'refund', 'href': 'http://refund.com'},
+ {'rel': 'capture', 'href': 'http://capture.com'}]}}
+ ]}
+ ]}
post = MagicMock()
post.json = data
post.status_code = 200
@@ -258,9 +273,12 @@ class TestPaypalCardProvider(TestCase):
provider.get_form(
payment=self.payment, data=PROCESS_DATA)
self.assertEqual(exc.args[0], self.payment.get_success_url())
+ links = provider._get_links(self.payment)
self.assertEqual(self.payment.status, 'preauth')
self.assertEqual(self.payment.captured_amount, Decimal('0'))
self.assertEqual(self.payment.transaction_id, transaction_id)
+ self.assertTrue('capture' in links)
+ self.assertTrue('refund' in links)
def test_form_shows_validation_error_message(self):
with patch('requests.post') as mocked_post: