Skip to content
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

Update generated code for beta #999

Merged
merged 6 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v431
v438
19 changes: 11 additions & 8 deletions stripe/api_resources/abstract/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ class TestHelpers(APIResourceTestHelpers):
def __init__(self, resource):
self.resource = resource

@classmethod
def _static_request(cls, *args, **kwargs):
return cls._resource_cls._static_request(*args, **kwargs)

@classmethod
def _static_request_stream(cls, *args, **kwargs):
return cls._resource_cls._static_request_stream(*args, **kwargs)

@classmethod
def class_url(cls):
if cls == APIResourceTestHelpers:
Expand Down Expand Up @@ -48,16 +56,11 @@ def instance_url(self):
return "%s/%s" % (base, extn)


# TODO (next major)
def test_helpers(cls):
"""
test_helpers decorator adds a test_helpers property and
wires the parent resource class to the nested TestHelpers class.

Should only be used on types that inherit from APIResource.

@test_helpers
class Foo(APIResource):
class TestHelpers(APIResourceTestHelpers):
The test_helpers decorator is deprecated and will be removed in a future version
of the library.
"""

def test_helpers_getter(self):
Expand Down
9 changes: 7 additions & 2 deletions stripe/api_resources/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
from stripe.api_resources.abstract import SearchableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import nested_resource_class_methods
from stripe.api_resources.abstract import test_helpers


@test_helpers
@nested_resource_class_methods(
"balance_transaction",
operations=["create", "retrieve", "update", "list"],
Expand Down Expand Up @@ -253,3 +251,10 @@ def fund_cash_balance(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


Customer.TestHelpers._resource_cls = Customer
9 changes: 7 additions & 2 deletions stripe/api_resources/issuing/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class Card(CreateableAPIResource, ListableAPIResource, UpdateableAPIResource):
"""
You can [create physical or virtual cards](https://stripe.com/docs/issuing/cards) that are issued to cardholders.
Expand Down Expand Up @@ -142,3 +140,10 @@ def ship_card(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


Card.TestHelpers._resource_cls = Card
9 changes: 7 additions & 2 deletions stripe/api_resources/issuing/card_design.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from stripe.api_resources.abstract import APIResourceTestHelpers
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class CardDesign(ListableAPIResource, UpdateableAPIResource):
"""
A Card Design is a logical grouping of a Card Bundle, card logo, and carrier text that represents a product line.
Expand Down Expand Up @@ -79,3 +77,10 @@ def deactivate_testmode(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


CardDesign.TestHelpers._resource_cls = CardDesign
9 changes: 7 additions & 2 deletions stripe/api_resources/refund.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class Refund(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
):
Expand Down Expand Up @@ -86,3 +84,10 @@ def expire(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


Refund.TestHelpers._resource_cls = Refund
9 changes: 7 additions & 2 deletions stripe/api_resources/terminal/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
from stripe.api_resources.abstract import DeletableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import UpdateableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class Reader(
CreateableAPIResource,
DeletableAPIResource,
Expand Down Expand Up @@ -305,3 +303,10 @@ def present_payment_method(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


Reader.TestHelpers._resource_cls = Reader
9 changes: 7 additions & 2 deletions stripe/api_resources/treasury/inbound_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from stripe.api_resources.abstract import APIResourceTestHelpers
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class InboundTransfer(CreateableAPIResource, ListableAPIResource):
"""
Use [InboundTransfers](https://stripe.com/docs/treasury/moving-money/financial-accounts/into/inbound-transfers) to add funds to your [FinancialAccount](https://stripe.com/docs/api#financial_accounts) via a PaymentMethod that is owned by you. The funds will be transferred via an ACH debit.
Expand Down Expand Up @@ -141,3 +139,10 @@ def succeed(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


InboundTransfer.TestHelpers._resource_cls = InboundTransfer
9 changes: 7 additions & 2 deletions stripe/api_resources/treasury/outbound_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from stripe.api_resources.abstract import APIResourceTestHelpers
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class OutboundPayment(CreateableAPIResource, ListableAPIResource):
"""
Use OutboundPayments to send funds to another party's external bank account or [FinancialAccount](https://stripe.com/docs/api#financial_accounts). To send money to an account belonging to the same user, use an [OutboundTransfer](https://stripe.com/docs/api#outbound_transfers).
Expand Down Expand Up @@ -143,3 +141,10 @@ def return_outbound_payment(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


OutboundPayment.TestHelpers._resource_cls = OutboundPayment
9 changes: 7 additions & 2 deletions stripe/api_resources/treasury/outbound_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from stripe.api_resources.abstract import APIResourceTestHelpers
from stripe.api_resources.abstract import CreateableAPIResource
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class OutboundTransfer(CreateableAPIResource, ListableAPIResource):
"""
Use OutboundTransfers to transfer funds from a [FinancialAccount](https://stripe.com/docs/api#financial_accounts) to a PaymentMethod belonging to the same entity. To send funds to a different party, use [OutboundPayments](https://stripe.com/docs/api#outbound_payments) instead. You can send funds over ACH rails or through a domestic wire transfer to a user's own external bank account.
Expand Down Expand Up @@ -143,3 +141,10 @@ def return_outbound_transfer(self, idempotency_key=None, **params):
idempotency_key=idempotency_key,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


OutboundTransfer.TestHelpers._resource_cls = OutboundTransfer
9 changes: 7 additions & 2 deletions stripe/api_resources/treasury/received_credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

from stripe.api_resources.abstract import APIResourceTestHelpers
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class ReceivedCredit(ListableAPIResource):
"""
ReceivedCredits represent funds sent to a [FinancialAccount](https://stripe.com/docs/api#financial_accounts) (for example, via ACH or wire). These money movements are not initiated from the FinancialAccount.
Expand All @@ -32,3 +30,10 @@ def create(
stripe_account=stripe_account,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


ReceivedCredit.TestHelpers._resource_cls = ReceivedCredit
9 changes: 7 additions & 2 deletions stripe/api_resources/treasury/received_debit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

from stripe.api_resources.abstract import APIResourceTestHelpers
from stripe.api_resources.abstract import ListableAPIResource
from stripe.api_resources.abstract import test_helpers


@test_helpers
class ReceivedDebit(ListableAPIResource):
"""
ReceivedDebits represent funds pulled from a [FinancialAccount](https://stripe.com/docs/api#financial_accounts). These are not initiated from the FinancialAccount.
Expand All @@ -32,3 +30,10 @@ def create(
stripe_account=stripe_account,
params=params,
)

@property
def test_helpers(self):
return self.TestHelpers(self)


ReceivedDebit.TestHelpers._resource_cls = ReceivedDebit
12 changes: 6 additions & 6 deletions tests/api_resources/abstract/test_test_helpers_api_resource.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from __future__ import absolute_import, division, print_function

import stripe
import pytest
from stripe import util
from stripe.api_resources.abstract import APIResourceTestHelpers


class TestTestHelperAPIResource(object):
@stripe.api_resources.abstract.test_helpers
class MyTestHelpersResource(stripe.api_resources.abstract.APIResource):
OBJECT_NAME = "myresource"

Expand All @@ -26,6 +24,12 @@ def do_stuff(self, idempotency_key=None, **params):
)
return self.resource

@property
def test_helpers(self):
return self.TestHelpers(self)

MyTestHelpersResource.TestHelpers._resource_cls = MyTestHelpersResource

def test_call_custom_method_class(self, request_mock):
request_mock.stub_request(
"post",
Expand Down Expand Up @@ -60,7 +64,3 @@ def test_call_custom_method_instance_via_property(self, request_mock):
{"foo": "bar"},
)
assert obj.thing_done is True

def test_helper_decorator_raises_for_non_resource(self):
with pytest.raises(ValueError):
stripe.api_resources.abstract.test_helpers(str)
2 changes: 1 addition & 1 deletion tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_convert_to_stripe_object_and_back(self):

obj = util.convert_to_stripe_object(resp)
assert isinstance(obj, stripe.Balance)
assert type(obj.available) == list
assert isinstance(obj.available, list)
assert isinstance(obj.available[0], stripe.stripe_object.StripeObject)

d = util.convert_to_dict(obj)
Expand Down