-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the Webhook Endpoint resource
- Loading branch information
1 parent
a9a8d75
commit fa20a06
Showing
4 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from stripe.api_resources.abstract import CreateableAPIResource | ||
from stripe.api_resources.abstract import DeletableAPIResource | ||
from stripe.api_resources.abstract import UpdateableAPIResource | ||
from stripe.api_resources.abstract import ListableAPIResource | ||
|
||
|
||
class WebhookEndpoint(CreateableAPIResource, UpdateableAPIResource, | ||
DeletableAPIResource, ListableAPIResource): | ||
OBJECT_NAME = 'webhook_endpoint' |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from __future__ import absolute_import, division, print_function | ||
|
||
import stripe | ||
|
||
|
||
TEST_RESOURCE_ID = 'we_123' | ||
|
||
|
||
class TestWebhookEndpoint(object): | ||
def test_is_listable(self, request_mock): | ||
resources = stripe.WebhookEndpoint.list() | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/webhook_endpoints' | ||
) | ||
assert isinstance(resources.data, list) | ||
assert isinstance(resources.data[0], stripe.WebhookEndpoint) | ||
|
||
def test_is_retrievable(self, request_mock): | ||
resource = stripe.WebhookEndpoint.retrieve(TEST_RESOURCE_ID) | ||
request_mock.assert_requested( | ||
'get', | ||
'/v1/webhook_endpoints/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.WebhookEndpoint) | ||
|
||
def test_is_creatable(self, request_mock): | ||
resource = stripe.WebhookEndpoint.create( | ||
enabled_events=['*'], | ||
url='https://stripe.com' | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/webhook_endpoints' | ||
) | ||
assert isinstance(resource, stripe.WebhookEndpoint) | ||
|
||
def test_is_saveable(self, request_mock): | ||
resource = stripe.WebhookEndpoint.retrieve(TEST_RESOURCE_ID) | ||
resource.enabled_events = ['*'] | ||
resource.save() | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/webhook_endpoints/%s' % TEST_RESOURCE_ID | ||
) | ||
|
||
def test_is_modifiable(self, request_mock): | ||
resource = stripe.WebhookEndpoint.modify( | ||
TEST_RESOURCE_ID, | ||
enabled_events=['*'] | ||
) | ||
request_mock.assert_requested( | ||
'post', | ||
'/v1/webhook_endpoints/%s' % TEST_RESOURCE_ID | ||
) | ||
assert isinstance(resource, stripe.WebhookEndpoint) | ||
|
||
def test_is_deletable(self, request_mock): | ||
resource = stripe.WebhookEndpoint.retrieve(TEST_RESOURCE_ID) | ||
resource.delete() | ||
request_mock.assert_requested( | ||
'delete', | ||
'/v1/webhook_endpoints/%s' % TEST_RESOURCE_ID | ||
) | ||
assert resource.deleted is True |