Skip to content

Commit

Permalink
Merge pull request stripe#407 from stripe/ob-fix-tests-deleted-resources
Browse files Browse the repository at this point in the history
Fix tests for deleted resources
  • Loading branch information
ob-stripe authored Mar 13, 2018
2 parents 8e819f8 + b675a82 commit 23d51aa
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ cache:
env:
global:
- PYCURL_SSL_LIBRARY=gnutls
- STRIPE_MOCK_VERSION=0.8.0
- STRIPE_MOCK_VERSION=0.9.0

addons:
apt:
Expand Down
9 changes: 6 additions & 3 deletions tests/api_resources/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,15 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.Account.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/accounts/%s' % resource.id
'/v1/accounts/%s' % resource_id
)
self.assertIsInstance(resource, stripe.Account)
self.assertTrue(resource.deleted)

def test_can_retrieve_no_id(self):
resource = stripe.Account.retrieve()
Expand Down Expand Up @@ -190,7 +193,7 @@ def test_is_deletable(self):
'/v1/accounts/%s/external_accounts/%s' % (TEST_RESOURCE_ID,
TEST_EXTERNALACCOUNT_ID)
)
self.assertIsInstance(resource, stripe.BankAccount)
self.assertTrue(resource.deleted)


class AccountLoginLinksTests(StripeTestCase):
Expand Down
7 changes: 5 additions & 2 deletions tests/api_resources/test_apple_pay_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def test_is_creatable(self):

def test_is_deletable(self):
resource = stripe.ApplePayDomain.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/apple_pay/domains/%s' % resource.id
'/v1/apple_pay/domains/%s' % resource_id
)
self.assertIsInstance(resource, stripe.ApplePayDomain)
self.assertTrue(resource.deleted)
2 changes: 2 additions & 0 deletions tests/api_resources/test_bank_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def test_is_deletable(self):
'delete',
'/v1/customers/cus_123/sources/%s' % TEST_RESOURCE_ID
)
# stripe-mock does not yet correctly handle deleting customer sources
# self.assertTrue(resource.deleted)

def test_is_verifiable(self):
resource = self.construct_resource(customer='cus_123')
Expand Down
7 changes: 5 additions & 2 deletions tests/api_resources/test_coupon.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.Coupon.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/coupons/%s' % resource.id
'/v1/coupons/%s' % resource_id
)
self.assertIsInstance(resource, stripe.Coupon)
self.assertTrue(resource.deleted)
7 changes: 5 additions & 2 deletions tests/api_resources/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.Customer.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/customers/%s' % resource.id
'/v1/customers/%s' % resource_id
)
self.assertIsInstance(resource, stripe.Customer)
self.assertTrue(resource.deleted)


# stripe-mock does not handle the legacy subscription endpoint so we stub
Expand Down
7 changes: 5 additions & 2 deletions tests/api_resources/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.Plan.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/plans/%s' % resource.id
'/v1/plans/%s' % resource_id
)
self.assertIsInstance(resource, stripe.Plan)
self.assertTrue(resource.deleted)
7 changes: 5 additions & 2 deletions tests/api_resources/test_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.Product.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/products/%s' % resource.id
'/v1/products/%s' % resource_id
)
self.assertIsInstance(resource, stripe.Product)
self.assertTrue(resource.deleted)
7 changes: 5 additions & 2 deletions tests/api_resources/test_recipient.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.Recipient.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/recipients/%s' % resource.id
'/v1/recipients/%s' % resource_id
)
self.assertIsInstance(resource, stripe.Recipient)
self.assertTrue(resource.deleted)

def test_can_list_transfers(self):
recipient = stripe.Recipient.retrieve(TEST_RESOURCE_ID)
Expand Down
7 changes: 5 additions & 2 deletions tests/api_resources/test_sku.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.SKU.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/skus/%s' % resource.id
'/v1/skus/%s' % resource_id
)
self.assertIsInstance(resource, stripe.SKU)
self.assertTrue(resource.deleted)
7 changes: 5 additions & 2 deletions tests/api_resources/test_subscription_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ def test_is_modifiable(self):

def test_is_deletable(self):
resource = stripe.SubscriptionItem.retrieve(TEST_RESOURCE_ID)
# Unfortunately stripe-mock will return a resource with a different
# ID, so we need to store the original ID for the request assertion
resource_id = resource.id
resource.delete()
self.assert_requested(
'delete',
'/v1/subscription_items/%s' % resource.id
'/v1/subscription_items/%s' % resource_id
)
self.assertIsInstance(resource, stripe.SubscriptionItem)
self.assertTrue(resource.deleted)
2 changes: 1 addition & 1 deletion tests/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from tests.request_mock import RequestMock


MOCK_MINIMUM_VERSION = '0.5.0'
MOCK_MINIMUM_VERSION = '0.9.0'
MOCK_PORT = os.environ.get('STRIPE_MOCK_PORT', 12111)


Expand Down

0 comments on commit 23d51aa

Please sign in to comment.