-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Adding useful tests to more quickly iterate on building out configu…
…rable app. - Only outputting helpful request/response info if it is set. - Distinguish between JSON/form data in request body.
- Loading branch information
1 parent
c35432d
commit d39dda8
Showing
11 changed files
with
108 additions
and
14 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
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
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
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ coverage | |
codecov | ||
nose | ||
mock | ||
twine | ||
twine | ||
requests |
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,38 @@ | ||
import requests | ||
|
||
from tests.testcase import ManagedTestCase | ||
|
||
__author__ = "Alex Laird" | ||
__copyright__ = "Copyright 2020, Alex Laird" | ||
__version__ = "0.0.3" | ||
|
||
|
||
class TestInspection(ManagedTestCase): | ||
|
||
def test_http_get_query_params(self): | ||
# GIVEN | ||
params = {"param_1": "param_value_1"} | ||
|
||
# WHEN | ||
requests.get(self.webhook_url, params=params) | ||
|
||
# TODO: finish out test assertions | ||
|
||
def test_http_post_form_data(self): | ||
# GIVEN | ||
data = {"form_data_1": "form_data_value_1"} | ||
|
||
# WHEN | ||
requests.post(self.webhook_url, data=data) | ||
|
||
# TODO: finish out test assertions | ||
|
||
def test_http_post_json_data(self): | ||
# GIVEN | ||
headers = {"Content-Type": "application/json"} | ||
data = {"json_data_1": "json_data_value_1"} | ||
|
||
# WHEN | ||
requests.post(self.webhook_url, headers=headers, json=data) | ||
|
||
# TODO: finish out test assertions |
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,38 @@ | ||
import time | ||
import unittest | ||
|
||
from future.utils import iteritems | ||
|
||
from hookee.manager import Manager | ||
|
||
__author__ = "Alex Laird" | ||
__copyright__ = "Copyright 2020, Alex Laird" | ||
__version__ = "0.0.3" | ||
|
||
|
||
class ManagedTestCase(unittest.TestCase): | ||
REQUEST_FORM_DATA_BOUNDARY = "REQUEST_FORM_DATA_BOUNDARY" | ||
FORM_DATA_STARTING_PAYLOAD = '--{0}\r\nContent-Disposition: form-data; name=\\"'.format(REQUEST_FORM_DATA_BOUNDARY) | ||
FORM_DATA_MIDDLE_PAYLOAD = '\"\r\n\r\n' | ||
FORM_DATA_ENDING_PAYLOAD = '--{0}--'.format(REQUEST_FORM_DATA_BOUNDARY) | ||
|
||
def setUp(self): | ||
self.port = 5000 | ||
self.manager = Manager.get_instance(self.port) | ||
|
||
self.manager.start() | ||
|
||
self.webhook_url = "{}/webhook".format(self.manager.tunnel.public_url) | ||
|
||
def tearDown(self): | ||
self.manager.stop() | ||
|
||
time.sleep(2) | ||
|
||
def generate_form_data_payload(self, data): | ||
payload = "" | ||
for key, value in iteritems(data): | ||
payload += '{0}{1}{2}{3}\r\n'.format(self.FORM_DATA_STARTING_PAYLOAD, key, self.FORM_DATA_MIDDLE_PAYLOAD, | ||
value) | ||
payload += self.FORM_DATA_ENDING_PAYLOAD | ||
return payload |