-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to using metadata on the price to get the number of calls for a price, rather than assuming it can be worked out from the price (plan) ID.
- Loading branch information
Showing
9 changed files
with
90 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import re | ||
from io import StringIO | ||
from mock import patch | ||
from mock import patch, ANY | ||
|
||
from django.contrib.auth.models import User | ||
from django.contrib.sites.models import Site | ||
|
@@ -28,7 +28,7 @@ def test_signup(self, socket): | |
'password': 'password', | ||
'password_confirm': 'password', | ||
'tandcs_tick': 1, | ||
'price': 'mapit-10k-v', | ||
'price': 'price_123', | ||
'charitable_tick': 1, | ||
'charitable': 'c', | ||
'charity_number': '123', | ||
|
@@ -59,7 +59,7 @@ def test_signup_card_error(self): | |
'password': 'password', | ||
'password_confirm': 'password', | ||
'tandcs_tick': 1, | ||
'price': 'mapit-10k-v', | ||
'price': 'price_123', | ||
'charitable_tick': 1, | ||
'charitable': 'c', | ||
'charity_number': '123', | ||
|
@@ -71,25 +71,24 @@ def test_signup_card_error(self): | |
class ManagementTest(PatchedStripeMixin, PatchedRedisTestCase): | ||
def test_add_mapit_user(self): | ||
with patch('mapit_mysociety_org.management.commands.add_mapit_user.stripe', self.MockStripe): | ||
self.MockStripe.Price.list.return_value = convert_to_stripe_object({ | ||
'data': [ | ||
{'id': 'mapit-0k-v', | ||
'product': {'id': 'prod_GHI', 'name': 'MapIt, unlimited calls'}}, | ||
{'id': 'mapit-10k-v', | ||
'product': {'id': 'prod_ABC', 'name': 'MapIt, 10,000 calls'}}, | ||
{'id': 'mapit-100k-v', | ||
'product': {'id': 'prod_DEF', 'name': 'MapIt, 100,000 calls'}}, | ||
] | ||
}, None, None) | ||
self.MockStripe.Product.list.return_value = convert_to_stripe_object([ | ||
{'id': 'prod_GHI', 'name': 'MapIt, unlimited calls', | ||
'default_price': {'id': 'price_789', 'metadata': {'calls': '0'}}}, | ||
{'id': 'prod_ABC', 'name': 'MapIt, 10,000 calls', | ||
'default_price': {'id': 'price_123', 'metadata': {'calls': '10000'}}}, | ||
{'id': 'prod_DEF', 'name': 'MapIt, 100,000 calls', | ||
'default_price': {'id': 'price_456', 'metadata': {'calls': '100000'}}}, | ||
], None, None) | ||
call_command( | ||
'add_mapit_user', '--email', '[email protected]', '--price', "mapit-100k-v", | ||
'add_mapit_user', '--email', '[email protected]', '--price', "MapIt, 100,000 calls", | ||
coupon='charitable25-6months', trial='10', | ||
stdout=StringIO(), stderr=StringIO()) | ||
|
||
self.MockStripe.Coupon.create.assert_called_once_with( | ||
id='charitable25-6months', duration='repeating', duration_in_months='6', percent_off='25') | ||
self.MockStripe.Subscription.create.assert_called_once_with( | ||
customer='CUSTOMER-ID', items=[{"price": 'mapit-100k-v'}], | ||
customer='CUSTOMER-ID', items=[{"price": 'price_456'}], | ||
default_tax_rates=[ANY], | ||
coupon='charitable25-6months', trial_period_days='10') | ||
|
||
user = User.objects.get(email='[email protected]') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.