-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added basic CRUD methods for Webhook objects
- Loading branch information
1 parent
f3820ea
commit 4264acb
Showing
6 changed files
with
75 additions
and
12 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 |
---|---|---|
@@ -1 +1 @@ | ||
3.4.0 | ||
3.5.0 |
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 |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = '3.4.0' | ||
VERSION = '3.5.0' |
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,45 @@ | ||
# Unit tests related to 'Webhook' (https://www.easypost.com/webhooks-guide). | ||
|
||
import unittest | ||
import easypost | ||
from constants import API_KEY as api_key | ||
|
||
easypost.api_key = api_key | ||
|
||
|
||
class WebhookTests(unittest.TestCase): | ||
|
||
def test_webhooks(self): | ||
# Create a webhook | ||
webhook = easypost.Webhook.create(url="example.com") | ||
assert webhook.id is not None | ||
assert webhook.mode == "test" | ||
assert webhook.url == "http://example.com" | ||
assert webhook.disabled_at is None | ||
assert type(webhook) == easypost.Webhook | ||
|
||
# Retrieve a webhook | ||
webhook2 = easypost.Webhook.retrieve(webhook.id) | ||
assert webhook2.id is not None | ||
assert webhook2.id == webhook.id | ||
|
||
# Update a webhook (re-enable it) | ||
webhook3 = webhook.update() | ||
assert webhook3.id is not None | ||
assert webhook3.id == webhook.id | ||
|
||
# Index webhooks | ||
webhooks = easypost.Webhook.all() | ||
assert webhooks["webhooks"][len(webhooks["webhooks"]) - 1].id == webhook.id | ||
|
||
# Delete a webhook | ||
webhook.delete() | ||
try: | ||
easypost.Webhook.retrieve(webhook.id) | ||
except easypost.Error as e: | ||
assert e.http_status == 404 | ||
assert e.message == "The requested resource could not be found." | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |