-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for /v1/topups endpoints #396
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from stripe.api_resources.abstract import CreateableAPIResource | ||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class Topup(CreateableAPIResource, ListableAPIResource, UpdateableAPIResource): | ||
OBJECT_NAME = 'topup' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import stripe | ||
from tests.helper import StripeTestCase | ||
|
||
|
||
TEST_RESOURCE_ID = 'tu_123' | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Unnecessary extra lines? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Similarly to the comment above, I believe PEP 8 will require this doubled up blank line too.) |
||
class TopupTest(StripeTestCase): | ||
def test_is_listable(self): | ||
resources = stripe.Topup.list() | ||
self.assert_requested( | ||
'get', | ||
'/v1/topups' | ||
) | ||
self.assertIsInstance(resources.data, list) | ||
self.assertIsInstance(resources.data[0], stripe.Topup) | ||
|
||
def test_is_retrievable(self): | ||
resource = stripe.Topup.retrieve(TEST_RESOURCE_ID) | ||
self.assert_requested( | ||
'get', | ||
'/v1/topups/%s' % TEST_RESOURCE_ID | ||
) | ||
self.assertIsInstance(resource, stripe.Topup) | ||
|
||
def test_is_creatable(self): | ||
resource = stripe.Topup.create( | ||
amount=100, | ||
currency='usd', | ||
source='src_123', | ||
description='description', | ||
statement_descriptor='statement descriptor' | ||
) | ||
self.assert_requested( | ||
'post', | ||
'/v1/topups' | ||
) | ||
self.assertIsInstance(resource, stripe.Topup) | ||
|
||
def test_is_saveable(self): | ||
resource = stripe.Topup.retrieve(TEST_RESOURCE_ID) | ||
resource.metadata['key'] = 'value' | ||
resource.save() | ||
self.assert_requested( | ||
'post', | ||
'/v1/topups/%s' % resource.id | ||
) | ||
|
||
def test_is_modifiable(self): | ||
resource = stripe.Topup.modify( | ||
TEST_RESOURCE_ID, | ||
metadata={'key': 'value'} | ||
) | ||
self.assert_requested( | ||
'post', | ||
'/v1/topups/%s' % TEST_RESOURCE_ID | ||
) | ||
self.assertIsInstance(resource, stripe.Topup) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth checking the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried this, but it looks like stripe-mock doesn't actually mutate received data correctly. I believe it just validates what it received and returns stock data. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that's correct Jamu. We want to fix this at some point, but for now it's not working checking any of the data that you get back. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Extra line here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the style used in other files, so I copied. I'll leave it as is to maintain consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a little weird coming from other languages, but believe it or not, this is conformant with the most universally accepted style for Python, PEP 8. From the spec:
There's a check that will fail the test suite if the style is off, so you're safe from pulling something in that's wrong, but I'd suggest as a general guideline just doing what Jamu did and copying the style seen elsewhere.