start of test for unsubscribe button
This commit is contained in:
parent
3f4150b176
commit
6042d68b66
|
@ -68,6 +68,16 @@ class gocardless_provider:
|
||||||
def get_token(self):
|
def get_token(self):
|
||||||
return 'N/A'
|
return 'N/A'
|
||||||
|
|
||||||
|
def cancel_subscribe(self, reference):
|
||||||
|
subscription = gocardless.client.subscription(reference)
|
||||||
|
response = subscription.cancel()
|
||||||
|
return {
|
||||||
|
'amount': subscription.amount,
|
||||||
|
'start_date': subscription.created_at,
|
||||||
|
'reference': subscription.id,
|
||||||
|
'success': response.success
|
||||||
|
}
|
||||||
|
|
||||||
def create_subscription(self, amount, name, redirect_success, redirect_failure, interval_unit='month', interval_length='1'):
|
def create_subscription(self, amount, name, redirect_success, redirect_failure, interval_unit='month', interval_length='1'):
|
||||||
return gocardless.client.new_subscription_url(
|
return gocardless.client.new_subscription_url(
|
||||||
amount=float(amount),
|
amount=float(amount),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from test_plus.test import TestCase
|
from test_plus.test import TestCase
|
||||||
# import unittest
|
from unittest import skip
|
||||||
from mock import patch, Mock
|
from mock import patch, Mock
|
||||||
|
|
||||||
from mhackspace.subscriptions.payments import payment, gocardless_provider, braintree_provider
|
from mhackspace.subscriptions.payments import payment, gocardless_provider, braintree_provider
|
||||||
|
@ -26,6 +26,23 @@ class TestPaymentGatewaysGocardless(TestCase):
|
||||||
self.provider = gocardless_provider()
|
self.provider = gocardless_provider()
|
||||||
return self.provider #self.provider
|
return self.provider #self.provider
|
||||||
|
|
||||||
|
@skip("Need to implement")
|
||||||
|
@patch('mhackspace.subscriptions.payments.gocardless.client.subscription', autospec=True)
|
||||||
|
def test_unsubscribe(self, mock_subscription):
|
||||||
|
mock_subscription.return_value = Mock(success='success')
|
||||||
|
mock_subscription.cancel.return_value = Mock(
|
||||||
|
id='01',
|
||||||
|
status='active',
|
||||||
|
amount=20.00,
|
||||||
|
created_at='date'
|
||||||
|
)
|
||||||
|
result = self.provider.cancel_subscription(reference='M01')
|
||||||
|
|
||||||
|
self.assertEqual(result.get('amount'), 20.00)
|
||||||
|
self.assertEqual(result.get('start_date'), 'date')
|
||||||
|
self.assertEqual(result.get('reference'), '01')
|
||||||
|
self.assertEqual(result.get('success'), 'success')
|
||||||
|
|
||||||
# @patch('mhackspace.subscriptions.payments.gocardless.request.requests.get', autospec=True)
|
# @patch('mhackspace.subscriptions.payments.gocardless.request.requests.get', autospec=True)
|
||||||
@patch('mhackspace.subscriptions.payments.gocardless.client.subscription', autospec=True)
|
@patch('mhackspace.subscriptions.payments.gocardless.client.subscription', autospec=True)
|
||||||
@patch('mhackspace.subscriptions.payments.gocardless.client.confirm_resource', autospec=True)
|
@patch('mhackspace.subscriptions.payments.gocardless.client.confirm_resource', autospec=True)
|
||||||
|
|
Loading…
Reference in New Issue