webhook tests: Rename main helper to check_webhook.

Almost all webhook tests use this helper, except a few
webhooks that write to private streams.

Being concise is important here, and the name
`self.send_and_test_stream_message` always confused
me, since it sounds you're sending a stream message,
and it leaves out the webhook piece.

We should consider renaming `send_and_test_private_message`
to something like `check_webhook_private`, but I couldn't
decide on a great name, and it's very rarely used.  So
for now I just made sure the docstrings of the two
sibling functions reference each other.
This commit is contained in:
Steve Howell 2020-08-23 13:49:24 +00:00 committed by Tim Abbott
parent 00001a396b
commit 388053db6b
71 changed files with 1726 additions and 1467 deletions

View File

@ -323,8 +323,8 @@ class HelloWorldHookTests(WebhookTestCase):
expected_message = "Hello! I am happy to be here! :smile: \nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**"; expected_message = "Hello! I am happy to be here! :smile: \nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**";
# use fixture named helloworld_hello # use fixture named helloworld_hello
self.send_and_test_stream_message('hello', expected_topic, expected_message, self.check_webhook('hello', expected_topic, expected_message,
content_type="application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded")
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("helloworld", fixture_name, file_type="json") return self.webhook_fixture_data("helloworld", fixture_name, file_type="json")
@ -333,9 +333,9 @@ class HelloWorldHookTests(WebhookTestCase):
In the above example, `STREAM_NAME`, `URL_TEMPLATE`, and `FIXTURE_DIR_NAME` refer In the above example, `STREAM_NAME`, `URL_TEMPLATE`, and `FIXTURE_DIR_NAME` refer
to class attributes from the base class, `WebhookTestCase`. These are needed by to class attributes from the base class, `WebhookTestCase`. These are needed by
the helper function `send_and_test_stream_message` to determine how to execute the helper function `check_webhook` to determine how to execute
your test. `STREAM_NAME` should be set to your default stream. If it doesn't exist, your test. `STREAM_NAME` should be set to your default stream. If it doesn't exist,
`send_and_test_stream_message` will create it while executing your test. `check_webhook` will create it while executing your test.
If your test expects a stream name from a test fixture, the value in the fixture If your test expects a stream name from a test fixture, the value in the fixture
and the value you set for `STREAM_NAME` must match. The test helpers use `STREAM_NAME` and the value you set for `STREAM_NAME` must match. The test helpers use `STREAM_NAME`
@ -364,8 +364,8 @@ class called something like `test_goodbye_message`:
expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**"; expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**";
# use fixture named helloworld_goodbye # use fixture named helloworld_goodbye
self.send_and_test_stream_message('goodbye', expected_topic, expected_message, self.check_webhook('goodbye', expected_topic, expected_message,
content_type="application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded")
``` ```
As well as a new fixture `goodbye.json` in As well as a new fixture `goodbye.json` in
@ -509,7 +509,7 @@ Here is an example from the WordPress integration:
``` ```
def test_unknown_action_no_data(self) -> None: def test_unknown_action_no_data(self) -> None:
# Mimic send_and_test_stream_message() to manually execute a negative test. # Mimic check_webhook() to manually execute a negative test.
# Otherwise its call to send_json_payload() would assert on the non-success # Otherwise its call to send_json_payload() would assert on the non-success
# we are testing. The value of result is the error message the webhook should # we are testing. The value of result is the error message the webhook should
# return if no params are sent. The fixture for this test is an empty file. # return if no params are sent. The fixture for this test is an empty file.
@ -526,7 +526,7 @@ def test_unknown_action_no_data(self) -> None:
self.assert_json_error(result, "Unknown WordPress webhook action: WordPress Action") self.assert_json_error(result, "Unknown WordPress webhook action: WordPress Action")
``` ```
In a normal test, `send_and_test_stream_message` would handle all the setup In a normal test, `check_webhook` would handle all the setup
and then check that the incoming webhook's response matches the expected result. If and then check that the incoming webhook's response matches the expected result. If
the webhook returns an error, the test fails. Instead, explicitly do the the webhook returns an error, the test fails. Instead, explicitly do the
setup it would have done, and check the result yourself. setup it would have done, and check the result yourself.
@ -540,7 +540,7 @@ webhook. As long as `self.url` is correct, you don't need to construct the webho
URL yourself. (In most cases, it is.) URL yourself. (In most cases, it is.)
`assert_json_error` then checks if the result matches the expected error. `assert_json_error` then checks if the result matches the expected error.
If you had used `send_and_test_stream_message`, it would have called If you had used `check_webhook`, it would have called
`send_json_payload`, which checks the result with `assert_json_success`. `send_json_payload`, which checks the result with `assert_json_success`.
### Custom query parameters ### Custom query parameters
@ -589,7 +589,7 @@ class QuerytestHookTests(WebhookTestCase):
expected_topic = "Query Test" expected_topic = "Query Test"
expected_message = "This is a test of custom query parameters." expected_message = "This is a test of custom query parameters."
self.send_and_test_stream_message('test_one', expected_topic, expected_message, self.check_webhook('test_one', expected_topic, expected_message,
content_type="application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded")
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:

View File

@ -1003,11 +1003,34 @@ class WebhookTestCase(ZulipTestCase):
def api_stream_message(self, user: UserProfile, *args: Any, **kwargs: Any) -> HttpResponse: def api_stream_message(self, user: UserProfile, *args: Any, **kwargs: Any) -> HttpResponse:
kwargs['HTTP_AUTHORIZATION'] = self.encode_user(user) kwargs['HTTP_AUTHORIZATION'] = self.encode_user(user)
return self.send_and_test_stream_message(*args, **kwargs) return self.check_webhook(*args, **kwargs)
def send_and_test_stream_message(self, fixture_name: str, expected_topic: Optional[str]=None, def check_webhook(
expected_message: Optional[str]=None, self,
content_type: Optional[str]="application/json", **kwargs: Any) -> Message: fixture_name: str,
expected_topic: Optional[str]=None,
expected_message: Optional[str]=None,
content_type: Optional[str]="application/json",
**kwargs: Any,
) -> Message:
"""
check_webhook is the main way to test "normal" webhooks that
work by receiving a payload from a third party and then writing
some message to a Zulip stream.
We use `fixture_name` to find the payload data in of our test
fixtures. Then we verify that a message gets sent to a stream:
self.STREAM_NAME: stream name
expected_topic: topic
expected_message: content
We simulate the delivery of the payload with `content_type`,
and you can pass other headers via `kwargs`.
For the rare cases of webhooks actually sending private messages,
see send_and_test_private_message.
"""
payload = self.get_body(fixture_name) payload = self.get_body(fixture_name)
if content_type is not None: if content_type is not None:
kwargs['content_type'] = content_type kwargs['content_type'] = content_type
@ -1029,6 +1052,13 @@ class WebhookTestCase(ZulipTestCase):
content_type: str = "application/json", content_type: str = "application/json",
**kwargs: Any, **kwargs: Any,
) -> Message: ) -> Message:
"""
For the rare cases that you are testing a webhook that sends
private messages, use this function.
Most webhooks send to streams, and you will want to look at
check_webhook.
"""
payload = self.get_body(fixture_name) payload = self.get_body(fixture_name)
kwargs['content_type'] = content_type kwargs['content_type'] = content_type

View File

@ -9,4 +9,4 @@ class AirbrakeHookTests(WebhookTestCase):
def test_airbrake_error_message(self) -> None: def test_airbrake_error_message(self) -> None:
expected_topic = "ZulipIntegrationTest" expected_topic = "ZulipIntegrationTest"
expected_message = "[ZeroDivisionError](https://zulip.airbrake.io/projects/125209/groups/1705190192091077626): \"Error message from logger\" occurred." expected_message = "[ZeroDivisionError](https://zulip.airbrake.io/projects/125209/groups/1705190192091077626): \"Error message from logger\" occurred."
self.send_and_test_stream_message('error_message', expected_topic, expected_message) self.check_webhook("error_message", expected_topic, expected_message)

View File

@ -14,11 +14,8 @@ class AlertmanagerHookTests(WebhookTestCase):
* CPU core temperature is 17.625C ([graph](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0)) * CPU core temperature is 17.625C ([graph](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'alert', "alert", expected_topic, expected_message, "application/json",
expected_topic,
expected_message,
"application/json",
) )
def test_single_error_issue_message(self) -> None: def test_single_error_issue_message(self) -> None:
@ -27,9 +24,6 @@ class AlertmanagerHookTests(WebhookTestCase):
:squared_ok: **Resolved** CPU core temperature is 34.75C ([graph](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0)) :squared_ok: **Resolved** CPU core temperature is 34.75C ([graph](http://cobalt:9090/graph?g0.expr=avg+by%28host%29+%28sensors_temp_input%7Bfeature%3D~%22core_%5B0-9%5D%2B%22%7D%29+%3E+15&g0.tab=0))
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'single_alert', "single_alert", expected_topic, expected_message, "application/json",
expected_topic,
expected_message,
"application/json",
) )

View File

@ -14,7 +14,7 @@ class AnsibletowerHookTests(WebhookTestCase):
expected_message = ("Project Update: [#2677 AWX - Project Update]" expected_message = ("Project Update: [#2677 AWX - Project Update]"
"(http://awx.example.co.uk/#/jobs/project/2677) was successful.") "(http://awx.example.co.uk/#/jobs/project/2677) was successful.")
self.send_and_test_stream_message('project_update_successful', expected_topic, expected_message) self.check_webhook("project_update_successful", expected_topic, expected_message)
def test_ansibletower_project_update_failed_message(self) -> None: def test_ansibletower_project_update_failed_message(self) -> None:
""" """
@ -24,7 +24,7 @@ class AnsibletowerHookTests(WebhookTestCase):
expected_message = ("Project Update: [#2678 AWX - Project Update]" expected_message = ("Project Update: [#2678 AWX - Project Update]"
"(http://awx.example.co.uk/#/jobs/project/2678) failed.") "(http://awx.example.co.uk/#/jobs/project/2678) failed.")
self.send_and_test_stream_message('project_update_failed', expected_topic, expected_message) self.check_webhook("project_update_failed", expected_topic, expected_message)
def test_ansibletower_job_successful_multiple_hosts_message(self) -> None: def test_ansibletower_job_successful_multiple_hosts_message(self) -> None:
""" """
@ -40,7 +40,7 @@ Job: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk/#/jobs/play
* mail.example.co.uk: Success * mail.example.co.uk: Success
""".strip() """.strip()
self.send_and_test_stream_message('job_successful_multiple_hosts', expected_topic, expected_message) self.check_webhook("job_successful_multiple_hosts", expected_topic, expected_message)
def test_ansibletower_job_successful_message(self) -> None: def test_ansibletower_job_successful_message(self) -> None:
""" """
@ -52,7 +52,7 @@ Job: [#2674 System - Deploy - Zabbix Agent](http://awx.example.co.uk/#/jobs/play
* chat.example.co.uk: Success * chat.example.co.uk: Success
""".strip() """.strip()
self.send_and_test_stream_message('job_successful', expected_topic, expected_message) self.check_webhook("job_successful", expected_topic, expected_message)
def test_ansibletower_nine_job_successful_message(self) -> None: def test_ansibletower_nine_job_successful_message(self) -> None:
""" """
@ -65,7 +65,7 @@ Job: [#1 Demo Job Template](https://towerhost/#/jobs/playbook/1) was successful:
* localhost: Success * localhost: Success
""".strip() """.strip()
self.send_and_test_stream_message('job_complete_successful_awx_9.1.1', expected_topic, expected_message) self.check_webhook("job_complete_successful_awx_9.1.1", expected_topic, expected_message)
def test_ansibletower_job_failed_message(self) -> None: def test_ansibletower_job_failed_message(self) -> None:
""" """
@ -77,7 +77,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
* chat.example.co.uk: Failed * chat.example.co.uk: Failed
""".strip() """.strip()
self.send_and_test_stream_message('job_failed', expected_topic, expected_message) self.check_webhook("job_failed", expected_topic, expected_message)
def test_ansibletower_job_failed_multiple_hosts_message(self) -> None: def test_ansibletower_job_failed_multiple_hosts_message(self) -> None:
""" """
@ -93,7 +93,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
* mail.example.co.uk: Failed * mail.example.co.uk: Failed
""".strip() """.strip()
self.send_and_test_stream_message('job_failed_multiple_hosts', expected_topic, expected_message) self.check_webhook("job_failed_multiple_hosts", expected_topic, expected_message)
def test_ansibletower_inventory_update_successful_message(self) -> None: def test_ansibletower_inventory_update_successful_message(self) -> None:
""" """
@ -103,7 +103,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
expected_message = ("Inventory Update: [#2724 AWX - Inventory Update]" expected_message = ("Inventory Update: [#2724 AWX - Inventory Update]"
"(http://awx.example.co.uk/#/jobs/inventory/2724) was successful.") "(http://awx.example.co.uk/#/jobs/inventory/2724) was successful.")
self.send_and_test_stream_message('inventory_update_successful', expected_topic, expected_message) self.check_webhook("inventory_update_successful", expected_topic, expected_message)
def test_ansibletower_inventory_update_failed_message(self) -> None: def test_ansibletower_inventory_update_failed_message(self) -> None:
""" """
@ -113,7 +113,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
expected_message = ("Inventory Update: [#2724 AWX - Inventory Update]" expected_message = ("Inventory Update: [#2724 AWX - Inventory Update]"
"(http://awx.example.co.uk/#/jobs/inventory/2724) failed.") "(http://awx.example.co.uk/#/jobs/inventory/2724) failed.")
self.send_and_test_stream_message('inventory_update_failed', expected_topic, expected_message) self.check_webhook("inventory_update_failed", expected_topic, expected_message)
def test_ansibletower_adhoc_command_successful_message(self) -> None: def test_ansibletower_adhoc_command_successful_message(self) -> None:
""" """
@ -123,7 +123,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
expected_message = ("AdHoc Command: [#2726 shell: uname -r]" expected_message = ("AdHoc Command: [#2726 shell: uname -r]"
"(http://awx.example.co.uk/#/jobs/command/2726) was successful.") "(http://awx.example.co.uk/#/jobs/command/2726) was successful.")
self.send_and_test_stream_message('adhoc_command_successful', expected_topic, expected_message) self.check_webhook("adhoc_command_successful", expected_topic, expected_message)
def test_ansibletower_adhoc_command_failed_message(self) -> None: def test_ansibletower_adhoc_command_failed_message(self) -> None:
""" """
@ -133,7 +133,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
expected_message = ("AdHoc Command: [#2726 shell: uname -r]" expected_message = ("AdHoc Command: [#2726 shell: uname -r]"
"(http://awx.example.co.uk/#/jobs/command/2726) failed.") "(http://awx.example.co.uk/#/jobs/command/2726) failed.")
self.send_and_test_stream_message('adhoc_command_failed', expected_topic, expected_message) self.check_webhook("adhoc_command_failed", expected_topic, expected_message)
def test_ansibletower_system_job_successful_message(self) -> None: def test_ansibletower_system_job_successful_message(self) -> None:
""" """
@ -143,7 +143,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
expected_message = ("System Job: [#2721 Cleanup Job Details]" expected_message = ("System Job: [#2721 Cleanup Job Details]"
"(http://awx.example.co.uk/#/jobs/system/2721) was successful.") "(http://awx.example.co.uk/#/jobs/system/2721) was successful.")
self.send_and_test_stream_message('system_job_successful', expected_topic, expected_message) self.check_webhook("system_job_successful", expected_topic, expected_message)
def test_ansibletower_system_job_failed_message(self) -> None: def test_ansibletower_system_job_failed_message(self) -> None:
""" """
@ -153,7 +153,7 @@ Job: [#2722 System - Updates - Ubuntu](http://awx.example.co.uk/#/jobs/playbook/
expected_message = ("System Job: [#2721 Cleanup Job Details]" expected_message = ("System Job: [#2721 Cleanup Job Details]"
"(http://awx.example.co.uk/#/jobs/system/2721) failed.") "(http://awx.example.co.uk/#/jobs/system/2721) failed.")
self.send_and_test_stream_message('system_job_failed', expected_topic, expected_message) self.check_webhook("system_job_failed", expected_topic, expected_message)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("ansibletower", fixture_name, file_type="json") return self.webhook_fixture_data("ansibletower", fixture_name, file_type="json")

View File

@ -10,8 +10,12 @@ class AppFollowHookTests(WebhookTestCase):
expected_topic = "Webhook integration was successful." expected_topic = "Webhook integration was successful."
expected_message = """Webhook integration was successful. expected_message = """Webhook integration was successful.
Test User / Acme (Google Play)""" Test User / Acme (Google Play)"""
self.send_and_test_stream_message('sample', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "sample",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_reviews(self) -> None: def test_reviews(self) -> None:
expected_topic = "Acme - Group chat" expected_topic = "Acme - Group chat"
@ -22,8 +26,12 @@ App Store, Acme Technologies, Inc.
Acme enables me to manage the flow of information quite well. I only wish I could create and edit my Acme Post files in the iOS app. Acme enables me to manage the flow of information quite well. I only wish I could create and edit my Acme Post files in the iOS app.
*by* **Mr RESOLUTIONARY** *for v3.9* *by* **Mr RESOLUTIONARY** *for v3.9*
[Permalink](http://appfollow.io/permalink) · [Add tag](http://watch.appfollow.io/add_tag)""" [Permalink](http://appfollow.io/permalink) · [Add tag](http://watch.appfollow.io/add_tag)"""
self.send_and_test_stream_message('review', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "review",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_reviews_with_topic(self) -> None: def test_reviews_with_topic(self) -> None:
# This temporary patch of URL_TEMPLATE is code smell but required due to the way # This temporary patch of URL_TEMPLATE is code smell but required due to the way
@ -39,8 +47,12 @@ App Store, Acme Technologies, Inc.
Acme enables me to manage the flow of information quite well. I only wish I could create and edit my Acme Post files in the iOS app. Acme enables me to manage the flow of information quite well. I only wish I could create and edit my Acme Post files in the iOS app.
*by* **Mr RESOLUTIONARY** *for v3.9* *by* **Mr RESOLUTIONARY** *for v3.9*
[Permalink](http://appfollow.io/permalink) · [Add tag](http://watch.appfollow.io/add_tag)""" [Permalink](http://appfollow.io/permalink) · [Add tag](http://watch.appfollow.io/add_tag)"""
self.send_and_test_stream_message('review', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "review",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
self.URL_TEMPLATE = original_url_template self.URL_TEMPLATE = original_url_template
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:

View File

@ -18,7 +18,7 @@ class AppveyorHookTests(WebhookTestCase):
* **Finished**: 9/9/2018 7:06 PM * **Finished**: 9/9/2018 7:06 PM
""".strip() """.strip()
self.send_and_test_stream_message('appveyor_build_success', expected_topic, expected_message) self.check_webhook("appveyor_build_success", expected_topic, expected_message)
def test_appveyor_build_failure_message(self) -> None: def test_appveyor_build_failure_message(self) -> None:
""" """
@ -32,7 +32,7 @@ class AppveyorHookTests(WebhookTestCase):
* **Finished**: 9/9/2018 7:06 PM * **Finished**: 9/9/2018 7:06 PM
""".strip() """.strip()
self.send_and_test_stream_message('appveyor_build_failure', expected_topic, expected_message) self.check_webhook("appveyor_build_failure", expected_topic, expected_message)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("appveyor", fixture_name, file_type="json") return self.webhook_fixture_data("appveyor", fixture_name, file_type="json")

View File

@ -136,4 +136,4 @@ class BasecampHookTests(WebhookTestCase):
self._send_and_test_message('comment_created', expected_message) self._send_and_test_message('comment_created', expected_message)
def _send_and_test_message(self, fixture_name: str, expected_message: str) -> None: def _send_and_test_message(self, fixture_name: str, expected_message: str) -> None:
self.send_and_test_stream_message(fixture_name, TOPIC, expected_message) self.check_webhook(fixture_name, TOPIC, expected_message)

View File

@ -17,10 +17,12 @@ You are going to derail from goal **gainweight** in **5.6 hours**. You need **+2
* Pledge: **0$** :relieved: * Pledge: **0$** :relieved:
""".strip() """.strip()
self.send_and_test_stream_message('derail', self.check_webhook(
expected_topic, "derail",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
@patch('zerver.webhooks.beeminder.view.time.time') @patch('zerver.webhooks.beeminder.view.time.time')
def test_beeminder_derail_worried(self, time: Any) -> None: def test_beeminder_derail_worried(self, time: Any) -> None:
@ -31,10 +33,9 @@ You are going to derail from goal **gainweight** in **5.6 hours**. You need **+2
* Pledge: **5$** :worried: * Pledge: **5$** :worried:
""".strip() """.strip()
self.send_and_test_stream_message('derail_worried', self.check_webhook(
expected_topic, "derail_worried", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("beeminder", fixture_name, file_type="json") return self.webhook_fixture_data("beeminder", fixture_name, file_type="json")

View File

@ -15,111 +15,121 @@ class Bitbucket2HookTests(WebhookTestCase):
def test_bitbucket2_on_push_event(self) -> None: def test_bitbucket2_on_push_event(self) -> None:
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))'
expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}" expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}"
self.send_and_test_stream_message('push', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("push", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_multiple_committers(self) -> None: def test_bitbucket2_on_push_commits_multiple_committers(self) -> None:
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{commit_info*2}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{commit_info*2}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
self.send_and_test_stream_message('push_multiple_committers', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None: def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None:
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{commit_info*9}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{commit_info*9}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
self.send_and_test_stream_message('push_multiple_committers_with_others', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook(
"push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message
)
def test_bitbucket2_on_push_commits_multiple_committers_filtered_by_branches(self) -> None: def test_bitbucket2_on_push_commits_multiple_committers_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{commit_info*2}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{commit_info*2}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
self.send_and_test_stream_message('push_multiple_committers', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches(self) -> None: def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{commit_info*9}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""" expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{commit_info*9}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
self.send_and_test_stream_message('push_multiple_committers_with_others', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook(
"push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message
)
def test_bitbucket2_on_push_event_filtered_by_branches(self) -> None: def test_bitbucket2_on_push_event_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))'
expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}" expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}"
self.send_and_test_stream_message('push', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("push", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_above_limit_event(self) -> None: def test_bitbucket2_on_push_commits_above_limit_event(self) -> None:
commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n' commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n'
expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{(commit_info * 5)}[and more commit(s)]" expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{(commit_info * 5)}[and more commit(s)]"
self.send_and_test_stream_message('push_commits_above_limit', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("push_commits_above_limit", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_above_limit_filtered_by_branches(self) -> None: def test_bitbucket2_on_push_commits_above_limit_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n' commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n'
expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{(commit_info * 5)}[and more commit(s)]" expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{(commit_info * 5)}[and more commit(s)]"
self.send_and_test_stream_message('push_commits_above_limit', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("push_commits_above_limit", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_force_push_event(self) -> None: def test_bitbucket2_on_force_push_event(self) -> None:
expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12." expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12."
self.send_and_test_stream_message('force_push', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("force_push", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_force_push_event_filtered_by_branches(self) -> None: def test_bitbucket2_on_force_push_event_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12." expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12."
self.send_and_test_stream_message('force_push', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("force_push", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_remove_branch_event(self) -> None: def test_bitbucket2_on_remove_branch_event(self) -> None:
expected_message = "kolaszek deleted branch master." expected_message = "kolaszek deleted branch master."
self.send_and_test_stream_message('remove_branch', TOPIC_BRANCH_EVENTS, expected_message) self.check_webhook("remove_branch", TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_fork_event(self) -> None: def test_bitbucket2_on_fork_event(self) -> None:
expected_message = "User Tomasz(login: kolaszek) forked the repository into [kolaszek/repository-name2](https://bitbucket.org/kolaszek/repository-name2)." expected_message = "User Tomasz(login: kolaszek) forked the repository into [kolaszek/repository-name2](https://bitbucket.org/kolaszek/repository-name2)."
self.send_and_test_stream_message('fork', TOPIC, expected_message) self.check_webhook("fork", TOPIC, expected_message)
def test_bitbucket2_on_commit_comment_created_event(self) -> None: def test_bitbucket2_on_commit_comment_created_event(self) -> None:
expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74#comment-3354963) on [32c4ea1](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74):\n~~~ quote\nNice fix!\n~~~" expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74#comment-3354963) on [32c4ea1](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74):\n~~~ quote\nNice fix!\n~~~"
self.send_and_test_stream_message('commit_comment_created', TOPIC, expected_message) self.check_webhook("commit_comment_created", TOPIC, expected_message)
def test_bitbucket2_on_commit_status_changed_event(self) -> None: def test_bitbucket2_on_commit_status_changed_event(self) -> None:
expected_message = "[System mybuildtool](https://my-build-tool.com/builds/MY-PROJECT/BUILD-777) changed status of [9fec847](https://bitbucket.org/kolaszek/repository-name/commits/9fec847784abb10b2fa567ee63b85bd238955d0e) to SUCCESSFUL." expected_message = "[System mybuildtool](https://my-build-tool.com/builds/MY-PROJECT/BUILD-777) changed status of [9fec847](https://bitbucket.org/kolaszek/repository-name/commits/9fec847784abb10b2fa567ee63b85bd238955d0e) to SUCCESSFUL."
self.send_and_test_stream_message('commit_status_changed', TOPIC, expected_message) self.check_webhook("commit_status_changed", TOPIC, expected_message)
def test_bitbucket2_on_issue_created_event(self) -> None: def test_bitbucket2_on_issue_created_event(self) -> None:
expected_message = "kolaszek created [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~" expected_message = "kolaszek created [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~"
self.send_and_test_stream_message('issue_created', TOPIC_ISSUE_EVENTS, expected_message) self.check_webhook("issue_created", TOPIC_ISSUE_EVENTS, expected_message)
def test_bitbucket2_on_issue_created_with_custom_topic_in_url(self) -> None: def test_bitbucket2_on_issue_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications") self.url = self.build_webhook_url(topic="notifications")
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "kolaszek created [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~" expected_message = "kolaszek created [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~"
self.send_and_test_stream_message('issue_created', expected_topic, expected_message) self.check_webhook("issue_created", expected_topic, expected_message)
def test_bitbucket2_on_issue_updated_event(self) -> None: def test_bitbucket2_on_issue_updated_event(self) -> None:
expected_message = "kolaszek updated [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." expected_message = "kolaszek updated [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
self.send_and_test_stream_message('issue_updated', TOPIC_ISSUE_EVENTS, expected_message) self.check_webhook("issue_updated", TOPIC_ISSUE_EVENTS, expected_message)
def test_bitbucket2_on_issue_commented_event(self) -> None: def test_bitbucket2_on_issue_commented_event(self) -> None:
expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
self.send_and_test_stream_message('issue_commented', TOPIC_ISSUE_EVENTS, expected_message) self.check_webhook("issue_commented", TOPIC_ISSUE_EVENTS, expected_message)
def test_bitbucket2_on_issue_commented_with_custom_topic_in_url(self) -> None: def test_bitbucket2_on_issue_commented_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications") self.url = self.build_webhook_url(topic="notifications")
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)." expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
self.send_and_test_stream_message('issue_commented', expected_topic, expected_message) self.check_webhook("issue_commented", expected_topic, expected_message)
def test_bitbucket2_on_pull_request_created_event(self) -> None: def test_bitbucket2_on_pull_request_created_event(self) -> None:
expected_message = "kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" expected_message = "kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~"
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:created', "HTTP_X_EVENT_KEY": 'pullrequest:created',
} }
self.send_and_test_stream_message('pull_request_created_or_updated', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_created_or_updated", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_created_without_reviewer_username_event(self) -> None: def test_bitbucket2_on_pull_request_created_without_reviewer_username_event(self) -> None:
expected_message = "kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" expected_message = "kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~"
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:created', "HTTP_X_EVENT_KEY": 'pullrequest:created',
} }
self.send_and_test_stream_message('pull_request_created_or_updated_without_username', self.check_webhook(
TOPIC_PR_EVENTS, expected_message, **kwargs) "pull_request_created_or_updated_without_username",
TOPIC_PR_EVENTS,
expected_message,
**kwargs
)
def test_bitbucket2_on_pull_request_created_with_custom_topic_in_url(self) -> None: def test_bitbucket2_on_pull_request_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications") self.url = self.build_webhook_url(topic="notifications")
@ -128,21 +138,27 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:created', "HTTP_X_EVENT_KEY": 'pullrequest:created',
} }
self.send_and_test_stream_message('pull_request_created_or_updated', expected_topic, expected_message, **kwargs) self.check_webhook(
"pull_request_created_or_updated", expected_topic, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_updated_event(self) -> None: def test_bitbucket2_on_pull_request_updated_event(self) -> None:
expected_message = "kolaszek updated [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~" expected_message = "kolaszek updated [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to tkolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~"
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:updated', "HTTP_X_EVENT_KEY": 'pullrequest:updated',
} }
self.send_and_test_stream_message('pull_request_created_or_updated', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_created_or_updated", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_approved_event(self) -> None: def test_bitbucket2_on_pull_request_approved_event(self) -> None:
expected_message = "kolaszek approved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." expected_message = "kolaszek approved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:approved', "HTTP_X_EVENT_KEY": 'pullrequest:approved',
} }
self.send_and_test_stream_message('pull_request_approved_or_unapproved', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_approved_or_unapproved", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_approved_with_custom_topic_in_url(self) -> None: def test_bitbucket2_on_pull_request_approved_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications") self.url = self.build_webhook_url(topic="notifications")
@ -151,35 +167,45 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:approved', "HTTP_X_EVENT_KEY": 'pullrequest:approved',
} }
self.send_and_test_stream_message('pull_request_approved_or_unapproved', expected_topic, expected_message, **kwargs) self.check_webhook(
"pull_request_approved_or_unapproved", expected_topic, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_unapproved_event(self) -> None: def test_bitbucket2_on_pull_request_unapproved_event(self) -> None:
expected_message = "kolaszek unapproved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." expected_message = "kolaszek unapproved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:unapproved', "HTTP_X_EVENT_KEY": 'pullrequest:unapproved',
} }
self.send_and_test_stream_message('pull_request_approved_or_unapproved', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_approved_or_unapproved", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_declined_event(self) -> None: def test_bitbucket2_on_pull_request_declined_event(self) -> None:
expected_message = "kolaszek rejected [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." expected_message = "kolaszek rejected [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:rejected', "HTTP_X_EVENT_KEY": 'pullrequest:rejected',
} }
self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_fulfilled_or_rejected", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_fulfilled_event(self) -> None: def test_bitbucket2_on_pull_request_fulfilled_event(self) -> None:
expected_message = "kolaszek merged [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)." expected_message = "kolaszek merged [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:fulfilled', "HTTP_X_EVENT_KEY": 'pullrequest:fulfilled',
} }
self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_fulfilled_or_rejected", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_comment_created_event(self) -> None: def test_bitbucket2_on_pull_request_comment_created_event(self) -> None:
expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~"
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_created', "HTTP_X_EVENT_KEY": 'pullrequest:comment_created',
} }
self.send_and_test_stream_message('pull_request_comment_action', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_comment_action", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_comment_created_with_custom_topic_in_url(self) -> None: def test_bitbucket2_on_pull_request_comment_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications") self.url = self.build_webhook_url(topic="notifications")
@ -188,14 +214,18 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_created', "HTTP_X_EVENT_KEY": 'pullrequest:comment_created',
} }
self.send_and_test_stream_message('pull_request_comment_action', expected_topic, expected_message, **kwargs) self.check_webhook(
"pull_request_comment_action", expected_topic, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_comment_updated_event(self) -> None: def test_bitbucket2_on_pull_request_comment_updated_event(self) -> None:
expected_message = "kolaszek updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" expected_message = "kolaszek updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~"
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_updated', "HTTP_X_EVENT_KEY": 'pullrequest:comment_updated',
} }
self.send_and_test_stream_message('pull_request_comment_action', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_comment_action", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_comment_updated_with_custom_topic_in_url(self) -> None: def test_bitbucket2_on_pull_request_comment_updated_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications") self.url = self.build_webhook_url(topic="notifications")
@ -204,42 +234,45 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_updated', "HTTP_X_EVENT_KEY": 'pullrequest:comment_updated',
} }
self.send_and_test_stream_message('pull_request_comment_action', expected_topic, expected_message, **kwargs) self.check_webhook(
"pull_request_comment_action", expected_topic, expected_message, **kwargs
)
def test_bitbucket2_on_pull_request_comment_deleted_event(self) -> None: def test_bitbucket2_on_pull_request_comment_deleted_event(self) -> None:
expected_message = "kolaszek deleted a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~" expected_message = "kolaszek deleted a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~"
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_deleted', "HTTP_X_EVENT_KEY": 'pullrequest:comment_deleted',
} }
self.send_and_test_stream_message('pull_request_comment_action', TOPIC_PR_EVENTS, expected_message, **kwargs) self.check_webhook(
"pull_request_comment_action", TOPIC_PR_EVENTS, expected_message, **kwargs
)
def test_bitbucket2_on_repo_updated_event(self) -> None: def test_bitbucket2_on_repo_updated_event(self) -> None:
expected_message = "eeshangarg changed the website of the **new-name** repo to **http://zulipchat.com**.\neeshangarg changed the name of the **new-name** repo from **test-repo** to **new-name**.\neeshangarg changed the language of the **new-name** repo to **python**.\neeshangarg changed the full name of the **new-name** repo from **webhooktest/test-repo** to **webhooktest/new-name**.\neeshangarg changed the description of the **new-name** repo to **Random description.**" expected_message = "eeshangarg changed the website of the **new-name** repo to **http://zulipchat.com**.\neeshangarg changed the name of the **new-name** repo from **test-repo** to **new-name**.\neeshangarg changed the language of the **new-name** repo to **python**.\neeshangarg changed the full name of the **new-name** repo from **webhooktest/test-repo** to **webhooktest/new-name**.\neeshangarg changed the description of the **new-name** repo to **Random description.**"
expected_topic = "new-name" expected_topic = "new-name"
kwargs = {"HTTP_X_EVENT_KEY": 'repo:updated'} kwargs = {"HTTP_X_EVENT_KEY": 'repo:updated'}
self.send_and_test_stream_message('repo_updated', expected_topic, self.check_webhook("repo_updated", expected_topic, expected_message, **kwargs)
expected_message, **kwargs)
def test_bitbucket2_on_push_one_tag_event(self) -> None: def test_bitbucket2_on_push_one_tag_event(self) -> None:
expected_message = "kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." expected_message = "kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push', "HTTP_X_EVENT_KEY": 'pullrequest:push',
} }
self.send_and_test_stream_message('push_one_tag', TOPIC, expected_message, **kwargs) self.check_webhook("push_one_tag", TOPIC, expected_message, **kwargs)
def test_bitbucket2_on_push_remove_tag_event(self) -> None: def test_bitbucket2_on_push_remove_tag_event(self) -> None:
expected_message = "kolaszek removed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." expected_message = "kolaszek removed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push', "HTTP_X_EVENT_KEY": 'pullrequest:push',
} }
self.send_and_test_stream_message('push_remove_tag', TOPIC, expected_message, **kwargs) self.check_webhook("push_remove_tag", TOPIC, expected_message, **kwargs)
def test_bitbucket2_on_push_more_than_one_tag_event(self) -> None: def test_bitbucket2_on_push_more_than_one_tag_event(self) -> None:
expected_message = "kolaszek pushed tag [{name}](https://bitbucket.org/kolaszek/repository-name/commits/tag/{name})." expected_message = "kolaszek pushed tag [{name}](https://bitbucket.org/kolaszek/repository-name/commits/tag/{name})."
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push', "HTTP_X_EVENT_KEY": 'pullrequest:push',
} }
self.send_and_test_stream_message('push_more_than_one_tag', **kwargs) self.check_webhook("push_more_than_one_tag", **kwargs)
msg = self.get_last_message() msg = self.get_last_message()
self.do_test_topic(msg, TOPIC) self.do_test_topic(msg, TOPIC)
self.do_test_message(msg, expected_message.format(name='b')) self.do_test_message(msg, expected_message.format(name='b'))
@ -251,7 +284,7 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push', "HTTP_X_EVENT_KEY": 'pullrequest:push',
} }
self.send_and_test_stream_message('more_than_one_push_event', **kwargs) self.check_webhook("more_than_one_push_event", **kwargs)
msg = self.get_second_to_last_message() msg = self.get_second_to_last_message()
self.do_test_message(msg, 'kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))') self.do_test_message(msg, 'kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))')
self.do_test_topic(msg, TOPIC_BRANCH_EVENTS) self.do_test_topic(msg, TOPIC_BRANCH_EVENTS)
@ -264,7 +297,7 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = { kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push', "HTTP_X_EVENT_KEY": 'pullrequest:push',
} }
self.send_and_test_stream_message('more_than_one_push_event', **kwargs) self.check_webhook("more_than_one_push_event", **kwargs)
msg = self.get_second_to_last_message() msg = self.get_second_to_last_message()
self.do_test_message(msg, 'kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))') self.do_test_message(msg, 'kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))')
self.do_test_topic(msg, TOPIC_BRANCH_EVENTS) self.do_test_topic(msg, TOPIC_BRANCH_EVENTS)
@ -278,9 +311,7 @@ class Bitbucket2HookTests(WebhookTestCase):
"HTTP_X_EVENT_KEY": 'pullrequest:push', "HTTP_X_EVENT_KEY": 'pullrequest:push',
} }
expected_message = "kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)." expected_message = "kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
self.send_and_test_stream_message('more_than_one_push_event', self.check_webhook("more_than_one_push_event", TOPIC, expected_message, **kwargs)
TOPIC,
expected_message, **kwargs)
@patch('zerver.webhooks.bitbucket2.view.check_send_webhook_message') @patch('zerver.webhooks.bitbucket2.view.check_send_webhook_message')
def test_bitbucket2_on_push_event_filtered_by_branches_ignore( def test_bitbucket2_on_push_event_filtered_by_branches_ignore(

View File

@ -11,83 +11,63 @@ class Bitbucket3HookTests(WebhookTestCase):
# Diagnostics Events: # Diagnostics Events:
def test_ping(self) -> None: def test_ping(self) -> None:
expected_message = "Congratulations! The Bitbucket Server webhook was configured successfully!" expected_message = "Congratulations! The Bitbucket Server webhook was configured successfully!"
self.send_and_test_stream_message("diagnostics_ping", self.check_webhook("diagnostics_ping", "Bitbucket Server Ping", expected_message)
"Bitbucket Server Ping",
expected_message)
def test_ping_with_user_defined_topic(self) -> None: def test_ping_with_user_defined_topic(self) -> None:
self.url = self.build_webhook_url(topic="my topic") self.url = self.build_webhook_url(topic="my topic")
expected_message = "Congratulations! The Bitbucket Server webhook was configured successfully!" expected_message = "Congratulations! The Bitbucket Server webhook was configured successfully!"
self.send_and_test_stream_message("diagnostics_ping", self.check_webhook("diagnostics_ping", "my topic", expected_message)
"my topic",
expected_message)
# Core Repo Events: # Core Repo Events:
def test_commit_comment_added(self) -> None: def test_commit_comment_added(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) commented on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\nJust an arbitrary comment on a commit.\n~~~""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) commented on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\nJust an arbitrary comment on a commit.\n~~~"""
self.send_and_test_stream_message("commit_comment_added", self.check_webhook("commit_comment_added", TOPIC, expected_message)
TOPIC,
expected_message)
def test_commit_comment_edited(self) -> None: def test_commit_comment_edited(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) edited their comment on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\nJust an arbitrary comment on a commit. Nothing to see here...\n~~~""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) edited their comment on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\nJust an arbitrary comment on a commit. Nothing to see here...\n~~~"""
self.send_and_test_stream_message("commit_comment_edited", self.check_webhook("commit_comment_edited", TOPIC, expected_message)
TOPIC,
expected_message)
def test_commit_comment_deleted(self) -> None: def test_commit_comment_deleted(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted their comment on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\n~~Just an arbitrary comment on a commit. Nothing to see here...~~\n~~~""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted their comment on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\n~~Just an arbitrary comment on a commit. Nothing to see here...~~\n~~~"""
self.send_and_test_stream_message("commit_comment_deleted", self.check_webhook("commit_comment_deleted", TOPIC, expected_message)
TOPIC,
expected_message)
def test_bitbucket3_repo_forked(self) -> None: def test_bitbucket3_repo_forked(self) -> None:
expected_message = """User Hemanth V. Alluri(login: [hypro999](http://139.59.64.214:7990/users/hypro999)) forked the repository into [sandbox fork](http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse).""" expected_message = """User Hemanth V. Alluri(login: [hypro999](http://139.59.64.214:7990/users/hypro999)) forked the repository into [sandbox fork](http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse)."""
self.send_and_test_stream_message("repo_forked", TOPIC, expected_message) self.check_webhook("repo_forked", TOPIC, expected_message)
def test_bitbucket3_repo_modified(self) -> None: def test_bitbucket3_repo_modified(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) changed the name of the **sandbox** repo from **sandbox** to **sandbox v2**.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) changed the name of the **sandbox** repo from **sandbox** to **sandbox v2**."""
expected_topic = "sandbox v2" expected_topic = "sandbox v2"
self.send_and_test_stream_message("repo_modified", expected_topic, expected_message) self.check_webhook("repo_modified", expected_topic, expected_message)
# Repo Push Events: # Repo Push Events:
def test_push_add_branch(self) -> None: def test_push_add_branch(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) created branch2 branch.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) created branch2 branch."""
expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch2") expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch2")
self.send_and_test_stream_message("repo_push_add_branch", self.check_webhook("repo_push_add_branch", expected_topic, expected_message)
expected_topic,
expected_message)
def test_push_add_tag(self) -> None: def test_push_add_tag(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed tag newtag.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed tag newtag."""
self.send_and_test_stream_message("repo_push_add_tag", self.check_webhook("repo_push_add_tag", TOPIC, expected_message)
TOPIC,
expected_message)
def test_push_delete_branch(self) -> None: def test_push_delete_branch(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted branch branch2.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted branch branch2."""
expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch2") expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch2")
self.send_and_test_stream_message("repo_push_delete_branch", self.check_webhook("repo_push_delete_branch", expected_topic, expected_message)
expected_topic,
expected_message)
def test_push_delete_tag(self) -> None: def test_push_delete_tag(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed tag test-tag.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed tag test-tag."""
self.send_and_test_stream_message("repo_push_delete_tag", self.check_webhook("repo_push_delete_tag", TOPIC, expected_message)
TOPIC,
expected_message)
def test_push_update_single_branch(self) -> None: def test_push_update_single_branch(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now e68c981ef53dbab0a5ca320a2d8d80e216c70528.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now e68c981ef53dbab0a5ca320a2d8d80e216c70528."""
expected_topic = TOPIC_BRANCH_EVENTS.format(branch="master") expected_topic = TOPIC_BRANCH_EVENTS.format(branch="master")
self.send_and_test_stream_message("repo_push_update_single_branch", self.check_webhook("repo_push_update_single_branch", expected_topic, expected_message)
expected_topic,
expected_message)
def test_push_update_multiple_branches(self) -> None: def test_push_update_multiple_branches(self) -> None:
expected_message_first = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d.""" expected_message_first = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d."""
expected_message_second = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2.""" expected_message_second = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2."""
self.send_and_test_stream_message("repo_push_update_multiple_branches") self.check_webhook("repo_push_update_multiple_branches")
msg = self.get_last_message() msg = self.get_last_message()
self.do_test_topic(msg, TOPIC_BRANCH_EVENTS.format(branch="master")) self.do_test_topic(msg, TOPIC_BRANCH_EVENTS.format(branch="master"))
@ -101,185 +81,145 @@ class Bitbucket3HookTests(WebhookTestCase):
self.url = self.build_webhook_url(branches='master') self.url = self.build_webhook_url(branches='master')
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2."""
expected_topic = TOPIC_BRANCH_EVENTS.format(branch="master") expected_topic = TOPIC_BRANCH_EVENTS.format(branch="master")
self.send_and_test_stream_message("repo_push_update_multiple_branches", self.check_webhook("repo_push_update_multiple_branches", expected_topic, expected_message)
expected_topic,
expected_message)
self.url = self.build_webhook_url(branches='branch1') self.url = self.build_webhook_url(branches='branch1')
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d."""
expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch1") expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch1")
self.send_and_test_stream_message("repo_push_update_multiple_branches", self.check_webhook("repo_push_update_multiple_branches", expected_topic, expected_message)
expected_topic,
expected_message)
# Core PR Events: # Core PR Events:
def test_pr_opened_without_reviewers(self) -> None: def test_pr_opened_without_reviewers(self) -> None:
expected_topic = "sandbox / PR #1 Branch1" expected_topic = "sandbox / PR #1 Branch1"
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) from `branch1` to `master`:\n\n~~~ quote\n* Add file2.txt\r\n* Add file3.txt\n~~~""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) from `branch1` to `master`:\n\n~~~ quote\n* Add file2.txt\r\n* Add file3.txt\n~~~"""
self.send_and_test_stream_message("pull_request_opened_without_reviewers", self.check_webhook(
expected_topic, "pull_request_opened_without_reviewers", expected_topic, expected_message
expected_message) )
def test_pr_opened_without_description(self) -> None: def test_pr_opened_without_description(self) -> None:
expected_topic = "sandbox / PR #2 Add notes feature." expected_topic = "sandbox / PR #2 Add notes feature."
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #2](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2) from `master` to `master`.""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #2](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2) from `master` to `master`."""
self.send_and_test_stream_message("pull_request_opened_without_description", self.check_webhook(
expected_topic, "pull_request_opened_without_description", expected_topic, expected_message
expected_message) )
def test_pr_opened_with_two_reviewers(self) -> None: def test_pr_opened_with_two_reviewers(self) -> None:
expected_topic = "sandbox / PR #5 Add Notes Feature" expected_topic = "sandbox / PR #5 Add Notes Feature"
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #5](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/5) from `master` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo) for review).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #5](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/5) from `master` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo) for review)."""
self.send_and_test_stream_message("pull_request_opened_with_two_reviewers", self.check_webhook(
expected_topic, "pull_request_opened_with_two_reviewers", expected_topic, expected_message
expected_message) )
def test_pr_opened_with_two_reviewers_and_user_defined_topic(self) -> None: def test_pr_opened_with_two_reviewers_and_user_defined_topic(self) -> None:
expected_topic = "sandbox / PR #5 Add Notes Feature" expected_topic = "sandbox / PR #5 Add Notes Feature"
expected_topic = "custom_topic" expected_topic = "custom_topic"
self.url = self.build_webhook_url(topic='custom_topic') self.url = self.build_webhook_url(topic='custom_topic')
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #5 Add Notes Feature](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/5) from `master` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo) for review).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #5 Add Notes Feature](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/5) from `master` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo) for review)."""
self.send_and_test_stream_message("pull_request_opened_with_two_reviewers", self.check_webhook(
expected_topic, "pull_request_opened_with_two_reviewers", expected_topic, expected_message
expected_message) )
def test_pr_opened_with_mulitple_reviewers(self) -> None: def test_pr_opened_with_mulitple_reviewers(self) -> None:
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) from `master` to `master` (assigned to [sougo](http://139.59.64.214:7990/users/sougo), [zura](http://139.59.64.214:7990/users/zura) and [shimura](http://139.59.64.214:7990/users/shimura) for review):\n\n~~~ quote\nAdd a simple text file for further testing purposes.\n~~~""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) opened [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) from `master` to `master` (assigned to [sougo](http://139.59.64.214:7990/users/sougo), [zura](http://139.59.64.214:7990/users/zura) and [shimura](http://139.59.64.214:7990/users/shimura) for review):\n\n~~~ quote\nAdd a simple text file for further testing purposes.\n~~~"""
self.send_and_test_stream_message("pull_request_opened_with_multiple_reviewers", self.check_webhook(
expected_topic, "pull_request_opened_with_multiple_reviewers", expected_topic, expected_message
expected_message) )
def test_pr_modified(self) -> None: def test_pr_modified(self) -> None:
expected_topic = "sandbox / PR #1 Branch1" expected_topic = "sandbox / PR #1 Branch1"
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) modified [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) from `branch1` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) for review):\n\n~~~ quote\n* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!\n~~~""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) modified [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) from `branch1` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) for review):\n\n~~~ quote\n* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!\n~~~"""
self.send_and_test_stream_message("pull_request_modified", self.check_webhook("pull_request_modified", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_modified_with_include_title(self) -> None: def test_pr_modified_with_include_title(self) -> None:
expected_topic = "custom_topic" expected_topic = "custom_topic"
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) modified [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) from `branch1` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) for review):\n\n~~~ quote\n* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!\n~~~""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) modified [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) from `branch1` to `master` (assigned to [shimura](http://139.59.64.214:7990/users/shimura) for review):\n\n~~~ quote\n* Add file2.txt\n* Add file3.txt\nBoth of these files would be important additions to the project!\n~~~"""
self.url = self.build_webhook_url(topic='custom_topic') self.url = self.build_webhook_url(topic='custom_topic')
self.send_and_test_stream_message("pull_request_modified", self.check_webhook("pull_request_modified", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_deleted(self) -> None: def test_pr_deleted(self) -> None:
expected_topic = "sandbox / PR #2 Add notes feature." expected_topic = "sandbox / PR #2 Add notes feature."
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted [PR #2](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted [PR #2](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2)."""
self.send_and_test_stream_message("pull_request_deleted", self.check_webhook("pull_request_deleted", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_deleted_with_include_title(self) -> None: def test_pr_deleted_with_include_title(self) -> None:
expected_topic = "custom_topic" expected_topic = "custom_topic"
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted [PR #2 Add notes feature.](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2)""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted [PR #2 Add notes feature.](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/2)"""
self.url = self.build_webhook_url(topic='custom_topic') self.url = self.build_webhook_url(topic='custom_topic')
self.send_and_test_stream_message("pull_request_deleted", self.check_webhook("pull_request_deleted", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_declined(self) -> None: def test_pr_declined(self) -> None:
expected_topic = "sandbox / PR #7 Crazy Idea" expected_topic = "sandbox / PR #7 Crazy Idea"
expected_message = """[zura](http://139.59.64.214:7990/users/zura) declined [PR #7](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/7).""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) declined [PR #7](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/7)."""
self.send_and_test_stream_message("pull_request_declined", self.check_webhook("pull_request_declined", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_merged(self) -> None: def test_pr_merged(self) -> None:
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
expected_message = """[zura](http://139.59.64.214:7990/users/zura) merged [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6).""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) merged [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6)."""
self.send_and_test_stream_message("pull_request_merged", self.check_webhook("pull_request_merged", expected_topic, expected_message)
expected_topic,
expected_message)
# PR Reviewer Events: # PR Reviewer Events:
def test_pr_approved(self) -> None: def test_pr_approved(self) -> None:
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
expected_message = """[zura](http://139.59.64.214:7990/users/zura) approved [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6).""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) approved [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6)."""
self.send_and_test_stream_message("pull_request_approved", self.check_webhook("pull_request_approved", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_unapproved(self) -> None: def test_pr_unapproved(self) -> None:
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
expected_message = """[zura](http://139.59.64.214:7990/users/zura) unapproved [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6).""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) unapproved [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6)."""
self.send_and_test_stream_message("pull_request_unapproved", self.check_webhook("pull_request_unapproved", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_marked_as_needs_review(self) -> None: def test_pr_marked_as_needs_review(self) -> None:
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
expected_message = """[zura](http://139.59.64.214:7990/users/zura) marked [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) as \"needs work\".""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) marked [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) as \"needs work\"."""
self.send_and_test_stream_message("pull_request_needs_work", self.check_webhook("pull_request_needs_work", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pr_marked_as_needs_review_and_include_title(self) -> None: def test_pr_marked_as_needs_review_and_include_title(self) -> None:
expected_topic = "custom_topic" expected_topic = "custom_topic"
expected_message = """[zura](http://139.59.64.214:7990/users/zura) marked [PR #6 sample_file: Add sample_file.txt.](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) as \"needs work\".""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) marked [PR #6 sample_file: Add sample_file.txt.](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6) as \"needs work\"."""
self.url = self.build_webhook_url(topic='custom_topic') self.url = self.build_webhook_url(topic='custom_topic')
self.send_and_test_stream_message("pull_request_needs_work", self.check_webhook("pull_request_needs_work", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pull_request_reviewer_added(self) -> None: def test_pull_request_reviewer_added(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura)."""
expected_topic = "sandbox / PR #1 Branch1" expected_topic = "sandbox / PR #1 Branch1"
self.send_and_test_stream_message("pull_request_add_reviewer", self.check_webhook("pull_request_add_reviewer", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pull_request_reviewer_added_and_include_title(self) -> None: def test_pull_request_reviewer_added_and_include_title(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura)."""
expected_topic = "custom_topic" expected_topic = "custom_topic"
self.url = self.build_webhook_url(topic='custom_topic') self.url = self.build_webhook_url(topic='custom_topic')
self.send_and_test_stream_message("pull_request_add_reviewer", self.check_webhook("pull_request_add_reviewer", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pull_request_reviewers_added(self) -> None: def test_pull_request_reviewers_added(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) reassigned [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1) to [shimura](http://139.59.64.214:7990/users/shimura) and [sougo](http://139.59.64.214:7990/users/sougo)."""
expected_topic = "sandbox / PR #1 Branch1" expected_topic = "sandbox / PR #1 Branch1"
self.send_and_test_stream_message("pull_request_add_two_reviewers", self.check_webhook("pull_request_add_two_reviewers", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pull_request_remove_all_reviewers(self) -> None: def test_pull_request_remove_all_reviewers(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed all reviewers from [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed all reviewers from [PR #1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1)."""
expected_topic = "sandbox / PR #1 Branch1" expected_topic = "sandbox / PR #1 Branch1"
self.send_and_test_stream_message("pull_request_remove_reviewer", self.check_webhook("pull_request_remove_reviewer", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pull_request_remove_all_reviewers_with_title(self) -> None: def test_pull_request_remove_all_reviewers_with_title(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed all reviewers from [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1).""" expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed all reviewers from [PR #1 Branch1](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/1)."""
expected_topic = "sandbox / PR #1 Branch1" expected_topic = "sandbox / PR #1 Branch1"
expected_topic = "custom_topic" expected_topic = "custom_topic"
self.url = self.build_webhook_url(topic='custom_topic') self.url = self.build_webhook_url(topic='custom_topic')
self.send_and_test_stream_message("pull_request_remove_reviewer", self.check_webhook("pull_request_remove_reviewer", expected_topic, expected_message)
expected_topic,
expected_message)
# PR Comment Events: # PR Comment Events:
def test_pull_request_comment_added(self) -> None: def test_pull_request_comment_added(self) -> None:
expected_message = """[zura](http://139.59.64.214:7990/users/zura) commented on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n~~~ quote\nThis seems like a pretty good idea.\n~~~""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) commented on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n~~~ quote\nThis seems like a pretty good idea.\n~~~"""
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
self.send_and_test_stream_message("pull_request_comment_added", self.check_webhook("pull_request_comment_added", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pull_request_comment_edited(self) -> None: def test_pull_request_comment_edited(self) -> None:
expected_message = """[zura](http://139.59.64.214:7990/users/zura) edited their comment on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n~~~ quote\nThis seems like a pretty good idea. @shimura what do you think?\n~~~""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) edited their comment on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n~~~ quote\nThis seems like a pretty good idea. @shimura what do you think?\n~~~"""
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
self.send_and_test_stream_message("pull_request_comment_edited", self.check_webhook("pull_request_comment_edited", expected_topic, expected_message)
expected_topic,
expected_message)
def test_pull_request_comment_deleted(self) -> None: def test_pull_request_comment_deleted(self) -> None:
expected_message = """[zura](http://139.59.64.214:7990/users/zura) deleted their comment on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n~~~ quote\n~~This seems like a pretty good idea. @shimura what do you think?~~\n~~~""" expected_message = """[zura](http://139.59.64.214:7990/users/zura) deleted their comment on [PR #6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/pull-requests/6):\n\n~~~ quote\n~~This seems like a pretty good idea. @shimura what do you think?~~\n~~~"""
expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt." expected_topic = "sandbox / PR #6 sample_file: Add sample_file.txt."
self.send_and_test_stream_message("pull_request_comment_deleted", self.check_webhook("pull_request_comment_deleted", expected_topic, expected_message)
expected_topic,
expected_message)

View File

@ -9,19 +9,19 @@ class BuildbotHookTests(WebhookTestCase):
def test_build_started(self) -> None: def test_build_started(self) -> None:
expected_topic = "buildbot-hello" expected_topic = "buildbot-hello"
expected_message = "Build [#33](http://exampleurl.com/#builders/1/builds/33) for **runtests** started." expected_message = "Build [#33](http://exampleurl.com/#builders/1/builds/33) for **runtests** started."
self.send_and_test_stream_message("started", expected_topic, expected_message) self.check_webhook("started", expected_topic, expected_message)
def test_build_success(self) -> None: def test_build_success(self) -> None:
expected_topic = "buildbot-hello" expected_topic = "buildbot-hello"
expected_message = "Build [#33](http://exampleurl.com/#builders/1/builds/33) (result: success) for **runtests** finished." expected_message = "Build [#33](http://exampleurl.com/#builders/1/builds/33) (result: success) for **runtests** finished."
self.send_and_test_stream_message("finished_success", expected_topic, expected_message) self.check_webhook("finished_success", expected_topic, expected_message)
def test_build_failure(self) -> None: def test_build_failure(self) -> None:
expected_topic = "general" # project key is empty expected_topic = "general" # project key is empty
expected_message = "Build [#34](http://exampleurl.com/#builders/1/builds/34) (result: failure) for **runtests** finished." expected_message = "Build [#34](http://exampleurl.com/#builders/1/builds/34) (result: failure) for **runtests** finished."
self.send_and_test_stream_message("finished_failure", expected_topic, expected_message) self.check_webhook("finished_failure", expected_topic, expected_message)
def test_build_cancelled(self) -> None: def test_build_cancelled(self) -> None:
expected_topic = "zulip/zulip-zapier" expected_topic = "zulip/zulip-zapier"
expected_message = "Build [#10434](https://ci.example.org/#builders/79/builds/307) (result: cancelled) for **AMD64 Ubuntu 18.04 Python 3** finished." expected_message = "Build [#10434](https://ci.example.org/#builders/79/builds/307) (result: cancelled) for **AMD64 Ubuntu 18.04 Python 3** finished."
self.send_and_test_stream_message("finished_cancelled", expected_topic, expected_message) self.check_webhook("finished_cancelled", expected_topic, expected_message)

View File

@ -13,11 +13,11 @@ class CanarytokenHookTests(WebhookTestCase):
"[Manage this canarytoken](http://example.com/test/url/for/webhook)" "[Manage this canarytoken](http://example.com/test/url/for/webhook)"
) )
self.send_and_test_stream_message( self.check_webhook(
'canarytoken_new', "canarytoken_new",
'canarytoken alert', "canarytoken alert",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded" content_type="application/x-www-form-urlencoded",
) )
def test_canarytoken_real(self) -> None: def test_canarytoken_real(self) -> None:
@ -29,11 +29,11 @@ class CanarytokenHookTests(WebhookTestCase):
"(https://canarytokens.org/manage?token=foo&auth=bar)" "(https://canarytokens.org/manage?token=foo&auth=bar)"
) )
self.send_and_test_stream_message( self.check_webhook(
'canarytoken_real', "canarytoken_real",
'canarytoken alert', "canarytoken alert",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded" content_type="application/x-www-form-urlencoded",
) )
def test_canarytoken_with_specific_topic(self) -> None: def test_canarytoken_with_specific_topic(self) -> None:
@ -46,9 +46,9 @@ class CanarytokenHookTests(WebhookTestCase):
"(https://canarytokens.org/manage?token=foo&auth=bar)" "(https://canarytokens.org/manage?token=foo&auth=bar)"
) )
self.send_and_test_stream_message( self.check_webhook(
'canarytoken_real', "canarytoken_real",
'foo', "foo",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded" content_type="application/x-www-form-urlencoded",
) )

View File

@ -14,7 +14,9 @@ Build [#5](https://circleci.com/bb/Hypro999/circleci-test/5) of `build`/`workflo
- **Pull Request:** https://bitbucket.org/Hypro999/circleci-test/pull-requests/1 - **Pull Request:** https://bitbucket.org/Hypro999/circleci-test/pull-requests/1
- **Author:** Hemanth V. Alluri - **Author:** Hemanth V. Alluri
""".strip() """.strip()
self.send_and_test_stream_message("bitbucket_private_repo_pull_request_failure", expected_topic, expected_message) self.check_webhook(
"bitbucket_private_repo_pull_request_failure", expected_topic, expected_message
)
def test_for_failed_build_off_github(self) -> None: def test_for_failed_build_off_github(self) -> None:
expected_topic = "zulip" expected_topic = "zulip"
@ -25,7 +27,9 @@ Build [#1429](https://circleci.com/gh/Hypro999/zulip/1429) of `bionic-backend-fr
- **Author:** Hemanth V. Alluri (Hypro999) - **Author:** Hemanth V. Alluri (Hypro999)
- **Committer:** Hemanth V. Alluri (Hypro999) - **Committer:** Hemanth V. Alluri (Hypro999)
""".strip() """.strip()
self.send_and_test_stream_message("github_bionic_backend_frontend_failure", expected_topic, expected_message) self.check_webhook(
"github_bionic_backend_frontend_failure", expected_topic, expected_message
)
def test_for_success_build_off_github_with_multiple_parties(self) -> None: def test_for_success_build_off_github_with_multiple_parties(self) -> None:
expected_topic = "zulip" expected_topic = "zulip"
@ -36,7 +40,11 @@ Build [#1431](https://circleci.com/gh/Hypro999/zulip/1431) of `bionic-production
- **Authors:** Gintoki Sakata (ShiroYasha999), Hemanth V. Alluri (Hypro999) - **Authors:** Gintoki Sakata (ShiroYasha999), Hemanth V. Alluri (Hypro999)
- **Committers:** Hemanth V. Alluri (Hypro999), Sadaharu - **Committers:** Hemanth V. Alluri (Hypro999), Sadaharu
""".strip() """.strip()
self.send_and_test_stream_message("github_bionic_production_build_success_multiple_parties", expected_topic, expected_message) self.check_webhook(
"github_bionic_production_build_success_multiple_parties",
expected_topic,
expected_message,
)
def test_for_cancelled_build_off_github(self) -> None: def test_for_cancelled_build_off_github(self) -> None:
expected_topic = "zulip" expected_topic = "zulip"
@ -47,9 +55,11 @@ Build [#1420](https://circleci.com/gh/Hypro999/zulip/1420) of `bionic-production
- **Author:** Hemanth V. Alluri (Hypro999) - **Author:** Hemanth V. Alluri (Hypro999)
- **Committer:** Hemanth V. Alluri (Hypro999) - **Committer:** Hemanth V. Alluri (Hypro999)
""".strip() """.strip()
self.send_and_test_stream_message("github_bionic_production_install_cancelled", expected_topic, expected_message) self.check_webhook(
"github_bionic_production_install_cancelled", expected_topic, expected_message
)
def test_super_minimal_payload(self) -> None: def test_super_minimal_payload(self) -> None:
expected_topic = "zulip" expected_topic = "zulip"
expected_message = "[Build](https://circleci.com/gh/zulip/zulip/48056) triggered by timabbott on branch `master` has failed." expected_message = "[Build](https://circleci.com/gh/zulip/zulip/48056) triggered by timabbott on branch `master` has failed."
self.send_and_test_stream_message("super_minimal_payload", expected_topic, expected_message) self.check_webhook("super_minimal_payload", expected_topic, expected_message)

View File

@ -11,125 +11,105 @@ class ClubhouseWebhookTest(WebhookTestCase):
def test_story_create(self) -> None: def test_story_create(self) -> None:
expected_message = "New story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) of type **feature** was created." expected_message = "New story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) of type **feature** was created."
self.send_and_test_stream_message( self.check_webhook(
'story_create', "Add cool feature!", "story_create", "Add cool feature!", expected_message,
expected_message,
) )
def test_story_delete(self) -> None: def test_story_delete(self) -> None:
expected_message = "The story **New random story** was deleted." expected_message = "The story **New random story** was deleted."
self.send_and_test_stream_message("story_delete", "New random story", self.check_webhook("story_delete", "New random story", expected_message)
expected_message)
def test_epic_story_create(self) -> None: def test_epic_story_create(self) -> None:
expected_message = "New story [An epic story!](https://app.clubhouse.io/zulip/story/23) was created and added to the epic **New Cool Epic!**." expected_message = "New story [An epic story!](https://app.clubhouse.io/zulip/story/23) was created and added to the epic **New Cool Epic!**."
self.send_and_test_stream_message( self.check_webhook(
'epic_create_story', "An epic story!", "epic_create_story", "An epic story!", expected_message,
expected_message,
) )
def test_epic_delete(self) -> None: def test_epic_delete(self) -> None:
expected_message = "The epic **Clubhouse Fork** was deleted." expected_message = "The epic **Clubhouse Fork** was deleted."
self.send_and_test_stream_message("epic_delete", "Clubhouse Fork", self.check_webhook("epic_delete", "Clubhouse Fork", expected_message)
expected_message)
def test_story_archive(self) -> None: def test_story_archive(self) -> None:
expected_message = "The story [Story 2](https://app.clubhouse.io/zulip/story/9) was archived." expected_message = "The story [Story 2](https://app.clubhouse.io/zulip/story/9) was archived."
self.send_and_test_stream_message('story_archive', "Story 2", expected_message) self.check_webhook("story_archive", "Story 2", expected_message)
def test_epic_archive(self) -> None: def test_epic_archive(self) -> None:
expected_message = "The epic **Zulip is epic!** was archived." expected_message = "The epic **Zulip is epic!** was archived."
self.send_and_test_stream_message('epic_archive', 'Zulip is epic!', self.check_webhook("epic_archive", "Zulip is epic!", expected_message)
expected_message)
def test_story_unarchive(self) -> None: def test_story_unarchive(self) -> None:
expected_message = "The story [Story 2](https://app.clubhouse.io/zulip/story/9) was unarchived." expected_message = "The story [Story 2](https://app.clubhouse.io/zulip/story/9) was unarchived."
self.send_and_test_stream_message('story_unarchive', "Story 2", expected_message) self.check_webhook("story_unarchive", "Story 2", expected_message)
def test_epic_create(self) -> None: def test_epic_create(self) -> None:
expected_message = "New epic **New Epic!**(to do) was created." expected_message = "New epic **New Epic!**(to do) was created."
self.send_and_test_stream_message('epic_create', "New Epic!", expected_message) self.check_webhook("epic_create", "New Epic!", expected_message)
def test_epic_update_add_comment(self) -> None: def test_epic_update_add_comment(self) -> None:
expected_message = "New comment added to the epic **New Cool Epic!**:\n``` quote\nAdded a comment on this Epic!\n```" expected_message = "New comment added to the epic **New Cool Epic!**:\n``` quote\nAdded a comment on this Epic!\n```"
self.send_and_test_stream_message('epic_update_add_comment', self.check_webhook("epic_update_add_comment", "New Cool Epic!", expected_message)
"New Cool Epic!", expected_message)
def test_story_update_add_comment(self) -> None: def test_story_update_add_comment(self) -> None:
expected_message = "New comment added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11):\n``` quote\nJust leaving a comment here!\n```" expected_message = "New comment added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11):\n``` quote\nJust leaving a comment here!\n```"
self.send_and_test_stream_message('story_update_add_comment', self.check_webhook("story_update_add_comment", "Add cool feature!", expected_message)
"Add cool feature!",
expected_message)
def test_epic_update_add_description(self) -> None: def test_epic_update_add_description(self) -> None:
expected_message = "New description added to the epic **New Cool Epic!**:\n``` quote\nAdded a description!\n```" expected_message = "New description added to the epic **New Cool Epic!**:\n``` quote\nAdded a description!\n```"
self.send_and_test_stream_message('epic_update_add_description', self.check_webhook("epic_update_add_description", "New Cool Epic!", expected_message)
"New Cool Epic!", expected_message)
def test_epic_update_remove_description(self) -> None: def test_epic_update_remove_description(self) -> None:
expected_message = "Description for the epic **New Cool Epic!** was removed." expected_message = "Description for the epic **New Cool Epic!** was removed."
self.send_and_test_stream_message('epic_update_remove_description', self.check_webhook("epic_update_remove_description", "New Cool Epic!", expected_message)
"New Cool Epic!", expected_message)
def test_epic_update_change_description(self) -> None: def test_epic_update_change_description(self) -> None:
expected_message = "Description for the epic **New Cool Epic!** was changed from:\n``` quote\nAdded a description!\n```\nto\n``` quote\nChanged a description!\n```" expected_message = "Description for the epic **New Cool Epic!** was changed from:\n``` quote\nAdded a description!\n```\nto\n``` quote\nChanged a description!\n```"
self.send_and_test_stream_message('epic_update_change_description', self.check_webhook("epic_update_change_description", "New Cool Epic!", expected_message)
"New Cool Epic!", expected_message)
def test_story_update_add_description(self) -> None: def test_story_update_add_description(self) -> None:
expected_message = "New description added to the story [Story 2](https://app.clubhouse.io/zulip/story/9):\n``` quote\nAdded a description.\n```" expected_message = "New description added to the story [Story 2](https://app.clubhouse.io/zulip/story/9):\n``` quote\nAdded a description.\n```"
self.send_and_test_stream_message('story_update_add_description', self.check_webhook("story_update_add_description", "Story 2", expected_message)
"Story 2", expected_message)
def test_story_update_remove_description(self) -> None: def test_story_update_remove_description(self) -> None:
expected_message = "Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed." expected_message = "Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed."
self.send_and_test_stream_message('story_update_remove_description', self.check_webhook("story_update_remove_description", "Add cool feature!", expected_message)
"Add cool feature!", expected_message)
def test_story_update_change_description(self) -> None: def test_story_update_change_description(self) -> None:
expected_message = "Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nWe should probably add this cool feature!\n```\nto\n``` quote\nWe should probably add this cool feature! Just edited this. :)\n```" expected_message = "Description for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nWe should probably add this cool feature!\n```\nto\n``` quote\nWe should probably add this cool feature! Just edited this. :)\n```"
self.send_and_test_stream_message('story_update_description', self.check_webhook("story_update_description", "Add cool feature!", expected_message)
"Add cool feature!", expected_message)
def test_epic_update_change_state(self) -> None: def test_epic_update_change_state(self) -> None:
expected_message = "State of the epic **New Cool Epic!** was changed from **to do** to **in progress**." expected_message = "State of the epic **New Cool Epic!** was changed from **to do** to **in progress**."
self.send_and_test_stream_message('epic_update_change_state', self.check_webhook("epic_update_change_state", "New Cool Epic!", expected_message)
"New Cool Epic!", expected_message)
def test_story_update_change_state(self) -> None: def test_story_update_change_state(self) -> None:
expected_message = "State of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **Unscheduled** to **Ready for Review**." expected_message = "State of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **Unscheduled** to **Ready for Review**."
self.send_and_test_stream_message('story_update_change_state', self.check_webhook("story_update_change_state", "Add cool feature!", expected_message)
"Add cool feature!", expected_message)
def test_epic_update_change_name(self) -> None: def test_epic_update_change_name(self) -> None:
expected_message = "The name of the epic **New Cool Epic!** was changed from:\n``` quote\nNew Epic!\n```\nto\n``` quote\nNew Cool Epic!\n```" expected_message = "The name of the epic **New Cool Epic!** was changed from:\n``` quote\nNew Epic!\n```\nto\n``` quote\nNew Cool Epic!\n```"
self.send_and_test_stream_message('epic_update_change_title', "New Cool Epic!", self.check_webhook("epic_update_change_title", "New Cool Epic!", expected_message)
expected_message)
def test_story_update_change_name(self) -> None: def test_story_update_change_name(self) -> None:
expected_message = "The name of the story [Add super cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nAdd cool feature!\n```\nto\n``` quote\nAdd super cool feature!\n```" expected_message = "The name of the story [Add super cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from:\n``` quote\nAdd cool feature!\n```\nto\n``` quote\nAdd super cool feature!\n```"
self.send_and_test_stream_message('story_update_change_title', "Add super cool feature!", self.check_webhook("story_update_change_title", "Add super cool feature!", expected_message)
expected_message)
def test_story_update_add_owner(self) -> None: def test_story_update_add_owner(self) -> None:
expected_message = "New owner added to the story [A new story by Shakespeare!](https://app.clubhouse.io/zulip/story/26)." expected_message = "New owner added to the story [A new story by Shakespeare!](https://app.clubhouse.io/zulip/story/26)."
self.send_and_test_stream_message('story_update_add_owner', 'A new story by Shakespeare!', self.check_webhook(
expected_message) "story_update_add_owner", "A new story by Shakespeare!", expected_message
)
def test_story_task_created(self) -> None: def test_story_task_created(self) -> None:
expected_message = "Task **Added a new task** was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." expected_message = "Task **Added a new task** was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)."
self.send_and_test_stream_message('story_task_create', "Add cool feature!", self.check_webhook("story_task_create", "Add cool feature!", expected_message)
expected_message)
def test_story_task_deleted(self) -> None: def test_story_task_deleted(self) -> None:
expected_message = "Task **Added a new task** was removed from the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." expected_message = "Task **Added a new task** was removed from the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)."
self.send_and_test_stream_message('story_task_delete', "Add cool feature!", self.check_webhook("story_task_delete", "Add cool feature!", expected_message)
expected_message)
def test_story_task_completed(self) -> None: def test_story_task_completed(self) -> None:
expected_message = "Task **A new task for this story** ([Add cool feature!](https://app.clubhouse.io/zulip/story/11)) was completed. :tada:" expected_message = "Task **A new task for this story** ([Add cool feature!](https://app.clubhouse.io/zulip/story/11)) was completed. :tada:"
self.send_and_test_stream_message('story_task_complete', "Add cool feature!", self.check_webhook("story_task_complete", "Add cool feature!", expected_message)
expected_message)
@patch('zerver.lib.webhooks.common.check_send_webhook_message') @patch('zerver.lib.webhooks.common.check_send_webhook_message')
def test_story_task_incomplete_ignore( def test_story_task_incomplete_ignore(
@ -142,38 +122,31 @@ class ClubhouseWebhookTest(WebhookTestCase):
def test_story_epic_changed(self) -> None: def test_story_epic_changed(self) -> None:
expected_message = ("The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from **Release 1.9**" expected_message = ("The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from **Release 1.9**"
" to **Clubhouse Fork**.") " to **Clubhouse Fork**.")
self.send_and_test_stream_message('story_update_change_epic', "Add cool feature!", self.check_webhook("story_update_change_epic", "Add cool feature!", expected_message)
expected_message)
def test_story_epic_added(self) -> None: def test_story_epic_added(self) -> None:
expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was added to the epic **Release 1.9**." expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was added to the epic **Release 1.9**."
self.send_and_test_stream_message('story_update_add_epic', "Add cool feature!", self.check_webhook("story_update_add_epic", "Add cool feature!", expected_message)
expected_message)
def test_story_epic_removed(self) -> None: def test_story_epic_removed(self) -> None:
expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed from the epic **Release 1.9**." expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was removed from the epic **Release 1.9**."
self.send_and_test_stream_message('story_update_remove_epic', "Add cool feature!", self.check_webhook("story_update_remove_epic", "Add cool feature!", expected_message)
expected_message)
def test_story_estimate_changed(self) -> None: def test_story_estimate_changed(self) -> None:
expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points." expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points."
self.send_and_test_stream_message('story_update_change_estimate', "Add cool feature!", self.check_webhook("story_update_change_estimate", "Add cool feature!", expected_message)
expected_message)
def test_story_estimate_added(self) -> None: def test_story_estimate_added(self) -> None:
expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points." expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to 4 points."
self.send_and_test_stream_message('story_update_add_estimate', "Add cool feature!", self.check_webhook("story_update_add_estimate", "Add cool feature!", expected_message)
expected_message)
def test_story_estimate_removed(self) -> None: def test_story_estimate_removed(self) -> None:
expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to *Unestimated*." expected_message = "The estimate for the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was set to *Unestimated*."
self.send_and_test_stream_message('story_update_remove_estimate', "Add cool feature!", self.check_webhook("story_update_remove_estimate", "Add cool feature!", expected_message)
expected_message)
def test_story_file_attachment_added(self) -> None: def test_story_file_attachment_added(self) -> None:
expected_message = "A file attachment `zuliprc` was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)." expected_message = "A file attachment `zuliprc` was added to the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11)."
self.send_and_test_stream_message('story_update_add_attachment', "Add cool feature!", self.check_webhook("story_update_add_attachment", "Add cool feature!", expected_message)
expected_message)
@patch('zerver.lib.webhooks.common.check_send_webhook_message') @patch('zerver.lib.webhooks.common.check_send_webhook_message')
def test_story_file_attachment_removed_ignore( def test_story_file_attachment_removed_ignore(
@ -185,14 +158,13 @@ class ClubhouseWebhookTest(WebhookTestCase):
def test_story_label_added(self) -> None: def test_story_label_added(self) -> None:
expected_message = "The label **mockup** was added to the story [An epic story!](https://app.clubhouse.io/zulip/story/23)." expected_message = "The label **mockup** was added to the story [An epic story!](https://app.clubhouse.io/zulip/story/23)."
self.send_and_test_stream_message('story_update_add_label', "An epic story!", self.check_webhook("story_update_add_label", "An epic story!", expected_message)
expected_message)
def test_story_label_added_label_name_in_actions(self) -> None: def test_story_label_added_label_name_in_actions(self) -> None:
expected_message = "The label **sad** was added to the story [An emotional story!](https://app.clubhouse.io/zulip/story/28)." expected_message = "The label **sad** was added to the story [An emotional story!](https://app.clubhouse.io/zulip/story/28)."
self.send_and_test_stream_message('story_update_add_label_name_in_action', self.check_webhook(
'An emotional story!', "story_update_add_label_name_in_action", "An emotional story!", expected_message
expected_message) )
@patch('zerver.lib.webhooks.common.check_send_webhook_message') @patch('zerver.lib.webhooks.common.check_send_webhook_message')
def test_story_label_removed_ignore( def test_story_label_removed_ignore(
@ -204,25 +176,25 @@ class ClubhouseWebhookTest(WebhookTestCase):
def test_story_update_project(self) -> None: def test_story_update_project(self) -> None:
expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from the **Backend** project to **Devops**." expected_message = "The story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was moved from the **Backend** project to **Devops**."
self.send_and_test_stream_message('story_update_change_project', "Add cool feature!", self.check_webhook("story_update_change_project", "Add cool feature!", expected_message)
expected_message)
def test_story_update_type(self) -> None: def test_story_update_type(self) -> None:
expected_message = "The type of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **feature** to **bug**." expected_message = "The type of the story [Add cool feature!](https://app.clubhouse.io/zulip/story/11) was changed from **feature** to **bug**."
self.send_and_test_stream_message('story_update_change_type', "Add cool feature!", self.check_webhook("story_update_change_type", "Add cool feature!", expected_message)
expected_message)
def test_story_update_add_github_pull_request(self) -> None: def test_story_update_add_github_pull_request(self) -> None:
expected_message = "New GitHub PR [#10](https://github.com/eeshangarg/Scheduler/pull/10) opened for story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/28) (Unscheduled -> Ready for Review)." expected_message = "New GitHub PR [#10](https://github.com/eeshangarg/Scheduler/pull/10) opened for story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/28) (Unscheduled -> Ready for Review)."
self.send_and_test_stream_message('story_update_add_github_pull_request', self.check_webhook(
'Testing pull requests with Story', "story_update_add_github_pull_request",
expected_message) "Testing pull requests with Story",
expected_message,
)
def test_story_update_add_github_branch(self) -> None: def test_story_update_add_github_branch(self) -> None:
expected_message = "New GitHub branch [eeshangarg/ch27/testing-pull-requests-with-story](https://github.com/eeshangarg/scheduler/tree/eeshangarg/ch27/testing-pull-requests-with-story) associated with story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/27) (Unscheduled -> In Development)." expected_message = "New GitHub branch [eeshangarg/ch27/testing-pull-requests-with-story](https://github.com/eeshangarg/scheduler/tree/eeshangarg/ch27/testing-pull-requests-with-story) associated with story [Testing pull requests with Story](https://app.clubhouse.io/zulip/story/27) (Unscheduled -> In Development)."
self.send_and_test_stream_message('story_update_add_github_branch', self.check_webhook(
'Testing pull requests with Story', "story_update_add_github_branch", "Testing pull requests with Story", expected_message
expected_message) )
@patch('zerver.lib.webhooks.common.check_send_webhook_message') @patch('zerver.lib.webhooks.common.check_send_webhook_message')
def test_empty_post_request_body_ignore(self, check_send_webhook_message_mock: MagicMock) -> None: def test_empty_post_request_body_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:

View File

@ -12,25 +12,25 @@ class CodeshipHookTests(WebhookTestCase):
Tests if codeship testing status is mapped correctly Tests if codeship testing status is mapped correctly
""" """
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started." expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started."
self.send_and_test_stream_message('testing_build', self.TOPIC, expected_message) self.check_webhook("testing_build", self.TOPIC, expected_message)
def test_codeship_build_in_error_status_message(self) -> None: def test_codeship_build_in_error_status_message(self) -> None:
""" """
Tests if codeship error status is mapped correctly Tests if codeship error status is mapped correctly
""" """
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed." expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed."
self.send_and_test_stream_message('error_build', self.TOPIC, expected_message) self.check_webhook("error_build", self.TOPIC, expected_message)
def test_codeship_build_in_success_status_message(self) -> None: def test_codeship_build_in_success_status_message(self) -> None:
""" """
Tests if codeship success status is mapped correctly Tests if codeship success status is mapped correctly
""" """
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded." expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded."
self.send_and_test_stream_message('success_build', self.TOPIC, expected_message) self.check_webhook("success_build", self.TOPIC, expected_message)
def test_codeship_build_in_other_status_status_message(self) -> None: def test_codeship_build_in_other_status_status_message(self) -> None:
""" """
Tests if codeship other status is mapped correctly Tests if codeship other status is mapped correctly
""" """
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status." expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status."
self.send_and_test_stream_message('other_status_build', self.TOPIC, expected_message) self.check_webhook("other_status_build", self.TOPIC, expected_message)

View File

@ -9,9 +9,9 @@ class CrashlyticsHookTests(WebhookTestCase):
def test_crashlytics_verification_message(self) -> None: def test_crashlytics_verification_message(self) -> None:
expected_topic = "Setup" expected_topic = "Setup"
expected_message = "Webhook has been successfully configured." expected_message = "Webhook has been successfully configured."
self.send_and_test_stream_message('verification', expected_topic, expected_message) self.check_webhook("verification", expected_topic, expected_message)
def test_crashlytics_build_in_success_status(self) -> None: def test_crashlytics_build_in_success_status(self) -> None:
expected_topic = "123: Issue Title" expected_topic = "123: Issue Title"
expected_message = "[Issue](http://crashlytics.com/full/url/to/issue) impacts at least 16 device(s)." expected_message = "[Issue](http://crashlytics.com/full/url/to/issue) impacts at least 16 device(s)."
self.send_and_test_stream_message('issue_message', expected_topic, expected_message) self.check_webhook("issue_message", expected_topic, expected_message)

View File

@ -16,10 +16,12 @@ Your service is fast and flawless!
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('survey_response_updated_promoter', self.check_webhook(
expected_topic, "survey_response_updated_promoter",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_feedback_message_non_promoter(self) -> None: def test_feedback_message_non_promoter(self) -> None:
expected_topic = "Survey Response" expected_topic = "Survey Response"
@ -35,10 +37,12 @@ Your service is slow, but nearly flawless! Keep up the good work!
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('survey_response_updated_non_promoter', self.check_webhook(
expected_topic, "survey_response_updated_non_promoter",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("delighted", fixture_name, file_type="json") return self.webhook_fixture_data("delighted", fixture_name, file_type="json")

View File

@ -11,8 +11,12 @@ class DropboxHookTests(WebhookTestCase):
expected_topic = "Dropbox" expected_topic = "Dropbox"
expected_message = "File has been updated on Dropbox!" expected_message = "File has been updated on Dropbox!"
self.send_and_test_stream_message('file_updated', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "file_updated",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("dropbox", fixture_name, file_type="json") return self.webhook_fixture_data("dropbox", fixture_name, file_type="json")

View File

@ -9,4 +9,4 @@ class ErrBitHookTests(WebhookTestCase):
def test_errbit_error_message(self) -> None: def test_errbit_error_message(self) -> None:
expected_topic = "ZulipIntegrationTest / ErrbitEnvName" expected_topic = "ZulipIntegrationTest / ErrbitEnvName"
expected_message = "[IllegalStateException](https://errbit.example.com/apps/5e1ed1ff1a603f3916f4f0de/problems/5e1fe93e1a603f3916f4f0e3): \"Invalid state error\" occurred." expected_message = "[IllegalStateException](https://errbit.example.com/apps/5e1ed1ff1a603f3916f4f0de/problems/5e1fe93e1a603f3916f4f0e3): \"Invalid state error\" occurred."
self.send_and_test_stream_message('error_message', expected_topic, expected_message) self.check_webhook("error_message", expected_topic, expected_message)

View File

@ -8,82 +8,72 @@ class FlockHookTests(WebhookTestCase):
def test_flock_message(self) -> None: def test_flock_message(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "This is the welcome message!" expected_message = "This is the welcome message!"
self.send_and_test_stream_message('messages', self.check_webhook(
expected_topic, "messages", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_reply(self) -> None: def test_flock_reply(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "It's interesting how high productivity will go..." expected_message = "It's interesting how high productivity will go..."
self.send_and_test_stream_message('reply', self.check_webhook(
expected_topic, "reply", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_note(self) -> None: def test_flock_note(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "Shared a note" expected_message = "Shared a note"
self.send_and_test_stream_message('note', self.check_webhook(
expected_topic, "note", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_reply_note(self) -> None: def test_flock_reply_note(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "This is reply to Note." expected_message = "This is reply to Note."
self.send_and_test_stream_message('reply_note', self.check_webhook(
expected_topic, "reply_note", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_reply_pinned(self) -> None: def test_flock_reply_pinned(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "This is reply to pinned message." expected_message = "This is reply to pinned message."
self.send_and_test_stream_message('reply_pinned', self.check_webhook(
expected_topic, "reply_pinned", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_reply_reminder(self) -> None: def test_flock_reply_reminder(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "This is a reply to Reminder." expected_message = "This is a reply to Reminder."
self.send_and_test_stream_message('reply_reminder', self.check_webhook(
expected_topic, "reply_reminder", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_reply_todo(self) -> None: def test_flock_reply_todo(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "This is a reply to Todo notification." expected_message = "This is a reply to Todo notification."
self.send_and_test_stream_message('reply_todo', self.check_webhook(
expected_topic, "reply_todo", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_pinned(self) -> None: def test_flock_pinned(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "Rishabh rawat pinned an item to the conversation" expected_message = "Rishabh rawat pinned an item to the conversation"
self.send_and_test_stream_message('pinned', self.check_webhook(
expected_topic, "pinned", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_reminder(self) -> None: def test_flock_reminder(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "Rishabh rawat wanted me to remind All" expected_message = "Rishabh rawat wanted me to remind All"
self.send_and_test_stream_message('reminder', self.check_webhook(
expected_topic, "reminder", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def test_flock_todo(self) -> None: def test_flock_todo(self) -> None:
expected_topic = "Flock notifications" expected_topic = "Flock notifications"
expected_message = "Rishabh rawat added a to-do in New List 1 list" expected_message = "Rishabh rawat added a to-do in New List 1 list"
self.send_and_test_stream_message('todo', self.check_webhook(
expected_topic, "todo", expected_topic, expected_message, content_type="application/json"
expected_message, )
content_type="application/json")
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("flock", fixture_name, file_type="json") return self.webhook_fixture_data("flock", fixture_name, file_type="json")

View File

@ -15,10 +15,12 @@ class FrontHookTests(WebhookTestCase):
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
expected_message = "**Leela Turanga** assigned themselves." expected_message = "**Leela Turanga** assigned themselves."
self.send_and_test_stream_message('conversation_assigned_outbound', self.check_webhook(
expected_topic, "conversation_assigned_outbound",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_outbound_message(self) -> None: def test_outbound_message(self) -> None:
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
@ -27,65 +29,79 @@ class FrontHookTests(WebhookTestCase):
"to **calculon@momsbot.com**:\n" \ "to **calculon@momsbot.com**:\n" \
"```quote\n*Subject*: Your next delivery is on Epsilon 96Z\n```" "```quote\n*Subject*: Your next delivery is on Epsilon 96Z\n```"
self.send_and_test_stream_message('outbound_message', self.check_webhook(
expected_topic, "outbound_message",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_conversation_archived(self) -> None: def test_conversation_archived(self) -> None:
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
expected_message = "Archived by **Leela Turanga**." expected_message = "Archived by **Leela Turanga**."
self.send_and_test_stream_message('conversation_archived', self.check_webhook(
expected_topic, "conversation_archived",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_conversation_reopened(self) -> None: def test_conversation_reopened(self) -> None:
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
expected_message = "Reopened by **Leela Turanga**." expected_message = "Reopened by **Leela Turanga**."
self.send_and_test_stream_message('conversation_reopened', self.check_webhook(
expected_topic, "conversation_reopened",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_conversation_deleted(self) -> None: def test_conversation_deleted(self) -> None:
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
expected_message = "Deleted by **Leela Turanga**." expected_message = "Deleted by **Leela Turanga**."
self.send_and_test_stream_message('conversation_deleted', self.check_webhook(
expected_topic, "conversation_deleted",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_conversation_restored(self) -> None: def test_conversation_restored(self) -> None:
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
expected_message = "Restored by **Leela Turanga**." expected_message = "Restored by **Leela Turanga**."
self.send_and_test_stream_message('conversation_restored', self.check_webhook(
expected_topic, "conversation_restored",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_conversation_unassigned(self) -> None: def test_conversation_unassigned(self) -> None:
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
expected_message = "Unassigned by **Leela Turanga**." expected_message = "Unassigned by **Leela Turanga**."
self.send_and_test_stream_message('conversation_unassigned', self.check_webhook(
expected_topic, "conversation_unassigned",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_mention_all(self) -> None: def test_mention_all(self) -> None:
expected_topic = 'cnv_keo696' expected_topic = 'cnv_keo696'
expected_message = "**Leela Turanga** left a comment:\n" \ expected_message = "**Leela Turanga** left a comment:\n" \
"```quote\n@all Could someone else take this?\n```" "```quote\n@all Could someone else take this?\n```"
self.send_and_test_stream_message('mention_all', self.check_webhook(
expected_topic, "mention_all",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
# Scenario 2: Conversation starts from an inbound message. # Scenario 2: Conversation starts from an inbound message.
@ -96,29 +112,35 @@ class FrontHookTests(WebhookTestCase):
"to **support@planet-express.com**:\n" \ "to **support@planet-express.com**:\n" \
"```quote\n*Subject*: Being a robot is great, but...\n```" "```quote\n*Subject*: Being a robot is great, but...\n```"
self.send_and_test_stream_message('inbound_message', self.check_webhook(
expected_topic, "inbound_message",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_conversation_tagged(self) -> None: def test_conversation_tagged(self) -> None:
expected_topic = 'cnv_keocka' expected_topic = 'cnv_keocka'
expected_message = "**Leela Turanga** added tag **Urgent**." expected_message = "**Leela Turanga** added tag **Urgent**."
self.send_and_test_stream_message('conversation_tagged', self.check_webhook(
expected_topic, "conversation_tagged",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
# Conversation automatically assigned to a teammate who replied to it. # Conversation automatically assigned to a teammate who replied to it.
def test_conversation_assigned_reply(self) -> None: def test_conversation_assigned_reply(self) -> None:
expected_topic = 'cnv_keocka' expected_topic = 'cnv_keocka'
expected_message = "**Leela Turanga** assigned themselves." expected_message = "**Leela Turanga** assigned themselves."
self.send_and_test_stream_message('conversation_assigned_reply', self.check_webhook(
expected_topic, "conversation_assigned_reply",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_outbound_reply(self) -> None: def test_outbound_reply(self) -> None:
expected_topic = 'cnv_keocka' expected_topic = 'cnv_keocka'
@ -126,49 +148,59 @@ class FrontHookTests(WebhookTestCase):
"from **support@planet-express.com** " \ "from **support@planet-express.com** " \
"to **calculon@momsbot.com**." "to **calculon@momsbot.com**."
self.send_and_test_stream_message('outbound_reply', self.check_webhook(
expected_topic, "outbound_reply",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_conversation_untagged(self) -> None: def test_conversation_untagged(self) -> None:
expected_topic = 'cnv_keocka' expected_topic = 'cnv_keocka'
expected_message = "**Leela Turanga** removed tag **Urgent**." expected_message = "**Leela Turanga** removed tag **Urgent**."
self.send_and_test_stream_message('conversation_untagged', self.check_webhook(
expected_topic, "conversation_untagged",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_mention(self) -> None: def test_mention(self) -> None:
expected_topic = 'cnv_keocka' expected_topic = 'cnv_keocka'
expected_message = "**Leela Turanga** left a comment:\n" \ expected_message = "**Leela Turanga** left a comment:\n" \
"```quote\n@bender Could you take it from here?\n```" "```quote\n@bender Could you take it from here?\n```"
self.send_and_test_stream_message('mention', self.check_webhook(
expected_topic, "mention",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_comment(self) -> None: def test_comment(self) -> None:
expected_topic = 'cnv_keocka' expected_topic = 'cnv_keocka'
expected_message = "**Bender Rodriguez** left a comment:\n" \ expected_message = "**Bender Rodriguez** left a comment:\n" \
"```quote\nSure.\n```" "```quote\nSure.\n```"
self.send_and_test_stream_message('comment', self.check_webhook(
expected_topic, "comment",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
# Conversation manually assigned to another teammate. # Conversation manually assigned to another teammate.
def test_conversation_assigned(self) -> None: def test_conversation_assigned(self) -> None:
expected_topic = 'cnv_keocka' expected_topic = 'cnv_keocka'
expected_message = "**Leela Turanga** assigned **Bender Rodriguez**." expected_message = "**Leela Turanga** assigned **Bender Rodriguez**."
self.send_and_test_stream_message('conversation_assigned', self.check_webhook(
expected_topic, "conversation_assigned",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_unknown_webhook_request(self) -> None: def test_unknown_webhook_request(self) -> None:
payload = self.get_body('conversation_assigned') payload = self.get_body('conversation_assigned')

View File

@ -9,59 +9,53 @@ class GoogleCodeInTests(WebhookTestCase):
def test_abandon_event_message(self) -> None: def test_abandon_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**student-yqqtag** abandoned the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' expected_message = '**student-yqqtag** abandoned the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).'
self.send_and_test_stream_message('task_abandoned_by_student', self.check_webhook("task_abandoned_by_student", expected_topic, expected_message)
expected_topic, expected_message)
def test_comment_event_message(self) -> None: def test_comment_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**student-yqqtag** commented on the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' expected_message = '**student-yqqtag** commented on the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).'
self.send_and_test_stream_message('student_commented_on_task', self.check_webhook("student_commented_on_task", expected_topic, expected_message)
expected_topic, expected_message)
def test_submit_event_message(self) -> None: def test_submit_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**student-yqqtag** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' expected_message = '**student-yqqtag** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).'
self.send_and_test_stream_message('task_submitted_by_student', self.check_webhook("task_submitted_by_student", expected_topic, expected_message)
expected_topic, expected_message)
def test_claim_event_message(self) -> None: def test_claim_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**student-yqqtag** claimed the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' expected_message = '**student-yqqtag** claimed the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).'
self.send_and_test_stream_message('task_claimed_by_student', self.check_webhook("task_claimed_by_student", expected_topic, expected_message)
expected_topic, expected_message)
def test_approve_event_message(self) -> None: def test_approve_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' expected_message = '**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).'
self.send_and_test_stream_message('task_approved_by_mentor', self.check_webhook("task_approved_by_mentor", expected_topic, expected_message)
expected_topic, expected_message)
def test_approve_pending_pc_event_message(self) -> None: def test_approve_pending_pc_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) (pending parental consent).' expected_message = '**eeshangarg** approved the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) (pending parental consent).'
self.send_and_test_stream_message('task_approved_by_mentor_pending_parental_consent', self.check_webhook(
expected_topic, expected_message) "task_approved_by_mentor_pending_parental_consent", expected_topic, expected_message
)
def test_needswork_event_message(self) -> None: def test_needswork_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**eeshangarg** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/5136918324969472/) for more work.' expected_message = '**eeshangarg** submitted the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/5136918324969472/) for more work.'
self.send_and_test_stream_message('task_submitted_by_mentor_for_more_work', self.check_webhook(
expected_topic, expected_message) "task_submitted_by_mentor_for_more_work", expected_topic, expected_message
)
def test_extend_event_message(self) -> None: def test_extend_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**eeshangarg** extended the deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) by 1.0 day(s).' expected_message = '**eeshangarg** extended the deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/) by 1.0 day(s).'
self.send_and_test_stream_message('task_deadline_extended_by_mentor', self.check_webhook("task_deadline_extended_by_mentor", expected_topic, expected_message)
expected_topic, expected_message)
def test_unassign_event_message(self) -> None: def test_unassign_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = '**eeshangarg** unassigned **student-yqqtag** from the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).' expected_message = '**eeshangarg** unassigned **student-yqqtag** from the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6296903092273152/).'
self.send_and_test_stream_message('student_unassigned_by_mentor', self.check_webhook("student_unassigned_by_mentor", expected_topic, expected_message)
expected_topic, expected_message)
def test_outoftime_event_message(self) -> None: def test_outoftime_event_message(self) -> None:
expected_topic = 'student-yqqtag' expected_topic = 'student-yqqtag'
expected_message = 'The deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6694926301528064/) has passed.' expected_message = 'The deadline for the task [Sails unspread it stopped at kearney](https://codein.withgoogle.com/dashboard/task-instances/6694926301528064/) has passed.'
self.send_and_test_stream_message('task_deadline_has_passed', self.check_webhook("task_deadline_has_passed", expected_topic, expected_message)
expected_topic, expected_message)

View File

@ -17,83 +17,83 @@ class GiteaHookTests(WebhookTestCase):
* commit ([6773eab](https://try.gitea.io/kostekIV/test/commit/6773eabc0778a3e38997c06a13f5f0c48b67e5dc)) * commit ([6773eab](https://try.gitea.io/kostekIV/test/commit/6773eabc0778a3e38997c06a13f5f0c48b67e5dc))
* commit ([337402c](https://try.gitea.io/kostekIV/test/commit/337402cf675ce7082ddcd23d06a116c85241825a)) * commit ([337402c](https://try.gitea.io/kostekIV/test/commit/337402cf675ce7082ddcd23d06a116c85241825a))
* commit ([0a38cad](https://try.gitea.io/kostekIV/test/commit/0a38cad3fac3a13bb78b738d13f15ce9cc3343fa))""" * commit ([0a38cad](https://try.gitea.io/kostekIV/test/commit/0a38cad3fac3a13bb78b738d13f15ce9cc3343fa))"""
self.send_and_test_stream_message('push__5_commits', expected_topic, expected_message) self.check_webhook("push__5_commits", expected_topic, expected_message)
def test_new_branch(self) -> None: def test_new_branch(self) -> None:
expected_topic = "test / test-branch" expected_topic = "test / test-branch"
expected_message = "kostekIV created [test-branch](https://try.gitea.io/kostekIV/test/src/test-branch) branch." expected_message = "kostekIV created [test-branch](https://try.gitea.io/kostekIV/test/src/test-branch) branch."
self.send_and_test_stream_message('create__branch', expected_topic, expected_message) self.check_webhook("create__branch", expected_topic, expected_message)
def test_pull_request_opened(self) -> None: def test_pull_request_opened(self) -> None:
expected_topic = "test / PR #1905 New pr" expected_topic = "test / PR #1905 New pr"
expected_message = """kostekIV opened [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`.""" expected_message = """kostekIV opened [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`."""
self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) self.check_webhook("pull_request__opened", expected_topic, expected_message)
def test_pull_request_merged(self) -> None: def test_pull_request_merged(self) -> None:
expected_topic = "test / PR #1905 New pr" expected_topic = "test / PR #1905 New pr"
expected_message = """kostekIV merged [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`.""" expected_message = """kostekIV merged [PR #4](https://try.gitea.io/kostekIV/test/pulls/4) from `test-branch` to `master`."""
self.send_and_test_stream_message('pull_request__merged', expected_topic, expected_message) self.check_webhook("pull_request__merged", expected_topic, expected_message)
def test_pull_request_edited(self) -> None: def test_pull_request_edited(self) -> None:
expected_topic = "test / PR #1906 test 2" expected_topic = "test / PR #1906 test 2"
expected_message = """kostekIV edited [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" expected_message = """kostekIV edited [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`."""
self.send_and_test_stream_message('pull_request__edited', expected_topic, expected_message) self.check_webhook("pull_request__edited", expected_topic, expected_message)
def test_pull_request_reopened(self) -> None: def test_pull_request_reopened(self) -> None:
expected_topic = "test / PR #1906 test 2" expected_topic = "test / PR #1906 test 2"
expected_message = """kostekIV reopened [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" expected_message = """kostekIV reopened [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`."""
self.send_and_test_stream_message('pull_request__reopened', expected_topic, expected_message) self.check_webhook("pull_request__reopened", expected_topic, expected_message)
def test_pull_request_closed(self) -> None: def test_pull_request_closed(self) -> None:
expected_topic = "test / PR #1906 test 2" expected_topic = "test / PR #1906 test 2"
expected_message = """kostekIV closed [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`.""" expected_message = """kostekIV closed [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) from `d` to `master`."""
self.send_and_test_stream_message('pull_request__closed', expected_topic, expected_message) self.check_webhook("pull_request__closed", expected_topic, expected_message)
def test_pull_request_assigned(self) -> None: def test_pull_request_assigned(self) -> None:
expected_topic = "test / PR #1906 test 2" expected_topic = "test / PR #1906 test 2"
expected_message = """kostekIV assigned [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) (assigned to kostekIV) from `d` to `master`.""" expected_message = """kostekIV assigned [PR #5](https://try.gitea.io/kostekIV/test/pulls/5) (assigned to kostekIV) from `d` to `master`."""
self.send_and_test_stream_message('pull_request__assigned', expected_topic, expected_message) self.check_webhook("pull_request__assigned", expected_topic, expected_message)
def test_issues_opened(self) -> None: def test_issues_opened(self) -> None:
expected_topic = "test / Issue #3 Test issue" expected_topic = "test / Issue #3 Test issue"
expected_message = """kostekIV opened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest body\n~~~""" expected_message = """kostekIV opened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest body\n~~~"""
self.send_and_test_stream_message('issues__opened', expected_topic, expected_message) self.check_webhook("issues__opened", expected_topic, expected_message)
def test_issues_edited(self) -> None: def test_issues_edited(self) -> None:
expected_topic = "test / Issue #3 Test issue 2" expected_topic = "test / Issue #3 Test issue 2"
expected_message = """kostekIV edited [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" expected_message = """kostekIV edited [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~"""
self.send_and_test_stream_message('issues__edited', expected_topic, expected_message) self.check_webhook("issues__edited", expected_topic, expected_message)
def test_issues_closed(self) -> None: def test_issues_closed(self) -> None:
expected_topic = "test / Issue #3 Test issue 2" expected_topic = "test / Issue #3 Test issue 2"
expected_message = """kostekIV closed [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" expected_message = """kostekIV closed [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~"""
self.send_and_test_stream_message('issues__closed', expected_topic, expected_message) self.check_webhook("issues__closed", expected_topic, expected_message)
def test_issues_assigned(self) -> None: def test_issues_assigned(self) -> None:
expected_topic = "test / Issue #3 Test issue" expected_topic = "test / Issue #3 Test issue"
expected_message = """kostekIV assigned [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" expected_message = """kostekIV assigned [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~"""
self.send_and_test_stream_message('issues__assigned', expected_topic, expected_message) self.check_webhook("issues__assigned", expected_topic, expected_message)
def test_issues_reopened(self) -> None: def test_issues_reopened(self) -> None:
expected_topic = "test / Issue #3 Test issue 2" expected_topic = "test / Issue #3 Test issue 2"
expected_message = """kostekIV reopened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~""" expected_message = """kostekIV reopened [Issue #3](https://try.gitea.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest body\n~~~"""
self.send_and_test_stream_message('issues__reopened', expected_topic, expected_message) self.check_webhook("issues__reopened", expected_topic, expected_message)
def test_issue_comment_new(self) -> None: def test_issue_comment_new(self) -> None:
expected_topic = "test / Issue #3 Test issue" expected_topic = "test / Issue #3 Test issue"
expected_message = """kostekIV [commented](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\ntest comment\n~~~""" expected_message = """kostekIV [commented](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\ntest comment\n~~~"""
self.send_and_test_stream_message('issue_comment__new', expected_topic, expected_message) self.check_webhook("issue_comment__new", expected_topic, expected_message)
def test_issue_comment_in_pr(self) -> None: def test_issue_comment_in_pr(self) -> None:
expected_topic = "test / Issue #1 dummy" expected_topic = "test / Issue #1 dummy"
expected_message = """kostekIV [commented](https://try.gitea.io/kostekIV/test/pulls/1/files#issuecomment-24399) on [Issue #1](https://try.gitea.io/kostekIV/test/issues/1):\n\n~~~ quote\ntest comment\n~~~""" expected_message = """kostekIV [commented](https://try.gitea.io/kostekIV/test/pulls/1/files#issuecomment-24399) on [Issue #1](https://try.gitea.io/kostekIV/test/issues/1):\n\n~~~ quote\ntest comment\n~~~"""
self.send_and_test_stream_message('issue_comment__in_pr', expected_topic, expected_message) self.check_webhook("issue_comment__in_pr", expected_topic, expected_message)
def test_issue_comment_edited(self) -> None: def test_issue_comment_edited(self) -> None:
expected_topic = "test / Issue #3 Test issue 2" expected_topic = "test / Issue #3 Test issue 2"
expected_message = """kostekIV edited a [comment](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit test comment\n~~~""" expected_message = """kostekIV edited a [comment](https://try.gitea.io/kostekIV/test/issues/3#issuecomment-24400) on [Issue #3](https://try.gitea.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit test comment\n~~~"""
self.send_and_test_stream_message('issue_comment__edited', expected_topic, expected_message) self.check_webhook("issue_comment__edited", expected_topic, expected_message)
@patch('zerver.webhooks.gogs.view.check_send_webhook_message') @patch('zerver.webhooks.gogs.view.check_send_webhook_message')
def test_push_filtered_by_branches_ignore(self, check_send_webhook_message_mock: MagicMock) -> None: def test_push_filtered_by_branches_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:

View File

@ -18,285 +18,307 @@ class GithubWebhookTest(WebhookTestCase):
def test_ping_event(self) -> None: def test_ping_event(self) -> None:
expected_message = "GitHub webhook has been successfully configured by TomaszKolek." expected_message = "GitHub webhook has been successfully configured by TomaszKolek."
self.send_and_test_stream_message('ping', TOPIC_REPO, expected_message) self.check_webhook("ping", TOPIC_REPO, expected_message)
def test_star_event(self) -> None: def test_star_event(self) -> None:
expected_message = "Codertocat starred the repository [Codertocat/Hello-World](https://github.com/Codertocat/Hello-World)." expected_message = "Codertocat starred the repository [Codertocat/Hello-World](https://github.com/Codertocat/Hello-World)."
expected_topic = "Hello-World" expected_topic = "Hello-World"
self.send_and_test_stream_message('star', expected_topic, expected_message) self.check_webhook("star", expected_topic, expected_message)
def test_ping_organization_event(self) -> None: def test_ping_organization_event(self) -> None:
expected_message = "GitHub webhook has been successfully configured by eeshangarg." expected_message = "GitHub webhook has been successfully configured by eeshangarg."
self.send_and_test_stream_message('ping__organization', 'zulip-test-org', expected_message) self.check_webhook("ping__organization", "zulip-test-org", expected_message)
def test_push_delete_branch(self) -> None: def test_push_delete_branch(self) -> None:
expected_message = "eeshangarg [deleted](https://github.com/eeshangarg/public-repo/compare/2e8cf535fb38...000000000000) the branch feature." expected_message = "eeshangarg [deleted](https://github.com/eeshangarg/public-repo/compare/2e8cf535fb38...000000000000) the branch feature."
self.send_and_test_stream_message('push__delete_branch', "public-repo / feature", expected_message) self.check_webhook("push__delete_branch", "public-repo / feature", expected_message)
def test_push_local_branch_without_commits(self) -> None: def test_push_local_branch_without_commits(self) -> None:
expected_message = "eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/feature) the branch feature." expected_message = "eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/feature) the branch feature."
self.send_and_test_stream_message('push__local_branch_without_commits', "public-repo / feature", expected_message) self.check_webhook(
"push__local_branch_without_commits", "public-repo / feature", expected_message
)
def test_push_1_commit(self) -> None: def test_push_1_commit(self) -> None:
expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))" expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"
self.send_and_test_stream_message('push__1_commit', TOPIC_BRANCH, expected_message) self.check_webhook("push__1_commit", TOPIC_BRANCH, expected_message)
def test_push_1_commit_without_username(self) -> None: def test_push_1_commit_without_username(self) -> None:
expected_message = "eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/0383613da871...2e8cf535fb38) 1 commit to branch changes. Commits by John Snow (1).\n\n* Update the README ([2e8cf53](https://github.com/eeshangarg/public-repo/commit/2e8cf535fb38a3dab2476cdf856efda904ad4c94))" expected_message = "eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/0383613da871...2e8cf535fb38) 1 commit to branch changes. Commits by John Snow (1).\n\n* Update the README ([2e8cf53](https://github.com/eeshangarg/public-repo/commit/2e8cf535fb38a3dab2476cdf856efda904ad4c94))"
self.send_and_test_stream_message('push__1_commit_without_username', TOPIC_BRANCH, expected_message) self.check_webhook("push__1_commit_without_username", TOPIC_BRANCH, expected_message)
def test_push_1_commit_filtered_by_branches(self) -> None: def test_push_1_commit_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url('master,changes') self.url = self.build_webhook_url('master,changes')
expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))" expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"
self.send_and_test_stream_message('push__1_commit', TOPIC_BRANCH, expected_message) self.check_webhook("push__1_commit", TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters(self) -> None: def test_push_multiple_comitters(self) -> None:
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{commits_info * 5}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""" expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{commits_info * 5}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
self.send_and_test_stream_message('push__multiple_committers', TOPIC_BRANCH, expected_message) self.check_webhook("push__multiple_committers", TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters_with_others(self) -> None: def test_push_multiple_comitters_with_others(self) -> None:
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{commits_info * 9}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""" expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{commits_info * 9}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
self.send_and_test_stream_message('push__multiple_committers_with_others', TOPIC_BRANCH, expected_message) self.check_webhook("push__multiple_committers_with_others", TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters_filtered_by_branches(self) -> None: def test_push_multiple_comitters_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url('master,changes') self.url = self.build_webhook_url('master,changes')
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{commits_info * 5}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""" expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{commits_info * 5}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
self.send_and_test_stream_message('push__multiple_committers', TOPIC_BRANCH, expected_message) self.check_webhook("push__multiple_committers", TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters_with_others_filtered_by_branches(self) -> None: def test_push_multiple_comitters_with_others_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url('master,changes') self.url = self.build_webhook_url('master,changes')
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{commits_info * 9}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""" expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{commits_info * 9}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
self.send_and_test_stream_message('push__multiple_committers_with_others', TOPIC_BRANCH, expected_message) self.check_webhook("push__multiple_committers_with_others", TOPIC_BRANCH, expected_message)
def test_push_50_commits(self) -> None: def test_push_50_commits(self) -> None:
commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n" commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n"
expected_message = f"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{commit_info * COMMITS_LIMIT}[and 30 more commit(s)]" expected_message = f"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{commit_info * COMMITS_LIMIT}[and 30 more commit(s)]"
self.send_and_test_stream_message('push__50_commits', TOPIC_BRANCH, expected_message) self.check_webhook("push__50_commits", TOPIC_BRANCH, expected_message)
def test_push_50_commits_filtered_by_branches(self) -> None: def test_push_50_commits_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,changes') self.url = self.build_webhook_url(branches='master,changes')
commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n" commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n"
expected_message = f"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{commit_info * COMMITS_LIMIT}[and 30 more commit(s)]" expected_message = f"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{commit_info * COMMITS_LIMIT}[and 30 more commit(s)]"
self.send_and_test_stream_message('push__50_commits', TOPIC_BRANCH, expected_message) self.check_webhook("push__50_commits", TOPIC_BRANCH, expected_message)
def test_commit_comment_msg(self) -> None: def test_commit_comment_msg(self) -> None:
expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394) on [9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b):\n~~~ quote\nThis is a really good change! :+1:\n~~~" expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394) on [9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b):\n~~~ quote\nThis is a really good change! :+1:\n~~~"
self.send_and_test_stream_message('commit_comment', TOPIC_REPO, expected_message) self.check_webhook("commit_comment", TOPIC_REPO, expected_message)
def test_create_msg(self) -> None: def test_create_msg(self) -> None:
expected_message = "baxterthehacker created tag 0.0.1." expected_message = "baxterthehacker created tag 0.0.1."
self.send_and_test_stream_message('create', TOPIC_REPO, expected_message) self.check_webhook("create", TOPIC_REPO, expected_message)
def test_delete_msg(self) -> None: def test_delete_msg(self) -> None:
expected_message = "baxterthehacker deleted tag simple-tag." expected_message = "baxterthehacker deleted tag simple-tag."
self.send_and_test_stream_message('delete', TOPIC_REPO, expected_message) self.check_webhook("delete", TOPIC_REPO, expected_message)
def test_deployment_msg(self) -> None: def test_deployment_msg(self) -> None:
expected_message = "baxterthehacker created new deployment." expected_message = "baxterthehacker created new deployment."
self.send_and_test_stream_message('deployment', TOPIC_DEPLOYMENT, expected_message) self.check_webhook("deployment", TOPIC_DEPLOYMENT, expected_message)
def test_deployment_status_msg(self) -> None: def test_deployment_status_msg(self) -> None:
expected_message = "Deployment changed status to success." expected_message = "Deployment changed status to success."
self.send_and_test_stream_message('deployment_status', TOPIC_DEPLOYMENT, expected_message) self.check_webhook("deployment_status", TOPIC_DEPLOYMENT, expected_message)
def test_fork_msg(self) -> None: def test_fork_msg(self) -> None:
expected_message = "baxterandthehackers forked [public-repo](https://github.com/baxterandthehackers/public-repo)." expected_message = "baxterandthehackers forked [public-repo](https://github.com/baxterandthehackers/public-repo)."
self.send_and_test_stream_message('fork', TOPIC_REPO, expected_message) self.check_webhook("fork", TOPIC_REPO, expected_message)
def test_issue_comment_msg(self) -> None: def test_issue_comment_msg(self) -> None:
expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~" expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~"
self.send_and_test_stream_message('issue_comment', TOPIC_ISSUE, expected_message) self.check_webhook("issue_comment", TOPIC_ISSUE, expected_message)
def test_issue_comment_deleted_msg(self) -> None: def test_issue_comment_deleted_msg(self) -> None:
expected_topic = "Scheduler / Issue #5 This is a new issue" expected_topic = "Scheduler / Issue #5 This is a new issue"
expected_message = "eeshangarg deleted a [comment](https://github.com/eeshangarg/Scheduler/issues/5#issuecomment-425164194) on [Issue #5](https://github.com/eeshangarg/Scheduler/issues/5):\n\n~~~ quote\nThis is a comment on this new issue.\n~~~" expected_message = "eeshangarg deleted a [comment](https://github.com/eeshangarg/Scheduler/issues/5#issuecomment-425164194) on [Issue #5](https://github.com/eeshangarg/Scheduler/issues/5):\n\n~~~ quote\nThis is a comment on this new issue.\n~~~"
self.send_and_test_stream_message('issue_comment__deleted', expected_topic, expected_message) self.check_webhook("issue_comment__deleted", expected_topic, expected_message)
def test_issue_comment_msg_with_custom_topic_in_url(self) -> None: def test_issue_comment_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~" expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~"
self.send_and_test_stream_message('issue_comment', expected_topic, expected_message) self.check_webhook("issue_comment", expected_topic, expected_message)
def test_issue_msg(self) -> None: def test_issue_msg(self) -> None:
expected_message = "baxterthehacker opened [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~" expected_message = "baxterthehacker opened [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~"
self.send_and_test_stream_message('issues', TOPIC_ISSUE, expected_message) self.check_webhook("issues", TOPIC_ISSUE, expected_message)
def test_issue_msg_with_custom_topic_in_url(self) -> None: def test_issue_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "baxterthehacker opened [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~" expected_message = "baxterthehacker opened [Issue #2 Spelling error in the README file](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~"
self.send_and_test_stream_message('issues', expected_topic, expected_message) self.check_webhook("issues", expected_topic, expected_message)
def test_membership_msg(self) -> None: def test_membership_msg(self) -> None:
expected_message = "baxterthehacker added [kdaigle](https://github.com/kdaigle) to the Contractors team." expected_message = "baxterthehacker added [kdaigle](https://github.com/kdaigle) to the Contractors team."
self.send_and_test_stream_message('membership', TOPIC_ORGANIZATION, expected_message) self.check_webhook("membership", TOPIC_ORGANIZATION, expected_message)
def test_membership_removal_msg(self) -> None: def test_membership_removal_msg(self) -> None:
expected_message = "baxterthehacker removed [kdaigle](https://github.com/kdaigle) from the Contractors team." expected_message = "baxterthehacker removed [kdaigle](https://github.com/kdaigle) from the Contractors team."
self.send_and_test_stream_message('membership__removal', TOPIC_ORGANIZATION, expected_message) self.check_webhook("membership__removal", TOPIC_ORGANIZATION, expected_message)
def test_member_msg(self) -> None: def test_member_msg(self) -> None:
expected_message = "baxterthehacker added [octocat](https://github.com/octocat) to [public-repo](https://github.com/baxterthehacker/public-repo)." expected_message = "baxterthehacker added [octocat](https://github.com/octocat) to [public-repo](https://github.com/baxterthehacker/public-repo)."
self.send_and_test_stream_message('member', TOPIC_REPO, expected_message) self.check_webhook("member", TOPIC_REPO, expected_message)
def test_pull_request_opened_msg(self) -> None: def test_pull_request_opened_msg(self) -> None:
expected_message = "baxterthehacker opened [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~" expected_message = "baxterthehacker opened [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~"
self.send_and_test_stream_message('pull_request__opened', TOPIC_PR, expected_message) self.check_webhook("pull_request__opened", TOPIC_PR, expected_message)
def test_pull_request_opened_with_preassigned_assignee_msg(self) -> None: def test_pull_request_opened_with_preassigned_assignee_msg(self) -> None:
expected_topic = "Scheduler / PR #4 Improve README" expected_topic = "Scheduler / PR #4 Improve README"
expected_message = "eeshangarg opened [PR #4](https://github.com/eeshangarg/Scheduler/pull/4) (assigned to eeshangarg) from `improve-readme-2` to `master`." expected_message = "eeshangarg opened [PR #4](https://github.com/eeshangarg/Scheduler/pull/4) (assigned to eeshangarg) from `improve-readme-2` to `master`."
self.send_and_test_stream_message('pull_request__opened_with_preassigned_assignee', expected_topic, expected_message) self.check_webhook(
"pull_request__opened_with_preassigned_assignee", expected_topic, expected_message
)
def test_pull_request_opened_msg_with_custom_topic_in_url(self) -> None: def test_pull_request_opened_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "baxterthehacker opened [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~" expected_message = "baxterthehacker opened [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~"
self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) self.check_webhook("pull_request__opened", expected_topic, expected_message)
def test_pull_request_synchronized_msg(self) -> None: def test_pull_request_synchronized_msg(self) -> None:
expected_message = "baxterthehacker updated [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`." expected_message = "baxterthehacker updated [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`."
self.send_and_test_stream_message('pull_request__synchronized', TOPIC_PR, expected_message) self.check_webhook("pull_request__synchronized", TOPIC_PR, expected_message)
def test_pull_request_closed_msg(self) -> None: def test_pull_request_closed_msg(self) -> None:
expected_message = "baxterthehacker closed without merge [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)." expected_message = "baxterthehacker closed without merge [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)."
self.send_and_test_stream_message('pull_request__closed', TOPIC_PR, expected_message) self.check_webhook("pull_request__closed", TOPIC_PR, expected_message)
def test_pull_request_closed_msg_with_custom_topic_in_url(self) -> None: def test_pull_request_closed_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "baxterthehacker closed without merge [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1)." expected_message = "baxterthehacker closed without merge [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1)."
self.send_and_test_stream_message('pull_request__closed', expected_topic, expected_message) self.check_webhook("pull_request__closed", expected_topic, expected_message)
def test_pull_request_merged_msg(self) -> None: def test_pull_request_merged_msg(self) -> None:
expected_message = "baxterthehacker merged [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)." expected_message = "baxterthehacker merged [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)."
self.send_and_test_stream_message('pull_request__merged', TOPIC_PR, expected_message) self.check_webhook("pull_request__merged", TOPIC_PR, expected_message)
def test_public_msg(self) -> None: def test_public_msg(self) -> None:
expected_message = "baxterthehacker made the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo) public." expected_message = "baxterthehacker made the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo) public."
self.send_and_test_stream_message('public', TOPIC_REPO, expected_message) self.check_webhook("public", TOPIC_REPO, expected_message)
def test_wiki_pages_msg(self) -> None: def test_wiki_pages_msg(self) -> None:
expected_message = "jasonrudolph:\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)" expected_message = "jasonrudolph:\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)"
self.send_and_test_stream_message('gollum__wiki_pages', TOPIC_WIKI, expected_message) self.check_webhook("gollum__wiki_pages", TOPIC_WIKI, expected_message)
def test_watch_msg(self) -> None: def test_watch_msg(self) -> None:
expected_message = "baxterthehacker starred the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo)." expected_message = "baxterthehacker starred the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo)."
self.send_and_test_stream_message('watch__repository', TOPIC_REPO, expected_message) self.check_webhook("watch__repository", TOPIC_REPO, expected_message)
def test_repository_msg(self) -> None: def test_repository_msg(self) -> None:
expected_message = "baxterthehacker created the repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo)." expected_message = "baxterthehacker created the repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo)."
self.send_and_test_stream_message('repository', TOPIC_REPO, expected_message) self.check_webhook("repository", TOPIC_REPO, expected_message)
def test_team_add_msg(self) -> None: def test_team_add_msg(self) -> None:
expected_message = "The repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo) was added to team github." expected_message = "The repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo) was added to team github."
self.send_and_test_stream_message('team_add', TOPIC_REPO, expected_message) self.check_webhook("team_add", TOPIC_REPO, expected_message)
def test_release_msg(self) -> None: def test_release_msg(self) -> None:
expected_message = "baxterthehacker published release [0.0.1](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1) for tag 0.0.1." expected_message = "baxterthehacker published release [0.0.1](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1) for tag 0.0.1."
self.send_and_test_stream_message('release', TOPIC_REPO, expected_message) self.check_webhook("release", TOPIC_REPO, expected_message)
def test_page_build_msg(self) -> None: def test_page_build_msg(self) -> None:
expected_message = "Github Pages build, triggered by baxterthehacker, has finished building." expected_message = "Github Pages build, triggered by baxterthehacker, has finished building."
self.send_and_test_stream_message('page_build', TOPIC_REPO, expected_message) self.check_webhook("page_build", TOPIC_REPO, expected_message)
def test_status_msg(self) -> None: def test_status_msg(self) -> None:
expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to success." expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to success."
self.send_and_test_stream_message('status', TOPIC_REPO, expected_message) self.check_webhook("status", TOPIC_REPO, expected_message)
def test_status_with_target_url_msg(self) -> None: def test_status_with_target_url_msg(self) -> None:
expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to [success](https://example.com/build/status)." expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to [success](https://example.com/build/status)."
self.send_and_test_stream_message('status__with_target_url', TOPIC_REPO, expected_message) self.check_webhook("status__with_target_url", TOPIC_REPO, expected_message)
def test_pull_request_review_msg(self) -> None: def test_pull_request_review_msg(self) -> None:
expected_message = "baxterthehacker submitted [PR Review](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)." expected_message = "baxterthehacker submitted [PR Review](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)."
self.send_and_test_stream_message('pull_request_review', TOPIC_PR, expected_message) self.check_webhook("pull_request_review", TOPIC_PR, expected_message)
def test_pull_request_review_msg_with_custom_topic_in_url(self) -> None: def test_pull_request_review_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "baxterthehacker submitted [PR Review for #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)." expected_message = "baxterthehacker submitted [PR Review for #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)."
self.send_and_test_stream_message('pull_request_review', expected_topic, expected_message) self.check_webhook("pull_request_review", expected_topic, expected_message)
def test_pull_request_review_comment_msg(self) -> None: def test_pull_request_review_comment_msg(self) -> None:
expected_message = "baxterthehacker created [PR Review Comment](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~" expected_message = "baxterthehacker created [PR Review Comment](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~"
self.send_and_test_stream_message('pull_request_review_comment', TOPIC_PR, expected_message) self.check_webhook("pull_request_review_comment", TOPIC_PR, expected_message)
def test_pull_request_review_comment_with_custom_topic_in_url(self) -> None: def test_pull_request_review_comment_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "baxterthehacker created [PR Review Comment on #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~" expected_message = "baxterthehacker created [PR Review Comment on #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~"
self.send_and_test_stream_message('pull_request_review_comment', expected_topic, expected_message) self.check_webhook("pull_request_review_comment", expected_topic, expected_message)
def test_push_tag_msg(self) -> None: def test_push_tag_msg(self) -> None:
expected_message = "baxterthehacker pushed tag abc." expected_message = "baxterthehacker pushed tag abc."
self.send_and_test_stream_message('push__tag', TOPIC_REPO, expected_message) self.check_webhook("push__tag", TOPIC_REPO, expected_message)
def test_pull_request_edited_msg(self) -> None: def test_pull_request_edited_msg(self) -> None:
expected_message = "baxterthehacker edited [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`." expected_message = "baxterthehacker edited [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`."
self.send_and_test_stream_message('pull_request__edited', TOPIC_PR, expected_message) self.check_webhook("pull_request__edited", TOPIC_PR, expected_message)
def test_pull_request_assigned_msg(self) -> None: def test_pull_request_assigned_msg(self) -> None:
expected_message = "baxterthehacker assigned [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." expected_message = "baxterthehacker assigned [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker."
self.send_and_test_stream_message('pull_request__assigned', TOPIC_PR, expected_message) self.check_webhook("pull_request__assigned", TOPIC_PR, expected_message)
def test_pull_request_assigned_msg_with_custom_topic_in_url(self) -> None: def test_pull_request_assigned_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "baxterthehacker assigned [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." expected_message = "baxterthehacker assigned [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker."
self.send_and_test_stream_message('pull_request__assigned', expected_topic, expected_message) self.check_webhook("pull_request__assigned", expected_topic, expected_message)
def test_pull_request_unassigned_msg(self) -> None: def test_pull_request_unassigned_msg(self) -> None:
expected_message = "eeshangarg unassigned [PR #1](https://github.com/zulip-test-org/helloworld/pull/1)." expected_message = "eeshangarg unassigned [PR #1](https://github.com/zulip-test-org/helloworld/pull/1)."
self.send_and_test_stream_message('pull_request__unassigned', 'helloworld / PR #1 Mention that Zulip rocks!', expected_message) self.check_webhook(
"pull_request__unassigned",
"helloworld / PR #1 Mention that Zulip rocks!",
expected_message,
)
def test_pull_request_ready_for_review_msg(self) -> None: def test_pull_request_ready_for_review_msg(self) -> None:
expected_message = "**Hypro999** has marked [PR #2](https://github.com/Hypro999/temp-test-github-webhook/pull/2) as ready for review." expected_message = "**Hypro999** has marked [PR #2](https://github.com/Hypro999/temp-test-github-webhook/pull/2) as ready for review."
self.send_and_test_stream_message('pull_request__ready_for_review', 'temp-test-github-webhook / PR #2 Test', expected_message) self.check_webhook(
"pull_request__ready_for_review",
"temp-test-github-webhook / PR #2 Test",
expected_message,
)
def test_pull_request_review_requested_msg(self) -> None: def test_pull_request_review_requested_msg(self) -> None:
expected_message = "**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." expected_message = "**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)."
self.send_and_test_stream_message('pull_request__review_requested', 'Scheduler / PR #1 This is just a test commit', expected_message) self.check_webhook(
"pull_request__review_requested",
"Scheduler / PR #1 This is just a test commit",
expected_message,
)
def test_pull_request_review_requested_singular_key_msg(self) -> None: def test_pull_request_review_requested_singular_key_msg(self) -> None:
expected_message = "**eeshangarg** requested [rishig](https://github.com/rishig) for a review on [PR #6](https://github.com/eeshangarg/Scheduler/pull/6)." expected_message = "**eeshangarg** requested [rishig](https://github.com/rishig) for a review on [PR #6](https://github.com/eeshangarg/Scheduler/pull/6)."
self.send_and_test_stream_message('pull_request__review_requested_singular_key', self.check_webhook(
'Scheduler / PR #6 Mention how awesome this project is in ...', "pull_request__review_requested_singular_key",
expected_message) "Scheduler / PR #6 Mention how awesome this project is in ...",
expected_message,
)
def test_pull_request_review_requested_multiple_reviwers_msg(self) -> None: def test_pull_request_review_requested_multiple_reviwers_msg(self) -> None:
expected_message = "**eeshangarg** requested [showell](https://github.com/showell) and [timabbott](https://github.com/timabbott) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)." expected_message = "**eeshangarg** requested [showell](https://github.com/showell) and [timabbott](https://github.com/timabbott) for a review on [PR #1](https://github.com/eeshangarg/Scheduler/pull/1)."
self.send_and_test_stream_message('pull_request__review_requested_multiple_reviewers', self.check_webhook(
'Scheduler / PR #1 This is just a test commit', "pull_request__review_requested_multiple_reviewers",
expected_message) "Scheduler / PR #1 This is just a test commit",
expected_message,
)
def test_pull_request__review_requested_team_reviewer_msg(self) -> None: def test_pull_request__review_requested_team_reviewer_msg(self) -> None:
expected_message = "**singhsourabh** requested [shreyaskargit](https://github.com/shreyaskargit), [bajaj99prashant](https://github.com/bajaj99prashant), [review-team](https://github.com/orgs/test-org965/teams/review-team), [authority](https://github.com/orgs/test-org965/teams/authority) and [management](https://github.com/orgs/test-org965/teams/management) for a review on [PR #4](https://github.com/test-org965/webhook-test/pull/4)." expected_message = "**singhsourabh** requested [shreyaskargit](https://github.com/shreyaskargit), [bajaj99prashant](https://github.com/bajaj99prashant), [review-team](https://github.com/orgs/test-org965/teams/review-team), [authority](https://github.com/orgs/test-org965/teams/authority) and [management](https://github.com/orgs/test-org965/teams/management) for a review on [PR #4](https://github.com/test-org965/webhook-test/pull/4)."
self.send_and_test_stream_message('pull_request__review_requested_team_reviewer', self.check_webhook(
'webhook-test / PR #4 testing webhook', "pull_request__review_requested_team_reviewer",
expected_message) "webhook-test / PR #4 testing webhook",
expected_message,
)
def test_pull_request_review_requested_with_custom_topic_in_url(self) -> None: def test_pull_request_review_requested_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1 This is just a test commit](https://github.com/eeshangarg/Scheduler/pull/1)." expected_message = "**eeshangarg** requested [showell](https://github.com/showell) for a review on [PR #1 This is just a test commit](https://github.com/eeshangarg/Scheduler/pull/1)."
self.send_and_test_stream_message('pull_request__review_requested', expected_topic, expected_message) self.check_webhook("pull_request__review_requested", expected_topic, expected_message)
def test_check_run(self) -> None: def test_check_run(self) -> None:
expected_topic = "hello-world / checks" expected_topic = "hello-world / checks"
expected_message = """ expected_message = """
Check [randscape](http://github.com/github/hello-world/runs/4) completed (success). ([d6fde92](http://github.com/github/hello-world/commit/d6fde92930d4715a2b49857d24b940956b26d2d3)) Check [randscape](http://github.com/github/hello-world/runs/4) completed (success). ([d6fde92](http://github.com/github/hello-world/commit/d6fde92930d4715a2b49857d24b940956b26d2d3))
""".strip() """.strip()
self.send_and_test_stream_message('check_run__completed', expected_topic, expected_message) self.check_webhook("check_run__completed", expected_topic, expected_message)
def test_team_edited_description(self) -> None: def test_team_edited_description(self) -> None:
expected_topic = "team Testing" expected_topic = "team Testing"
@ -305,17 +327,17 @@ Check [randscape](http://github.com/github/hello-world/runs/4) completed (succes
```quote ```quote
A temporary team so that I can get some webhook fixtures! A temporary team so that I can get some webhook fixtures!
```""" ```"""
self.send_and_test_stream_message('team__edited_description', expected_topic, expected_message) self.check_webhook("team__edited_description", expected_topic, expected_message)
def test_team_edited_name(self) -> None: def test_team_edited_name(self) -> None:
expected_topic = "team Testing Team" expected_topic = "team Testing Team"
expected_message = """Team `Testing` was renamed to `Testing Team`.""" expected_message = """Team `Testing` was renamed to `Testing Team`."""
self.send_and_test_stream_message('team__edited_name', expected_topic, expected_message) self.check_webhook("team__edited_name", expected_topic, expected_message)
def test_team_edited_privacy(self) -> None: def test_team_edited_privacy(self) -> None:
expected_topic = "team Testing Team" expected_topic = "team Testing Team"
expected_message = """Team visibility changed to `secret`""" expected_message = """Team visibility changed to `secret`"""
self.send_and_test_stream_message('team__edited_privacy_secret', expected_topic, expected_message) self.check_webhook("team__edited_privacy_secret", expected_topic, expected_message)
@patch('zerver.webhooks.github.view.check_send_webhook_message') @patch('zerver.webhooks.github.view.check_send_webhook_message')
def test_check_run_in_progress_ignore( def test_check_run_in_progress_ignore(

View File

@ -13,60 +13,68 @@ class GitlabHookTests(WebhookTestCase):
self.url = self.build_webhook_url("topic=Specific%20topic") self.url = self.build_webhook_url("topic=Specific%20topic")
expected_topic = "Specific topic" expected_topic = "Specific topic"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))"
self.send_and_test_stream_message('push_hook', expected_topic, expected_message) self.check_webhook("push_hook", expected_topic, expected_message)
def test_push_event_message(self) -> None: def test_push_event_message(self) -> None:
expected_topic = "my-awesome-project / tomek" expected_topic = "my-awesome-project / tomek"
expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))"
self.send_and_test_stream_message('push_hook', expected_topic, expected_message) self.check_webhook("push_hook", expected_topic, expected_message)
def test_push_local_branch_without_commits(self) -> None: def test_push_local_branch_without_commits(self) -> None:
expected_topic = "my-awesome-project / changes" expected_topic = "my-awesome-project / changes"
expected_message = "Eeshan Garg [pushed](https://gitlab.com/eeshangarg/my-awesome-project/compare/0000000000000000000000000000000000000000...68d7a5528cf423dfaac37dd62a56ac9cc8a884e3) the branch changes." expected_message = "Eeshan Garg [pushed](https://gitlab.com/eeshangarg/my-awesome-project/compare/0000000000000000000000000000000000000000...68d7a5528cf423dfaac37dd62a56ac9cc8a884e3) the branch changes."
self.send_and_test_stream_message('push_hook__push_local_branch_without_commits', expected_topic, expected_message) self.check_webhook(
"push_hook__push_local_branch_without_commits", expected_topic, expected_message
)
def test_push_event_message_filtered_by_branches(self) -> None: def test_push_event_message_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,tomek') self.url = self.build_webhook_url(branches='master,tomek')
expected_topic = "my-awesome-project / tomek" expected_topic = "my-awesome-project / tomek"
expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek.\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))"
self.send_and_test_stream_message('push_hook', expected_topic, expected_message) self.check_webhook("push_hook", expected_topic, expected_message)
def test_push_multiple_committers(self) -> None: def test_push_multiple_committers(self) -> None:
expected_topic = "my-awesome-project / tomek" expected_topic = "my-awesome-project / tomek"
expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek. Commits by Ben (1) and Tomasz Kolek (1).\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" expected_message = "Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 2 commits to branch tomek. Commits by Ben (1) and Tomasz Kolek (1).\n\n* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n* c ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))"
self.send_and_test_stream_message('push_hook__push_multiple_committers', expected_topic, expected_message) self.check_webhook("push_hook__push_multiple_committers", expected_topic, expected_message)
def test_push_multiple_committers_with_others(self) -> None: def test_push_multiple_committers_with_others(self) -> None:
expected_topic = "my-awesome-project / tomek" expected_topic = "my-awesome-project / tomek"
commit_info = "* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))\n" commit_info = "* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))\n"
expected_message = f"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 7 commits to branch tomek. Commits by Ben (3), baxterthehacker (2), James (1) and others (1).\n\n{commit_info * 6}* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))" expected_message = f"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 7 commits to branch tomek. Commits by Ben (3), baxterthehacker (2), James (1) and others (1).\n\n{commit_info * 6}* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))"
self.send_and_test_stream_message('push_hook__push_multiple_committers_with_others', expected_topic, expected_message) self.check_webhook(
"push_hook__push_multiple_committers_with_others", expected_topic, expected_message
)
def test_push_commits_more_than_limit_event_message(self) -> None: def test_push_commits_more_than_limit_event_message(self) -> None:
expected_topic = "my-awesome-project / tomek" expected_topic = "my-awesome-project / tomek"
commits_info = '* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' commits_info = '* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n'
expected_message = f"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{commits_info * COMMITS_LIMIT}[and {50 - COMMITS_LIMIT} more commit(s)]" expected_message = f"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{commits_info * COMMITS_LIMIT}[and {50 - COMMITS_LIMIT} more commit(s)]"
self.send_and_test_stream_message('push_hook__push_commits_more_than_limit', expected_topic, expected_message) self.check_webhook(
"push_hook__push_commits_more_than_limit", expected_topic, expected_message
)
def test_push_commits_more_than_limit_message_filtered_by_branches(self) -> None: def test_push_commits_more_than_limit_message_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,tomek') self.url = self.build_webhook_url(branches='master,tomek')
expected_topic = "my-awesome-project / tomek" expected_topic = "my-awesome-project / tomek"
commits_info = '* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' commits_info = '* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n'
expected_message = f"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{commits_info * COMMITS_LIMIT}[and {50 - COMMITS_LIMIT} more commit(s)]" expected_message = f"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{commits_info * COMMITS_LIMIT}[and {50 - COMMITS_LIMIT} more commit(s)]"
self.send_and_test_stream_message('push_hook__push_commits_more_than_limit', expected_topic, expected_message) self.check_webhook(
"push_hook__push_commits_more_than_limit", expected_topic, expected_message
)
def test_remove_branch_event_message(self) -> None: def test_remove_branch_event_message(self) -> None:
expected_topic = "my-awesome-project / tomek" expected_topic = "my-awesome-project / tomek"
expected_message = "Tomasz Kolek deleted branch tomek." expected_message = "Tomasz Kolek deleted branch tomek."
self.send_and_test_stream_message('push_hook__remove_branch', expected_topic, expected_message) self.check_webhook("push_hook__remove_branch", expected_topic, expected_message)
def test_add_tag_event_message(self) -> None: def test_add_tag_event_message(self) -> None:
expected_topic = "my-awesome-project" expected_topic = "my-awesome-project"
expected_message = "Tomasz Kolek pushed tag xyz." expected_message = "Tomasz Kolek pushed tag xyz."
self.send_and_test_stream_message( self.check_webhook(
'tag_push_hook__add_tag', "tag_push_hook__add_tag",
expected_topic, expected_topic,
expected_message, expected_message,
HTTP_X_GITLAB_EVENT="Tag Push Hook", HTTP_X_GITLAB_EVENT="Tag Push Hook",
@ -76,479 +84,393 @@ class GitlabHookTests(WebhookTestCase):
expected_topic = "my-awesome-project" expected_topic = "my-awesome-project"
expected_message = "Tomasz Kolek removed tag xyz." expected_message = "Tomasz Kolek removed tag xyz."
self.send_and_test_stream_message( self.check_webhook("tag_push_hook__remove_tag", expected_topic, expected_message)
'tag_push_hook__remove_tag',
expected_topic,
expected_message)
def test_create_issue_without_assignee_event_message(self) -> None: def test_create_issue_without_assignee_event_message(self) -> None:
expected_topic = "my-awesome-project / Issue #1 Issue title" expected_topic = "my-awesome-project / Issue #1 Issue title"
expected_message = "Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~" expected_message = "Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__issue_created_without_assignee', "issue_hook__issue_created_without_assignee", expected_topic, expected_message
expected_topic, )
expected_message)
def test_create_confidential_issue_without_assignee_event_message(self) -> None: def test_create_confidential_issue_without_assignee_event_message(self) -> None:
expected_subject = "testing / Issue #1 Testing" expected_subject = "testing / Issue #1 Testing"
expected_message = "Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nTesting\n~~~" expected_message = "Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nTesting\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__confidential_issue_created_without_assignee', "issue_hook__confidential_issue_created_without_assignee",
expected_subject, expected_subject,
expected_message) expected_message,
)
def test_create_issue_with_custom_topic_in_url(self) -> None: def test_create_issue_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek created [Issue #1 Issue title](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~" expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek created [Issue #1 Issue title](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1):\n\n~~~ quote\nIssue description\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__issue_created_without_assignee', "issue_hook__issue_created_without_assignee", expected_topic, expected_message
expected_topic, )
expected_message)
def test_create_issue_with_assignee_event_message(self) -> None: def test_create_issue_with_assignee_event_message(self) -> None:
expected_topic = "my-awesome-project / Issue #1 Issue title" expected_topic = "my-awesome-project / Issue #1 Issue title"
expected_message = "Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1) (assigned to Tomasz Kolek):\n\n~~~ quote\nIssue description\n~~~" expected_message = "Tomasz Kolek created [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1) (assigned to Tomasz Kolek):\n\n~~~ quote\nIssue description\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__issue_created_with_assignee', "issue_hook__issue_created_with_assignee", expected_topic, expected_message
expected_topic, )
expected_message)
def test_create_issue_with_two_assignees_event_message(self) -> None: def test_create_issue_with_two_assignees_event_message(self) -> None:
expected_subject = "Zulip GitLab Test / Issue #2 Zulip Test Issue 2" expected_subject = "Zulip GitLab Test / Issue #2 Zulip Test Issue 2"
expected_message = "Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds and eeshangarg):\n\n~~~ quote\nZulip Test Issue 2\n~~~" expected_message = "Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds and eeshangarg):\n\n~~~ quote\nZulip Test Issue 2\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__issue_created_with_two_assignees', "issue_hook__issue_created_with_two_assignees", expected_subject, expected_message
expected_subject, )
expected_message)
def test_create_issue_with_three_assignees_event_message(self) -> None: def test_create_issue_with_three_assignees_event_message(self) -> None:
expected_subject = "Zulip GitLab Test / Issue #2 Zulip Test Issue 2" expected_subject = "Zulip GitLab Test / Issue #2 Zulip Test Issue 2"
expected_message = "Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds, eeshangarg and timabbott):\n\n~~~ quote\nZulip Test Issue 2\n~~~" expected_message = "Adam Birds created [Issue #2](https://gitlab.com/adambirds/zulip-gitlab-test/issues/2) (assigned to adambirds, eeshangarg and timabbott):\n\n~~~ quote\nZulip Test Issue 2\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__issue_created_with_three_assignees', "issue_hook__issue_created_with_three_assignees", expected_subject, expected_message
expected_subject, )
expected_message)
def test_create_confidential_issue_with_assignee_event_message(self) -> None: def test_create_confidential_issue_with_assignee_event_message(self) -> None:
expected_subject = "testing / Issue #2 Testing" expected_subject = "testing / Issue #2 Testing"
expected_message = "Joe Bloggs created [Issue #2](https://gitlab.example.co.uk/joe.bloggs/testing/issues/2) (assigned to joe.bloggs):\n\n~~~ quote\nTesting\n~~~" expected_message = "Joe Bloggs created [Issue #2](https://gitlab.example.co.uk/joe.bloggs/testing/issues/2) (assigned to joe.bloggs):\n\n~~~ quote\nTesting\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__confidential_issue_created_with_assignee', "issue_hook__confidential_issue_created_with_assignee",
expected_subject, expected_subject,
expected_message) expected_message,
)
def test_create_issue_with_hidden_comment_in_description(self) -> None: def test_create_issue_with_hidden_comment_in_description(self) -> None:
expected_topic = "public-repo / Issue #3 New Issue with hidden comment" expected_topic = "public-repo / Issue #3 New Issue with hidden comment"
expected_message = "Eeshan Garg created [Issue #3](https://gitlab.com/eeshangarg/public-repo/issues/3):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~" expected_message = "Eeshan Garg created [Issue #3](https://gitlab.com/eeshangarg/public-repo/issues/3):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__issue_created_with_hidden_comment_in_description', "issue_hook__issue_created_with_hidden_comment_in_description",
expected_topic, expected_topic,
expected_message) expected_message,
)
def test_create_confidential_issue_with_hidden_comment_in_description(self) -> None: def test_create_confidential_issue_with_hidden_comment_in_description(self) -> None:
expected_subject = "testing / Issue #1 Testing" expected_subject = "testing / Issue #1 Testing"
expected_message = "Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~" expected_message = "Joe Bloggs created [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1):\n\n~~~ quote\nThis description actually has a hidden comment in it!\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__confidential_issue_created_with_hidden_comment_in_description', "issue_hook__confidential_issue_created_with_hidden_comment_in_description",
expected_subject, expected_subject,
expected_message) expected_message,
)
def test_create_issue_with_null_description(self) -> None: def test_create_issue_with_null_description(self) -> None:
expected_topic = "my-awesome-project / Issue #7 Issue without description" expected_topic = "my-awesome-project / Issue #7 Issue without description"
expected_message = "Eeshan Garg created [Issue #7](https://gitlab.com/eeshangarg/my-awesome-project/issues/7)." expected_message = "Eeshan Garg created [Issue #7](https://gitlab.com/eeshangarg/my-awesome-project/issues/7)."
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__issue_opened_with_null_description', "issue_hook__issue_opened_with_null_description", expected_topic, expected_message
expected_topic, )
expected_message)
def test_update_issue_event_message(self) -> None: def test_update_issue_event_message(self) -> None:
expected_topic = "my-awesome-project / Issue #1 Issue title_new" expected_topic = "my-awesome-project / Issue #1 Issue title_new"
expected_message = "Tomasz Kolek updated [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." expected_message = "Tomasz Kolek updated [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)."
self.send_and_test_stream_message( self.check_webhook("issue_hook__issue_updated", expected_topic, expected_message)
'issue_hook__issue_updated',
expected_topic,
expected_message)
def test_update_confidential_issue_event_message(self) -> None: def test_update_confidential_issue_event_message(self) -> None:
expected_subject = "testing / Issue #1 Testing" expected_subject = "testing / Issue #1 Testing"
expected_message = "Joe Bloggs updated [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." expected_message = "Joe Bloggs updated [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)."
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__confidential_issue_updated', "issue_hook__confidential_issue_updated", expected_subject, expected_message
expected_subject, )
expected_message)
def test_update_issue_with_custom_topic_in_url(self) -> None: def test_update_issue_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek updated [Issue #1 Issue title_new](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek updated [Issue #1 Issue title_new](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)."
self.send_and_test_stream_message( self.check_webhook("issue_hook__issue_updated", expected_topic, expected_message)
'issue_hook__issue_updated',
expected_topic,
expected_message)
def test_close_issue_event_message(self) -> None: def test_close_issue_event_message(self) -> None:
expected_topic = "my-awesome-project / Issue #1 Issue title_new" expected_topic = "my-awesome-project / Issue #1 Issue title_new"
expected_message = "Tomasz Kolek closed [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." expected_message = "Tomasz Kolek closed [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)."
self.send_and_test_stream_message( self.check_webhook("issue_hook__issue_closed", expected_topic, expected_message)
'issue_hook__issue_closed',
expected_topic,
expected_message)
def test_close_confidential_issue_event_message(self) -> None: def test_close_confidential_issue_event_message(self) -> None:
expected_subject = "testing / Issue #1 Testing Test" expected_subject = "testing / Issue #1 Testing Test"
expected_message = "Joe Bloggs closed [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." expected_message = "Joe Bloggs closed [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)."
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__confidential_issue_closed', "issue_hook__confidential_issue_closed", expected_subject, expected_message
expected_subject, )
expected_message)
def test_reopen_issue_event_message(self) -> None: def test_reopen_issue_event_message(self) -> None:
expected_topic = "my-awesome-project / Issue #1 Issue title_new" expected_topic = "my-awesome-project / Issue #1 Issue title_new"
expected_message = "Tomasz Kolek reopened [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)." expected_message = "Tomasz Kolek reopened [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)."
self.send_and_test_stream_message( self.check_webhook("issue_hook__issue_reopened", expected_topic, expected_message)
'issue_hook__issue_reopened',
expected_topic,
expected_message)
def test_reopen_confidential_issue_event_message(self) -> None: def test_reopen_confidential_issue_event_message(self) -> None:
expected_subject = "testing / Issue #1 Testing Test" expected_subject = "testing / Issue #1 Testing Test"
expected_message = "Joe Bloggs reopened [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)." expected_message = "Joe Bloggs reopened [Issue #1](https://gitlab.example.co.uk/joe.bloggs/testing/issues/1)."
self.send_and_test_stream_message( self.check_webhook(
'issue_hook__confidential_issue_reopened', "issue_hook__confidential_issue_reopened", expected_subject, expected_message
expected_subject, )
expected_message)
def test_note_commit_event_message(self) -> None: def test_note_commit_event_message(self) -> None:
expected_topic = "my-awesome-project" expected_topic = "my-awesome-project"
expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7#note_14169211) on [66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7):\n~~~ quote\nnice commit\n~~~" expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7#note_14169211) on [66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7):\n~~~ quote\nnice commit\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__commit_note", expected_topic, expected_message)
'note_hook__commit_note',
expected_topic,
expected_message)
def test_note_merge_request_event_message(self) -> None: def test_note_merge_request_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #1 Tomek" expected_topic = "my-awesome-project / MR #1 Tomek"
expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~" expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__merge_request_note", expected_topic, expected_message)
'note_hook__merge_request_note',
expected_topic,
expected_message)
def test_note_merge_request_event_message_without_merge_request_title(self) -> None: def test_note_merge_request_event_message_without_merge_request_title(self) -> None:
expected_topic = "my-awesome-project / MR #1" expected_topic = "my-awesome-project / MR #1"
expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~" expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~"
self.url = self.build_webhook_url(use_merge_request_title="false") # To keep things as valid JSON. self.url = self.build_webhook_url(use_merge_request_title="false") # To keep things as valid JSON.
self.send_and_test_stream_message( self.check_webhook("note_hook__merge_request_note", expected_topic, expected_message)
'note_hook__merge_request_note',
expected_topic,
expected_message)
def test_note_merge_request_with_custom_topic_in_url(self) -> None: def test_note_merge_request_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1 Tomek](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~" expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1#note_14171860) on [MR #1 Tomek](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/1):\n\n~~~ quote\nNice merge request!\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__merge_request_note", expected_topic, expected_message)
'note_hook__merge_request_note',
expected_topic,
expected_message)
def test_note_issue_event_message(self) -> None: def test_note_issue_event_message(self) -> None:
expected_topic = "my-awesome-project / Issue #2 abc" expected_topic = "my-awesome-project / Issue #2 abc"
expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~" expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__issue_note", expected_topic, expected_message)
'note_hook__issue_note',
expected_topic,
expected_message)
def test_note_confidential_issue_event_message(self) -> None: def test_note_confidential_issue_event_message(self) -> None:
expected_subject = "Test / Issue #3 Test" expected_subject = "Test / Issue #3 Test"
expected_message = "Joe Bloggs [commented](https://gitlab.com/joebloggs/test/issues/3#note_101638770) on [Issue #3](https://gitlab.com/joebloggs/test/issues/3):\n\n~~~ quote\nTest\n~~~" expected_message = "Joe Bloggs [commented](https://gitlab.com/joebloggs/test/issues/3#note_101638770) on [Issue #3](https://gitlab.com/joebloggs/test/issues/3):\n\n~~~ quote\nTest\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__confidential_issue_note", expected_subject, expected_message)
'note_hook__confidential_issue_note',
expected_subject,
expected_message)
def test_note_issue_with_custom_topic_in_url(self) -> None: def test_note_issue_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2 abc](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~" expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2#note_14172057) on [Issue #2 abc](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/2):\n\n~~~ quote\nNice issue\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__issue_note", expected_topic, expected_message)
'note_hook__issue_note',
expected_topic,
expected_message)
def test_note_snippet_event_message(self) -> None: def test_note_snippet_event_message(self) -> None:
expected_topic = "my-awesome-project / Snippet #2 test" expected_topic = "my-awesome-project / Snippet #2 test"
expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~" expected_message = "Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__snippet_note", expected_topic, expected_message)
'note_hook__snippet_note',
expected_topic,
expected_message)
def test_note_snippet_with_custom_topic_in_url(self) -> None: def test_note_snippet_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2 test](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~" expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek [commented](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2#note_14172058) on [Snippet #2 test](https://gitlab.com/tomaszkolek0/my-awesome-project/snippets/2):\n\n~~~ quote\nNice snippet\n~~~"
self.send_and_test_stream_message( self.check_webhook("note_hook__snippet_note", expected_topic, expected_message)
'note_hook__snippet_note',
expected_topic,
expected_message)
def test_merge_request_created_without_assignee_event_message(self) -> None: def test_merge_request_created_without_assignee_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #2 NEW MR" expected_topic = "my-awesome-project / MR #2 NEW MR"
expected_message = "Tomasz Kolek created [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" expected_message = "Tomasz Kolek created [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_created_without_assignee', "merge_request_hook__merge_request_created_without_assignee",
expected_topic, expected_topic,
expected_message) expected_message,
)
def test_merge_request_created_with_custom_topic_in_url(self) -> None: def test_merge_request_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek created [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek created [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_created_without_assignee', "merge_request_hook__merge_request_created_without_assignee",
expected_topic, expected_topic,
expected_message) expected_message,
)
def test_merge_request_created_with_assignee_event_message(self) -> None: def test_merge_request_created_with_assignee_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #3 New Merge Request" expected_topic = "my-awesome-project / MR #3 New Merge Request"
expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_created_with_assignee', "merge_request_hook__merge_request_created_with_assignee",
expected_topic, expected_topic,
expected_message) expected_message,
)
def test_merge_request_closed_event_message(self) -> None: def test_merge_request_closed_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #2 NEW MR" expected_topic = "my-awesome-project / MR #2 NEW MR"
expected_message = "Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." expected_message = "Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)."
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_closed', "merge_request_hook__merge_request_closed", expected_topic, expected_message
expected_topic, )
expected_message)
def test_merge_request_closed_event_message_without_using_title(self) -> None: def test_merge_request_closed_event_message_without_using_title(self) -> None:
expected_topic = "my-awesome-project / MR #2" expected_topic = "my-awesome-project / MR #2"
expected_message = "Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." expected_message = "Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)."
self.url = self.build_webhook_url(use_merge_request_title="false") self.url = self.build_webhook_url(use_merge_request_title="false")
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_closed', "merge_request_hook__merge_request_closed", expected_topic, expected_message
expected_topic, )
expected_message)
def test_merge_request_closed_with_custom_topic_in_url(self) -> None: def test_merge_request_closed_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek closed [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek closed [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)."
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_closed', "merge_request_hook__merge_request_closed", expected_topic, expected_message
expected_topic, )
expected_message)
def test_merge_request_reopened_event_message(self) -> None: def test_merge_request_reopened_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #1 Update the README with author ..." expected_topic = "my-awesome-project / MR #1 Update the README with author ..."
expected_message = "Eeshan Garg reopened [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)." expected_message = "Eeshan Garg reopened [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)."
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_reopened', "merge_request_hook__merge_request_reopened", expected_topic, expected_message
expected_topic, )
expected_message)
def test_merge_request_approved_event_message(self) -> None: def test_merge_request_approved_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #1 Update the README with author ..." expected_topic = "my-awesome-project / MR #1 Update the README with author ..."
expected_message = "Eeshan Garg approved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)." expected_message = "Eeshan Garg approved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)."
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_approved', "merge_request_hook__merge_request_approved", expected_topic, expected_message
expected_topic, )
expected_message)
def test_merge_request_updated_event_message(self) -> None: def test_merge_request_updated_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #3 New Merge Request" expected_topic = "my-awesome-project / MR #3 New Merge Request"
expected_message = "Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\nupdated desc\n~~~" expected_message = "Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\nupdated desc\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_updated', "merge_request_hook__merge_request_updated", expected_topic, expected_message
expected_topic, )
expected_message)
def test_merge_request_added_commit_event_message(self) -> None: def test_merge_request_added_commit_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #3 New Merge Request" expected_topic = "my-awesome-project / MR #3 New Merge Request"
expected_message = "Tomasz Kolek added commit(s) to [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)." expected_message = "Tomasz Kolek added commit(s) to [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)."
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_added_commit', "merge_request_hook__merge_request_added_commit", expected_topic, expected_message
expected_topic, )
expected_message)
def test_merge_request_merged_event_message(self) -> None: def test_merge_request_merged_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #3 New Merge Request" expected_topic = "my-awesome-project / MR #3 New Merge Request"
expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)." expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)."
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_merged', "merge_request_hook__merge_request_merged", expected_topic, expected_message
expected_topic, )
expected_message)
def test_wiki_page_opened_event_message(self) -> None: def test_wiki_page_opened_event_message(self) -> None:
expected_topic = "my-awesome-project" expected_topic = "my-awesome-project"
expected_message = "Tomasz Kolek created [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." expected_message = "Tomasz Kolek created [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)."
self.send_and_test_stream_message( self.check_webhook("wiki_page_hook__wiki_page_opened", expected_topic, expected_message)
'wiki_page_hook__wiki_page_opened',
expected_topic,
expected_message)
def test_wiki_page_edited_event_message(self) -> None: def test_wiki_page_edited_event_message(self) -> None:
expected_topic = "my-awesome-project" expected_topic = "my-awesome-project"
expected_message = "Tomasz Kolek updated [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." expected_message = "Tomasz Kolek updated [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)."
self.send_and_test_stream_message( self.check_webhook("wiki_page_hook__wiki_page_edited", expected_topic, expected_message)
'wiki_page_hook__wiki_page_edited',
expected_topic,
expected_message)
def test_build_created_event_message(self) -> None: def test_build_created_event_message(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "Build job_name from test stage was created." expected_message = "Build job_name from test stage was created."
self.send_and_test_stream_message( self.check_webhook(
'build_created', "build_created", expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Job Hook",
expected_topic,
expected_message,
HTTP_X_GITLAB_EVENT="Job Hook",
) )
def test_build_started_event_message(self) -> None: def test_build_started_event_message(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "Build job_name from test stage started." expected_message = "Build job_name from test stage started."
self.send_and_test_stream_message( self.check_webhook(
'build_started', "build_started", expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Job Hook",
expected_topic,
expected_message,
HTTP_X_GITLAB_EVENT="Job Hook",
) )
def test_build_succeeded_event_message(self) -> None: def test_build_succeeded_event_message(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "Build job_name from test stage changed status to success." expected_message = "Build job_name from test stage changed status to success."
self.send_and_test_stream_message( self.check_webhook(
'build_succeeded', "build_succeeded", expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Job Hook",
expected_topic,
expected_message,
HTTP_X_GITLAB_EVENT="Job Hook",
) )
def test_build_created_event_message_legacy_event_name(self) -> None: def test_build_created_event_message_legacy_event_name(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "Build job_name from test stage was created." expected_message = "Build job_name from test stage was created."
self.send_and_test_stream_message( self.check_webhook(
'build_created', "build_created", expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Build Hook",
expected_topic,
expected_message,
HTTP_X_GITLAB_EVENT="Build Hook",
) )
def test_build_started_event_message_legacy_event_name(self) -> None: def test_build_started_event_message_legacy_event_name(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "Build job_name from test stage started." expected_message = "Build job_name from test stage started."
self.send_and_test_stream_message( self.check_webhook(
'build_started', "build_started", expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Build Hook",
expected_topic,
expected_message,
HTTP_X_GITLAB_EVENT="Build Hook",
) )
def test_build_succeeded_event_message_legacy_event_name(self) -> None: def test_build_succeeded_event_message_legacy_event_name(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "Build job_name from test stage changed status to success." expected_message = "Build job_name from test stage changed status to success."
self.send_and_test_stream_message( self.check_webhook(
'build_succeeded', "build_succeeded", expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Build Hook",
expected_topic,
expected_message,
HTTP_X_GITLAB_EVENT="Build Hook",
) )
def test_pipeline_succeeded_with_artifacts_event_message(self) -> None: def test_pipeline_succeeded_with_artifacts_event_message(self) -> None:
expected_topic = "onlysomeproject / test/links-in-zulip-pipeline-message" expected_topic = "onlysomeproject / test/links-in-zulip-pipeline-message"
expected_message = "[Pipeline (22668)](https://gitlab.example.com/group1/onlysomeproject/pipelines/22668) changed status to success with build(s):\n* [cleanup:cleanup docker image](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58592) - success\n* [pages](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58591) - success\n * built artifact: *artifacts.zip* [[Browse](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58591/artifacts/browse)|[Download](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58591/artifacts/download)]\n* [black+pytest:future environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58590) - success\n* [docs:anaconda environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58589) - success\n * built artifact: *sphinx-docs.zip* [[Browse](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58589/artifacts/browse)|[Download](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58589/artifacts/download)]\n* [pytest:current environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58588) - success\n* [black:current environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58587) - success\n* [setup:docker image](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58586) - success." expected_message = "[Pipeline (22668)](https://gitlab.example.com/group1/onlysomeproject/pipelines/22668) changed status to success with build(s):\n* [cleanup:cleanup docker image](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58592) - success\n* [pages](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58591) - success\n * built artifact: *artifacts.zip* [[Browse](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58591/artifacts/browse)|[Download](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58591/artifacts/download)]\n* [black+pytest:future environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58590) - success\n* [docs:anaconda environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58589) - success\n * built artifact: *sphinx-docs.zip* [[Browse](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58589/artifacts/browse)|[Download](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58589/artifacts/download)]\n* [pytest:current environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58588) - success\n* [black:current environment](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58587) - success\n* [setup:docker image](https://gitlab.example.com/group1/onlysomeproject/-/jobs/58586) - success."
self.send_and_test_stream_message( self.check_webhook(
'pipeline_hook__pipline_succeeded_with_artifacts', "pipeline_hook__pipline_succeeded_with_artifacts", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_pipeline_succeeded_event_message(self) -> None: def test_pipeline_succeeded_event_message(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "[Pipeline (4414206)](https://gitlab.com/TomaszKolek/my-awesome-project/pipelines/4414206) changed status to success with build(s):\n* [job_name2](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541113) - success\n* [job_name](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541112) - success." expected_message = "[Pipeline (4414206)](https://gitlab.com/TomaszKolek/my-awesome-project/pipelines/4414206) changed status to success with build(s):\n* [job_name2](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541113) - success\n* [job_name](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541112) - success."
self.send_and_test_stream_message( self.check_webhook(
'pipeline_hook__pipeline_succeeded', "pipeline_hook__pipeline_succeeded", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_pipeline_started_event_message(self) -> None: def test_pipeline_started_event_message(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "[Pipeline (4414206)](https://gitlab.com/TomaszKolek/my-awesome-project/pipelines/4414206) started with build(s):\n* [job_name](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541112) - running\n* [job_name2](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541113) - pending." expected_message = "[Pipeline (4414206)](https://gitlab.com/TomaszKolek/my-awesome-project/pipelines/4414206) started with build(s):\n* [job_name](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541112) - running\n* [job_name2](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541113) - pending."
self.send_and_test_stream_message( self.check_webhook(
'pipeline_hook__pipeline_started', "pipeline_hook__pipeline_started", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_pipeline_pending_event_message(self) -> None: def test_pipeline_pending_event_message(self) -> None:
expected_topic = "my-awesome-project / master" expected_topic = "my-awesome-project / master"
expected_message = "[Pipeline (4414206)](https://gitlab.com/TomaszKolek/my-awesome-project/pipelines/4414206) was created with build(s):\n* [job_name2](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541113) - pending\n* [job_name](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541112) - created." expected_message = "[Pipeline (4414206)](https://gitlab.com/TomaszKolek/my-awesome-project/pipelines/4414206) was created with build(s):\n* [job_name2](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541113) - pending\n* [job_name](https://gitlab.com/TomaszKolek/my-awesome-project/-/jobs/4541112) - created."
self.send_and_test_stream_message( self.check_webhook(
'pipeline_hook__pipeline_pending', "pipeline_hook__pipeline_pending", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_issue_type_test_payload(self) -> None: def test_issue_type_test_payload(self) -> None:
expected_topic = 'public-repo' expected_topic = 'public-repo'
expected_message = "Webhook for **public-repo** has been configured successfully! :tada:" expected_message = "Webhook for **public-repo** has been configured successfully! :tada:"
self.send_and_test_stream_message( self.check_webhook(
'test_hook__issue_test_payload', "test_hook__issue_test_payload", expected_topic, expected_message,
expected_topic,
expected_message,
) )
@patch('zerver.lib.webhooks.common.check_send_webhook_message') @patch('zerver.lib.webhooks.common.check_send_webhook_message')
@ -572,85 +494,66 @@ class GitlabHookTests(WebhookTestCase):
def test_job_hook_event(self) -> None: def test_job_hook_event(self) -> None:
expected_topic = "gitlab_test / gitlab-script-trigger" expected_topic = "gitlab_test / gitlab-script-trigger"
expected_message = "Build test from test stage was created." expected_message = "Build test from test stage was created."
self.send_and_test_stream_message( self.check_webhook("job_hook__build_created", expected_topic, expected_message)
'job_hook__build_created',
expected_topic,
expected_message)
def test_job_hook_event_topic(self) -> None: def test_job_hook_event_topic(self) -> None:
self.url = self.build_webhook_url(topic="provided topic") self.url = self.build_webhook_url(topic="provided topic")
expected_topic = "provided topic" expected_topic = "provided topic"
expected_message = "[[gitlab_test](http://192.168.64.1:3005/gitlab-org/gitlab-test)] Build test from test stage was created." expected_message = "[[gitlab_test](http://192.168.64.1:3005/gitlab-org/gitlab-test)] Build test from test stage was created."
self.send_and_test_stream_message( self.check_webhook("job_hook__build_created", expected_topic, expected_message)
'job_hook__build_created',
expected_topic,
expected_message)
def test_system_push_event_message(self) -> None: def test_system_push_event_message(self) -> None:
expected_topic = "gitlab / master" expected_topic = "gitlab / master"
expected_message = "John Smith [pushed](http://test.example.com/gitlab/gitlab/compare/95790bf891e76fee5e1747ab589903a6a1f80f22...da1560886d4f094c3e6c9ef40349f7d38b5d27d7) 1 commit to branch master. Commits by Test User (1).\n\n* Add simple search to projects in public area ([c5feabd](https://test.example.com/gitlab/gitlab/-/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428))" expected_message = "John Smith [pushed](http://test.example.com/gitlab/gitlab/compare/95790bf891e76fee5e1747ab589903a6a1f80f22...da1560886d4f094c3e6c9ef40349f7d38b5d27d7) 1 commit to branch master. Commits by Test User (1).\n\n* Add simple search to projects in public area ([c5feabd](https://test.example.com/gitlab/gitlab/-/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428))"
self.send_and_test_stream_message('system_hook__push_hook', expected_topic, expected_message) self.check_webhook("system_hook__push_hook", expected_topic, expected_message)
def test_system_merge_request_created_without_assignee_event_message(self) -> None: def test_system_merge_request_created_without_assignee_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #2 NEW MR" expected_topic = "my-awesome-project / MR #2 NEW MR"
expected_message = "Tomasz Kolek created [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" expected_message = "Tomasz Kolek created [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'system_hook__merge_request_created_without_assignee', "system_hook__merge_request_created_without_assignee", expected_topic, expected_message
expected_topic, )
expected_message)
def test_system_merge_request_created_with_custom_topic_in_url(self) -> None: def test_system_merge_request_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek created [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek created [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'system_hook__merge_request_created_without_assignee', "system_hook__merge_request_created_without_assignee", expected_topic, expected_message
expected_topic, )
expected_message)
def test_system_merge_request_created_with_assignee_event_message(self) -> None: def test_system_merge_request_created_with_assignee_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #3 New Merge Request" expected_topic = "my-awesome-project / MR #3 New Merge Request"
expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~" expected_message = "Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3) (assigned to Tomasz Kolek) from `tomek` to `master`:\n\n~~~ quote\ndescription of merge request\n~~~"
self.send_and_test_stream_message( self.check_webhook(
'system_hook__merge_request_created_with_assignee', "system_hook__merge_request_created_with_assignee", expected_topic, expected_message
expected_topic, )
expected_message)
def test_system_merge_request_closed_event_message(self) -> None: def test_system_merge_request_closed_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #2 NEW MR" expected_topic = "my-awesome-project / MR #2 NEW MR"
expected_message = "Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." expected_message = "Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)."
self.send_and_test_stream_message( self.check_webhook("system_hook__merge_request_closed", expected_topic, expected_message)
'system_hook__merge_request_closed',
expected_topic,
expected_message)
def test_system_merge_request_merged_event_message(self) -> None: def test_system_merge_request_merged_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #3 New Merge Request" expected_topic = "my-awesome-project / MR #3 New Merge Request"
expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)." expected_message = "Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)."
self.send_and_test_stream_message( self.check_webhook("system_hook__merge_request_merged", expected_topic, expected_message)
'system_hook__merge_request_merged',
expected_topic,
expected_message)
def test_system_merge_request_closed_with_custom_topic_in_url(self) -> None: def test_system_merge_request_closed_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek closed [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)." expected_message = "[[my-awesome-project](https://gitlab.com/tomaszkolek0/my-awesome-project)] Tomasz Kolek closed [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)."
self.send_and_test_stream_message( self.check_webhook("system_hook__merge_request_closed", expected_topic, expected_message)
'system_hook__merge_request_closed',
expected_topic,
expected_message)
def test_merge_request_unapproved_event_message(self) -> None: def test_merge_request_unapproved_event_message(self) -> None:
expected_topic = "my-awesome-project / MR #1 Update the README with author ..." expected_topic = "my-awesome-project / MR #1 Update the README with author ..."
expected_message = "Eeshan Garg unapproved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)." expected_message = "Eeshan Garg unapproved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)."
self.send_and_test_stream_message( self.check_webhook(
'merge_request_hook__merge_request_unapproved', "merge_request_hook__merge_request_unapproved", expected_topic, expected_message
expected_topic, )
expected_message)

View File

@ -14,8 +14,8 @@ class GocdHookTests(WebhookTestCase):
"/go/tab/pipeline/history/pipelineName)\n" "/go/tab/pipeline/history/pipelineName)\n"
"Comment: my hola mundo changes") "Comment: my hola mundo changes")
self.send_and_test_stream_message( self.check_webhook(
'pipeline', "pipeline",
self.TOPIC, self.TOPIC,
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
@ -28,8 +28,8 @@ class GocdHookTests(WebhookTestCase):
"/go/tab/pipeline/history/pipelineName)\n" "/go/tab/pipeline/history/pipelineName)\n"
"Comment: my hola mundo changes") "Comment: my hola mundo changes")
self.send_and_test_stream_message( self.check_webhook(
'pipeline_failed', "pipeline_failed",
self.TOPIC, self.TOPIC,
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",

View File

@ -14,20 +14,20 @@ class GogsHookTests(WebhookTestCase):
expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1). expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1).
* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""" * Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))"""
self.send_and_test_stream_message('push', expected_topic, expected_message) self.check_webhook("push", expected_topic, expected_message)
def test_push_multiple_committers(self) -> None: def test_push_multiple_committers(self) -> None:
commit_info = '* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' commit_info = '* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n'
expected_topic = "try-git / master" expected_topic = "try-git / master"
expected_message = f"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{commit_info}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""" expected_message = f"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{commit_info}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))"""
self.send_and_test_stream_message('push__commits_multiple_committers', expected_topic, expected_message) self.check_webhook("push__commits_multiple_committers", expected_topic, expected_message)
def test_push_multiple_committers_filtered_by_branches(self) -> None: def test_push_multiple_committers_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
commit_info = '* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' commit_info = '* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n'
expected_topic = "try-git / master" expected_topic = "try-git / master"
expected_message = f"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{commit_info}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""" expected_message = f"""john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 2 commits to branch master. Commits by Benjamin (1) and John (1).\n\n{commit_info}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))"""
self.send_and_test_stream_message('push__commits_multiple_committers', expected_topic, expected_message) self.check_webhook("push__commits_multiple_committers", expected_topic, expected_message)
def test_push_filtered_by_branches(self) -> None: def test_push_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
@ -35,106 +35,106 @@ class GogsHookTests(WebhookTestCase):
expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1). expected_message = """john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 1 commit to branch master. Commits by John (1).
* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""" * Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))"""
self.send_and_test_stream_message('push', expected_topic, expected_message) self.check_webhook("push", expected_topic, expected_message)
def test_push_commits_more_than_limits(self) -> None: def test_push_commits_more_than_limits(self) -> None:
expected_topic = "try-git / master" expected_topic = "try-git / master"
commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n" commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n"
expected_message = f"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{commits_info * COMMITS_LIMIT}[and {30 - COMMITS_LIMIT} more commit(s)]" expected_message = f"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{commits_info * COMMITS_LIMIT}[and {30 - COMMITS_LIMIT} more commit(s)]"
self.send_and_test_stream_message('push__commits_more_than_limits', expected_topic, expected_message) self.check_webhook("push__commits_more_than_limits", expected_topic, expected_message)
def test_push_commits_more_than_limits_filtered_by_branches(self) -> None: def test_push_commits_more_than_limits_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development') self.url = self.build_webhook_url(branches='master,development')
expected_topic = "try-git / master" expected_topic = "try-git / master"
commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n" commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n"
expected_message = f"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{commits_info * COMMITS_LIMIT}[and {30 - COMMITS_LIMIT} more commit(s)]" expected_message = f"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{commits_info * COMMITS_LIMIT}[and {30 - COMMITS_LIMIT} more commit(s)]"
self.send_and_test_stream_message('push__commits_more_than_limits', expected_topic, expected_message) self.check_webhook("push__commits_more_than_limits", expected_topic, expected_message)
def test_new_branch(self) -> None: def test_new_branch(self) -> None:
expected_topic = "try-git / my_feature" expected_topic = "try-git / my_feature"
expected_message = "john created [my_feature](http://localhost:3000/john/try-git/src/my_feature) branch." expected_message = "john created [my_feature](http://localhost:3000/john/try-git/src/my_feature) branch."
self.send_and_test_stream_message('create__branch', expected_topic, expected_message) self.check_webhook("create__branch", expected_topic, expected_message)
def test_pull_request_opened(self) -> None: def test_pull_request_opened(self) -> None:
expected_topic = "try-git / PR #1 Title Text for Pull Request" expected_topic = "try-git / PR #1 Title Text for Pull Request"
expected_message = """john opened [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" expected_message = """john opened [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`."""
self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) self.check_webhook("pull_request__opened", expected_topic, expected_message)
def test_pull_request_opened_with_custom_topic_in_url(self) -> None: def test_pull_request_opened_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications') self.url = self.build_webhook_url(topic='notifications')
expected_topic = "notifications" expected_topic = "notifications"
expected_message = """john opened [PR #1 Title Text for Pull Request](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" expected_message = """john opened [PR #1 Title Text for Pull Request](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`."""
self.send_and_test_stream_message('pull_request__opened', expected_topic, expected_message) self.check_webhook("pull_request__opened", expected_topic, expected_message)
def test_pull_request_closed(self) -> None: def test_pull_request_closed(self) -> None:
expected_topic = "try-git / PR #1 Title Text for Pull Request" expected_topic = "try-git / PR #1 Title Text for Pull Request"
expected_message = """john closed [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`.""" expected_message = """john closed [PR #1](http://localhost:3000/john/try-git/pulls/1) from `feature` to `master`."""
self.send_and_test_stream_message('pull_request__closed', expected_topic, expected_message) self.check_webhook("pull_request__closed", expected_topic, expected_message)
def test_pull_request_merged(self) -> None: def test_pull_request_merged(self) -> None:
expected_topic = "try-git / PR #2 Title Text for Pull Request" expected_topic = "try-git / PR #2 Title Text for Pull Request"
expected_message = """john merged [PR #2](http://localhost:3000/john/try-git/pulls/2) from `feature` to `master`.""" expected_message = """john merged [PR #2](http://localhost:3000/john/try-git/pulls/2) from `feature` to `master`."""
self.send_and_test_stream_message('pull_request__merged', expected_topic, expected_message) self.check_webhook("pull_request__merged", expected_topic, expected_message)
def test_pull_request_reopened(self) -> None: def test_pull_request_reopened(self) -> None:
expected_topic = "test / PR #1349 reopened" expected_topic = "test / PR #1349 reopened"
expected_message = """kostekIV reopened [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" expected_message = """kostekIV reopened [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__reopened', expected_topic, expected_message) self.check_webhook("pull_request__reopened", expected_topic, expected_message)
def test_pull_request_edited(self) -> None: def test_pull_request_edited(self) -> None:
expected_topic = "test / PR #1349 Test" expected_topic = "test / PR #1349 Test"
expected_message = """kostekIV edited [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" expected_message = """kostekIV edited [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__edited', expected_topic, expected_message) self.check_webhook("pull_request__edited", expected_topic, expected_message)
def test_pull_request_assigned(self) -> None: def test_pull_request_assigned(self) -> None:
expected_topic = "test / PR #1349 Test" expected_topic = "test / PR #1349 Test"
expected_message = """kostekIV assigned [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" expected_message = """kostekIV assigned [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__assigned', expected_topic, expected_message) self.check_webhook("pull_request__assigned", expected_topic, expected_message)
def test_pull_request_synchronized(self) -> None: def test_pull_request_synchronized(self) -> None:
expected_topic = "test / PR #1349 Test" expected_topic = "test / PR #1349 Test"
expected_message = """kostekIV synchronized [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`.""" expected_message = """kostekIV synchronized [PR #2](https://try.gogs.io/kostekIV/test/pulls/2) from `c` to `master`."""
self.send_and_test_stream_message('pull_request__synchronized', expected_topic, expected_message) self.check_webhook("pull_request__synchronized", expected_topic, expected_message)
def test_issues_opened(self) -> None: def test_issues_opened(self) -> None:
expected_topic = "test / Issue #3 New test issue" expected_topic = "test / Issue #3 New test issue"
expected_message = """kostekIV opened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~""" expected_message = """kostekIV opened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~"""
self.send_and_test_stream_message('issues__opened', expected_topic, expected_message) self.check_webhook("issues__opened", expected_topic, expected_message)
def test_issues_reopened(self) -> None: def test_issues_reopened(self) -> None:
expected_topic = "test / Issue #3 New test issue" expected_topic = "test / Issue #3 New test issue"
expected_message = """kostekIV reopened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~""" expected_message = """kostekIV reopened [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest\n~~~"""
self.send_and_test_stream_message('issues__reopened', expected_topic, expected_message) self.check_webhook("issues__reopened", expected_topic, expected_message)
def test_issues_edited(self) -> None: def test_issues_edited(self) -> None:
expected_topic = "test / Issue #3 New test issue" expected_topic = "test / Issue #3 New test issue"
expected_message = """kostekIV edited [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest edit\n~~~""" expected_message = """kostekIV edited [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest edit\n~~~"""
self.send_and_test_stream_message('issues__edited', expected_topic, expected_message) self.check_webhook("issues__edited", expected_topic, expected_message)
def test_issues_assignee(self) -> None: def test_issues_assignee(self) -> None:
expected_topic = "test / Issue #3 New test issue" expected_topic = "test / Issue #3 New test issue"
expected_message = """kostekIV assigned [Issue #3](https://try.gogs.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest\n~~~""" expected_message = """kostekIV assigned [Issue #3](https://try.gogs.io/kostekIV/test/issues/3) (assigned to kostekIV):\n\n~~~ quote\nTest\n~~~"""
self.send_and_test_stream_message('issues__assigned', expected_topic, expected_message) self.check_webhook("issues__assigned", expected_topic, expected_message)
def test_issues_closed(self) -> None: def test_issues_closed(self) -> None:
expected_topic = "test / Issue #3 New test issue" expected_topic = "test / Issue #3 New test issue"
expected_message = """kostekIV closed [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nClosed #3\n~~~""" expected_message = """kostekIV closed [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nClosed #3\n~~~"""
self.send_and_test_stream_message('issues__closed', expected_topic, expected_message) self.check_webhook("issues__closed", expected_topic, expected_message)
def test_issue_comment_new(self) -> None: def test_issue_comment_new(self) -> None:
expected_topic = "test / Issue #3 New test issue" expected_topic = "test / Issue #3 New test issue"
expected_message = """kostekIV [commented](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3635) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest comment\n~~~""" expected_message = """kostekIV [commented](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3635) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nTest comment\n~~~"""
self.send_and_test_stream_message('issue_comment__new', expected_topic, expected_message) self.check_webhook("issue_comment__new", expected_topic, expected_message)
def test_issue_comment_edited(self) -> None: def test_issue_comment_edited(self) -> None:
expected_topic = "test / Issue #3 New test issue" expected_topic = "test / Issue #3 New test issue"
expected_message = """kostekIV edited a [comment](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3634) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit comment\n~~~""" expected_message = """kostekIV edited a [comment](https://try.gogs.io/kostekIV/test/issues/3#issuecomment-3634) on [Issue #3](https://try.gogs.io/kostekIV/test/issues/3):\n\n~~~ quote\nedit comment\n~~~"""
self.send_and_test_stream_message('issue_comment__edited', expected_topic, expected_message) self.check_webhook("issue_comment__edited", expected_topic, expected_message)
def test_release_published(self) -> None: def test_release_published(self) -> None:
expected_topic = "zulip_test / v1.4 Title" expected_topic = "zulip_test / v1.4 Title"
expected_message = """cestrell published release [Title](https://try.gogs.io/cestrell/zulip_test) for tag v1.4.""" expected_message = """cestrell published release [Title](https://try.gogs.io/cestrell/zulip_test) for tag v1.4."""
self.send_and_test_stream_message('release__published', expected_topic, expected_message) self.check_webhook("release__published", expected_topic, expected_message)
@patch('zerver.webhooks.gogs.view.check_send_webhook_message') @patch('zerver.webhooks.gogs.view.check_send_webhook_message')
def test_push_filtered_by_branches_ignore(self, check_send_webhook_message_mock: MagicMock) -> None: def test_push_filtered_by_branches_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:

View File

@ -12,8 +12,12 @@ class GoSquaredHookTests(WebhookTestCase):
expected_topic = "GoSquared - requestb.in" expected_topic = "GoSquared - requestb.in"
expected_message = "[requestb.in](https://www.gosquared.com/now/GSN-595854-T) has 33 visitors online." expected_message = "[requestb.in](https://www.gosquared.com/now/GSN-595854-T) has 33 visitors online."
self.send_and_test_stream_message('traffic_spike', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "traffic_spike",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_chat_message(self) -> None: def test_chat_message(self) -> None:
expected_topic = "Live Chat Session - Zulip Chat" expected_topic = "Live Chat Session - Zulip Chat"
@ -23,8 +27,12 @@ class GoSquaredHookTests(WebhookTestCase):
content='Zulip is awesome!', content='Zulip is awesome!',
) )
self.send_and_test_stream_message('chat_message', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "chat_message",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("gosquared", fixture_name, file_type="json") return self.webhook_fixture_data("gosquared", fixture_name, file_type="json")

View File

@ -21,8 +21,12 @@ Someone is testing the alert notification within grafana.
""".strip() """.strip()
# use fixture named helloworld_hello # use fixture named helloworld_hello
self.send_and_test_stream_message('alert', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "alert",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_no_data_alert(self) -> None: def test_no_data_alert(self) -> None:
expected_topic = "[Alerting] No Data alert" expected_topic = "[Alerting] No Data alert"
@ -34,8 +38,12 @@ The panel has no data.
""".strip() """.strip()
# use fixture named helloworld_hello # use fixture named helloworld_hello
self.send_and_test_stream_message('no_data_alert', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "no_data_alert",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_no_message_alert(self) -> None: def test_no_message_alert(self) -> None:
expected_topic = "[Alerting] No Message alert" expected_topic = "[Alerting] No Message alert"
@ -46,8 +54,12 @@ The panel has no data.
""".strip() """.strip()
# use fixture named helloworld_hello # use fixture named helloworld_hello
self.send_and_test_stream_message('no_message_alert', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "no_message_alert",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("grafana", fixture_name, file_type="json") return self.webhook_fixture_data("grafana", fixture_name, file_type="json")

View File

@ -18,10 +18,9 @@ Hire Candidate Johnny Smith (ID: 19), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...) * **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...)
""".strip() """.strip()
self.send_and_test_stream_message('candidate_hired', self.check_webhook(
expected_topic, "candidate_hired", expected_topic, expected_message, content_type=self.CONTENT_TYPE
expected_message, )
content_type=self.CONTENT_TYPE)
def test_message_candidate_rejected(self) -> None: def test_message_candidate_rejected(self) -> None:
expected_topic = "Reject Candidate - 265788" expected_topic = "Reject Candidate - 265788"
@ -32,10 +31,9 @@ Reject Candidate Hector Porter (ID: 265788), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...) * **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...)
""".strip() """.strip()
self.send_and_test_stream_message('candidate_rejected', self.check_webhook(
expected_topic, "candidate_rejected", expected_topic, expected_message, content_type=self.CONTENT_TYPE
expected_message, )
content_type=self.CONTENT_TYPE)
def test_message_candidate_stage_change(self) -> None: def test_message_candidate_stage_change(self) -> None:
expected_topic = "Candidate Stage Change - 265772" expected_topic = "Candidate Stage Change - 265772"
@ -46,10 +44,12 @@ Candidate Stage Change Giuseppe Hurley (ID: 265772), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...), [Cover_Letter](https://prod-heroku.s3.amazonaws.com/...), [Attachment](https://prod-heroku.s3.amazonaws.com/...) * **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...), [Cover_Letter](https://prod-heroku.s3.amazonaws.com/...), [Attachment](https://prod-heroku.s3.amazonaws.com/...)
""".strip() """.strip()
self.send_and_test_stream_message('candidate_stage_change', self.check_webhook(
expected_topic, "candidate_stage_change",
expected_message, expected_topic,
content_type=self.CONTENT_TYPE) expected_message,
content_type=self.CONTENT_TYPE,
)
def test_message_prospect_created(self) -> None: def test_message_prospect_created(self) -> None:
expected_topic = "New Prospect Application - 968190" expected_topic = "New Prospect Application - 968190"
@ -60,10 +60,9 @@ New Prospect Application Trisha Troy (ID: 968190), applying for:
* **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...) * **Attachments**: [Resume](https://prod-heroku.s3.amazonaws.com/...)
""".strip() """.strip()
self.send_and_test_stream_message('prospect_created', self.check_webhook(
expected_topic, "prospect_created", expected_topic, expected_message, content_type=self.CONTENT_TYPE
expected_message, )
content_type=self.CONTENT_TYPE)
@patch('zerver.webhooks.greenhouse.view.check_send_webhook_message') @patch('zerver.webhooks.greenhouse.view.check_send_webhook_message')
def test_ping_message_ignore( def test_ping_message_ignore(

View File

@ -17,16 +17,24 @@ The content of the body goes here.
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('ticket_started', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "ticket_started",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket # This simulates the condition when a ticket
# is assigned to an agent. # is assigned to an agent.
def test_groove_ticket_assigned_agent_only(self) -> None: def test_groove_ticket_assigned_agent_only(self) -> None:
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com." expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com."
self.send_and_test_stream_message('ticket_assigned__agent_only', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "ticket_assigned__agent_only",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket # This simulates the condition when a ticket
# is assigned to an agent in a group. # is assigned to an agent in a group.
@ -34,16 +42,24 @@ The content of the body goes here.
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com from group2." expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (open) assigned to agent@example.com from group2."
self.send_and_test_stream_message('ticket_assigned__agent_and_group', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "ticket_assigned__agent_and_group",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket # This simulates the condition when a ticket
# is assigned to a group. # is assigned to a group.
def test_groove_ticket_assigned_group_only(self) -> None: def test_groove_ticket_assigned_group_only(self) -> None:
expected_topic = "notifications" expected_topic = "notifications"
expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (pending) assigned to group2." expected_message = "[#9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446) (pending) assigned to group2."
self.send_and_test_stream_message('ticket_assigned__group_only', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "ticket_assigned__group_only",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a ticket # This simulates the condition when a ticket
# is assigned to no one. # is assigned to no one.
@ -65,8 +81,12 @@ Hello , This is a reply from an agent to a ticket
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('agent_replied', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "agent_replied",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when a customer replied to a ticket. # This simulates the condition when a customer replied to a ticket.
def test_groove_customer_replied(self) -> None: def test_groove_customer_replied(self) -> None:
@ -79,8 +99,12 @@ Hello agent, thanks for getting back. This is how a reply from customer looks li
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('customer_replied', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_replied",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# This simulates the condition when an agent left a note. # This simulates the condition when an agent left a note.
def test_groove_note_added(self) -> None: def test_groove_note_added(self) -> None:
@ -93,8 +117,12 @@ This is a note added to a ticket
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('note_added', expected_topic, expected_message, self.check_webhook(
content_type="application/x-ww-form-urlencoded") "note_added",
expected_topic,
expected_message,
content_type="application/x-ww-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("groove", fixture_name, file_type="json") return self.webhook_fixture_data("groove", fixture_name, file_type="json")

View File

@ -10,8 +10,7 @@ class HarborHookTests(WebhookTestCase):
def test_push_image(self) -> None: def test_push_image(self) -> None:
expected_topic = "example/test" expected_topic = "example/test"
expected_message = """**admin** pushed image `example/test:latest`""" expected_message = """**admin** pushed image `example/test:latest`"""
self.send_and_test_stream_message( self.check_webhook("push_image", expected_topic, expected_message)
"push_image", expected_topic, expected_message)
@patch('zerver.lib.webhooks.common.check_send_webhook_message') @patch('zerver.lib.webhooks.common.check_send_webhook_message')
def test_delete_image_ignored( def test_delete_image_ignored(
@ -35,8 +34,7 @@ Image scan completed for `example/test:latest`. Vulnerabilities by severity:
* None: **131** * None: **131**
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook("scanning_completed", expected_topic, expected_message)
"scanning_completed", expected_topic, expected_message)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("harbor", fixture_name, file_type="json") return self.webhook_fixture_data("harbor", fixture_name, file_type="json")

View File

@ -12,30 +12,38 @@ class HelloSignHookTests(WebhookTestCase):
expected_topic = "NDA with Acme Co." expected_topic = "NDA with Acme Co."
expected_message = ("The `NDA with Acme Co.` document is awaiting the signature of " expected_message = ("The `NDA with Acme Co.` document is awaiting the signature of "
"Jack, and was just signed by Jill.") "Jack, and was just signed by Jill.")
self.send_and_test_stream_message('signatures', expected_topic, expected_message, self.check_webhook("signatures", expected_topic, expected_message, content_type=None)
content_type=None)
def test_signatures_message_signed_by_one(self) -> None: def test_signatures_message_signed_by_one(self) -> None:
expected_topic = "NDA with Acme Co." expected_topic = "NDA with Acme Co."
expected_message = ("The `NDA with Acme Co.` document was just signed by Jill.") expected_message = ("The `NDA with Acme Co.` document was just signed by Jill.")
self.send_and_test_stream_message('signatures_signed_by_one_signatory', self.check_webhook(
expected_topic, expected_message, "signatures_signed_by_one_signatory",
content_type=None) expected_topic,
expected_message,
content_type=None,
)
def test_signatures_message_with_four_signatories(self) -> None: def test_signatures_message_with_four_signatories(self) -> None:
expected_topic = "Signature doc" expected_topic = "Signature doc"
expected_message = ("The `Signature doc` document is awaiting the signature of " expected_message = ("The `Signature doc` document is awaiting the signature of "
"Eeshan Garg, John Smith, Jane Doe, and Stephen Strange.") "Eeshan Garg, John Smith, Jane Doe, and Stephen Strange.")
self.send_and_test_stream_message('signatures_with_four_signatories', expected_topic, expected_message, self.check_webhook(
content_type=None) "signatures_with_four_signatories", expected_topic, expected_message, content_type=None
)
def test_signatures_message_with_own_subject(self) -> None: def test_signatures_message_with_own_subject(self) -> None:
expected_topic = "Our own subject." expected_topic = "Our own subject."
self.url = self.build_webhook_url(topic=expected_topic) self.url = self.build_webhook_url(topic=expected_topic)
expected_message = ("The `NDA with Acme Co.` document is awaiting the signature of " expected_message = ("The `NDA with Acme Co.` document is awaiting the signature of "
"Jack, and was just signed by Jill.") "Jack, and was just signed by Jill.")
self.send_and_test_stream_message('signatures_with_own_subject', expected_topic, expected_message, self.check_webhook(
content_type=None, topic=expected_topic) "signatures_with_own_subject",
expected_topic,
expected_message,
content_type=None,
topic=expected_topic,
)
def get_body(self, fixture_name: str) -> Dict[str, str]: def get_body(self, fixture_name: str) -> Dict[str, str]:
return {"json": self.webhook_fixture_data("hellosign", fixture_name, file_type="json")} return {"json": self.webhook_fixture_data("hellosign", fixture_name, file_type="json")}

View File

@ -16,16 +16,24 @@ class HelloWorldHookTests(WebhookTestCase):
expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**" expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**"
# use fixture named helloworld_hello # use fixture named helloworld_hello
self.send_and_test_stream_message('hello', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "hello",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_goodbye_message(self) -> None: def test_goodbye_message(self) -> None:
expected_topic = "Hello World" expected_topic = "Hello World"
expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**"
# use fixture named helloworld_goodbye # use fixture named helloworld_goodbye
self.send_and_test_stream_message('goodbye', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "goodbye",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_pm_to_bot_owner(self) -> None: def test_pm_to_bot_owner(self) -> None:
# Note that this is really just a test for check_send_webhook_message # Note that this is really just a test for check_send_webhook_message
@ -52,8 +60,12 @@ class HelloWorldHookTests(WebhookTestCase):
self.url = self.build_webhook_url(topic=expected_topic) self.url = self.build_webhook_url(topic=expected_topic)
expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**" expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Goodbye](https://en.wikipedia.org/wiki/Goodbye)**"
self.send_and_test_stream_message('goodbye', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "goodbye",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("helloworld", fixture_name, file_type="json") return self.webhook_fixture_data("helloworld", fixture_name, file_type="json")

View File

@ -14,8 +14,12 @@ user@example.com deployed version 3eb5f44 of [sample-project](http://sample-proj
* Example User: Test commit for Deploy Hook 2 * Example User: Test commit for Deploy Hook 2
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('deploy', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "deploy",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_deployment_multiple_commits(self) -> None: def test_deployment_multiple_commits(self) -> None:
expected_topic = "sample-project" expected_topic = "sample-project"
@ -34,8 +38,12 @@ user@example.com deployed version 3eb5f44 of [sample-project](http://sample-proj
* Example User: Second test commit for Deploy Hook 2 * Example User: Second test commit for Deploy Hook 2
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('deploy_multiple_commits', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "deploy_multiple_commits",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("heroku", fixture_name, file_type="txt") return self.webhook_fixture_data("heroku", fixture_name, file_type="txt")

View File

@ -10,15 +10,23 @@ class HomeAssistantHookTests(WebhookTestCase):
expected_topic = "homeassistant" expected_topic = "homeassistant"
expected_message = "The sun will be shining today!" expected_message = "The sun will be shining today!"
self.send_and_test_stream_message('simplereq', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "simplereq",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_req_with_title(self) -> None: def test_req_with_title(self) -> None:
expected_topic = "Weather forecast" expected_topic = "Weather forecast"
expected_message = "It will be 30 degrees Celsius out there today!" expected_message = "It will be 30 degrees Celsius out there today!"
self.send_and_test_stream_message('reqwithtitle', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "reqwithtitle",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("homeassistant", fixture_name, file_type="json") return self.webhook_fixture_data("homeassistant", fixture_name, file_type="json")

View File

@ -9,12 +9,12 @@ class IFTTTHookTests(WebhookTestCase):
def test_ifttt_when_subject_and_body_are_correct(self) -> None: def test_ifttt_when_subject_and_body_are_correct(self) -> None:
expected_topic = "Email sent from email@email.com" expected_topic = "Email sent from email@email.com"
expected_message = "Email subject: Subject" expected_message = "Email subject: Subject"
self.send_and_test_stream_message('correct_subject_and_body', expected_topic, expected_message) self.check_webhook("correct_subject_and_body", expected_topic, expected_message)
def test_ifttt_when_topic_and_body_are_correct(self) -> None: def test_ifttt_when_topic_and_body_are_correct(self) -> None:
expected_topic = "Email sent from email@email.com" expected_topic = "Email sent from email@email.com"
expected_message = "Email subject: Subject" expected_message = "Email subject: Subject"
self.send_and_test_stream_message('correct_topic_and_body', expected_topic, expected_message) self.check_webhook("correct_topic_and_body", expected_topic, expected_message)
def test_ifttt_when_topic_is_missing(self) -> None: def test_ifttt_when_topic_is_missing(self) -> None:
self.url = self.build_webhook_url() self.url = self.build_webhook_url()

View File

@ -15,9 +15,12 @@ State changed to **Available**:
* **Timestamp**: Fri Dec 29 17:23:46 2017 * **Timestamp**: Fri Dec 29 17:23:46 2017
""".strip() """.strip()
self.send_and_test_stream_message('website_state_available', self.check_webhook(
expected_topic, expected_message, "website_state_available",
content_type="application/x-www-form-urlencoded") expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_website_state_not_responding_message(self) -> None: def test_website_state_not_responding_message(self) -> None:
expected_topic = "insping" expected_topic = "insping"
@ -28,9 +31,12 @@ State changed to **Not Responding**:
* **Timestamp**: Fri Dec 29 17:13:46 2017 * **Timestamp**: Fri Dec 29 17:13:46 2017
""".strip() """.strip()
self.send_and_test_stream_message('website_state_not_responding', self.check_webhook(
expected_topic, expected_message, "website_state_not_responding",
content_type="application/x-www-form-urlencoded") expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("insping", fixture_name, file_type="json") return self.webhook_fixture_data("insping", fixture_name, file_type="json")

View File

@ -23,19 +23,15 @@ New company **Kandra Labs** created:
* **User count**: 1 * **User count**: 1
* **Monthly spending**: 0 * **Monthly spending**: 0
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'company_created', "company_created", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_contact_added_email(self) -> None: def test_contact_added_email(self) -> None:
expected_topic = "Contact: Azure Bus from St. John's" expected_topic = "Contact: Azure Bus from St. John's"
expected_message = "New email jerryguitarist@gmail.com added to contact." expected_message = "New email jerryguitarist@gmail.com added to contact."
self.send_and_test_stream_message( self.check_webhook(
'contact_added_email', "contact_added_email", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_contact_created(self) -> None: def test_contact_created(self) -> None:
@ -46,10 +42,8 @@ New contact created:
* **Email**: aaron@zulip.com * **Email**: aaron@zulip.com
* **Location**: St. John's, Newfoundland and Labrador, Canada * **Location**: St. John's, Newfoundland and Labrador, Canada
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'contact_created', "contact_created", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_contact_signed_up(self) -> None: def test_contact_signed_up(self) -> None:
@ -59,73 +53,57 @@ Contact signed up:
* **Email**: iago@zulip.com * **Email**: iago@zulip.com
* **Location**: St. John's, Newfoundland and Labrador, Canada * **Location**: St. John's, Newfoundland and Labrador, Canada
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'contact_signed_up', "contact_signed_up", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_contact_tag_created(self) -> None: def test_contact_tag_created(self) -> None:
expected_topic = "Contact: Eeshan Garg" expected_topic = "Contact: Eeshan Garg"
expected_message = "Contact tagged with the `developer` tag." expected_message = "Contact tagged with the `developer` tag."
self.send_and_test_stream_message( self.check_webhook(
'contact_tag_created', "contact_tag_created", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_contact_tag_deleted(self) -> None: def test_contact_tag_deleted(self) -> None:
expected_topic = "Contact: Eeshan Garg" expected_topic = "Contact: Eeshan Garg"
expected_message = "The tag `developer` was removed from the contact." expected_message = "The tag `developer` was removed from the contact."
self.send_and_test_stream_message( self.check_webhook(
'contact_tag_deleted', "contact_tag_deleted", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_assigned(self) -> None: def test_conversation_admin_assigned(self) -> None:
expected_topic = "Lead: Eeshan Garg" expected_topic = "Lead: Eeshan Garg"
expected_message = "Tim Abbott assigned to conversation." expected_message = "Tim Abbott assigned to conversation."
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_assigned', "conversation_admin_assigned", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_opened(self) -> None: def test_conversation_admin_opened(self) -> None:
expected_topic = "Lead: Cordelia Lear" expected_topic = "Lead: Cordelia Lear"
expected_message = "Eeshan Garg opened the conversation." expected_message = "Eeshan Garg opened the conversation."
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_opened', "conversation_admin_opened", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_closed(self) -> None: def test_conversation_admin_closed(self) -> None:
expected_topic = "Lead: Eeshan Garg" expected_topic = "Lead: Eeshan Garg"
expected_message = "Cordelia Lear closed the conversation." expected_message = "Cordelia Lear closed the conversation."
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_closed', "conversation_admin_closed", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_snoozed(self) -> None: def test_conversation_admin_snoozed(self) -> None:
expected_topic = "Lead: Eeshan Garg" expected_topic = "Lead: Eeshan Garg"
expected_message = "Cordelia Lear snoozed the conversation." expected_message = "Cordelia Lear snoozed the conversation."
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_snoozed', "conversation_admin_snoozed", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_unsnoozed(self) -> None: def test_conversation_admin_unsnoozed(self) -> None:
expected_topic = "Lead: Eeshan Garg" expected_topic = "Lead: Eeshan Garg"
expected_message = "Cordelia Lear unsnoozed the conversation." expected_message = "Cordelia Lear unsnoozed the conversation."
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_unsnoozed', "conversation_admin_unsnoozed", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_replied(self) -> None: def test_conversation_admin_replied(self) -> None:
@ -137,10 +115,8 @@ Cordelia Lear replied to the conversation:
Hey Eeshan! How can I help? Hey Eeshan! How can I help?
``` ```
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_replied', "conversation_admin_replied", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_noted(self) -> None: def test_conversation_admin_noted(self) -> None:
@ -152,10 +128,8 @@ Cordelia Lear added a note to the conversation:
Talk to Tim about this user's query. Talk to Tim about this user's query.
``` ```
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_noted', "conversation_admin_noted", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_admin_single_created(self) -> None: def test_conversation_admin_single_created(self) -> None:
@ -167,10 +141,8 @@ Cordelia Lear initiated a conversation:
Hi Eeshan, What's up Hi Eeshan, What's up
``` ```
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'conversation_admin_single_created', "conversation_admin_single_created", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_user_created(self) -> None: def test_conversation_user_created(self) -> None:
@ -182,10 +154,8 @@ Rose Poodle from St. John's initiated a conversation:
Hello everyone! Hello everyone!
``` ```
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'conversation_user_created', "conversation_user_created", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_conversation_user_replied(self) -> None: def test_conversation_user_replied(self) -> None:
@ -197,19 +167,15 @@ Eeshan Garg replied to the conversation:
Well, I need some help getting access to a developer account. Well, I need some help getting access to a developer account.
``` ```
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'conversation_user_replied', "conversation_user_replied", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_event_created(self) -> None: def test_event_created(self) -> None:
expected_topic = "Events" expected_topic = "Events"
expected_message = "New event **invited-friend** created." expected_message = "New event **invited-friend** created."
self.send_and_test_stream_message( self.check_webhook(
'event_created', "event_created", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_user_created(self) -> None: def test_user_created(self) -> None:
@ -220,48 +186,38 @@ New user created:
* **Email**: aaron@zulip.com * **Email**: aaron@zulip.com
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'user_created', "user_created", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_user_deleted(self) -> None: def test_user_deleted(self) -> None:
self.send_and_test_stream_message( self.check_webhook(
'user_deleted', "user_deleted", "User: jerryguitarist@gmail.com", "User deleted.",
'User: jerryguitarist@gmail.com',
'User deleted.',
) )
def test_user_email_updated(self) -> None: def test_user_email_updated(self) -> None:
self.send_and_test_stream_message( self.check_webhook(
'user_email_updated', "user_email_updated",
'Contact: Azure Bus from St. John\'s', "Contact: Azure Bus from St. John's",
'User\'s email was updated to aaron@zulip.com.', "User's email was updated to aaron@zulip.com.",
) )
def test_user_tag_created(self) -> None: def test_user_tag_created(self) -> None:
self.send_and_test_stream_message( self.check_webhook(
'user_tag_created', "user_tag_created", "User: eeshangarg", "The tag `developer` was added to the user.",
'User: eeshangarg',
'The tag `developer` was added to the user.',
) )
def test_user_tag_deleted(self) -> None: def test_user_tag_deleted(self) -> None:
expected_topic = 'User: eeshangarg' expected_topic = 'User: eeshangarg'
expected_message = 'The tag `CSV Import - 2019-03-26 22:46:04 UTC` was removed from the user.' expected_message = 'The tag `CSV Import - 2019-03-26 22:46:04 UTC` was removed from the user.'
self.send_and_test_stream_message( self.check_webhook(
'user_tag_deleted', "user_tag_deleted", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_user_unsubscribed(self) -> None: def test_user_unsubscribed(self) -> None:
self.send_and_test_stream_message( self.check_webhook(
'user_unsubscribed', "user_unsubscribed", "Contact: Eeshan Garg", "User unsubscribed from emails.",
'Contact: Eeshan Garg',
'User unsubscribed from emails.',
) )
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:

View File

@ -33,8 +33,8 @@ Leo Franchi created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/
* **Priority**: Major * **Priority**: Major
* **Assignee**: no one * **Assignee**: no one
""".strip() """.strip()
self.send_and_test_stream_message('created_v1', expected_topic, expected_message) self.check_webhook("created_v1", expected_topic, expected_message)
self.send_and_test_stream_message('created_v2', expected_topic, expected_message) self.check_webhook("created_v2", expected_topic, expected_message)
def test_created_with_stream_with_spaces_escaped(self) -> None: def test_created_with_stream_with_spaces_escaped(self) -> None:
self.STREAM_NAME = quote('jira alerts') self.STREAM_NAME = quote('jira alerts')
@ -87,7 +87,7 @@ Leo Franchi created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/
* **Priority**: Major * **Priority**: Major
* **Assignee**: no one * **Assignee**: no one
""".strip() """.strip()
self.send_and_test_stream_message('created_v1', expected_topic, expected_message) self.check_webhook("created_v1", expected_topic, expected_message)
def test_created_with_unicode(self) -> None: def test_created_with_unicode(self) -> None:
expected_topic = "BUG-15: New bug with à hook" expected_topic = "BUG-15: New bug with à hook"
@ -97,8 +97,8 @@ Leo Franchià created [BUG-15: New bug with à hook](http://lfranchi.com:8080/br
* **Priority**: Major * **Priority**: Major
* **Assignee**: no one * **Assignee**: no one
""".strip() """.strip()
self.send_and_test_stream_message('created_with_unicode_v1', expected_topic, expected_message) self.check_webhook("created_with_unicode_v1", expected_topic, expected_message)
self.send_and_test_stream_message('created_with_unicode_v2', expected_topic, expected_message) self.check_webhook("created_with_unicode_v2", expected_topic, expected_message)
def test_created_assignee(self) -> None: def test_created_assignee(self) -> None:
expected_topic = "TEST-4: Test Created Assignee" expected_topic = "TEST-4: Test Created Assignee"
@ -108,8 +108,8 @@ Leonardo Franchi [Administrator] created [TEST-4: Test Created Assignee](https:/
* **Priority**: Major * **Priority**: Major
* **Assignee**: Leonardo Franchi [Administrator] * **Assignee**: Leonardo Franchi [Administrator]
""".strip() """.strip()
self.send_and_test_stream_message('created_assignee_v1', expected_topic, expected_message) self.check_webhook("created_assignee_v1", expected_topic, expected_message)
self.send_and_test_stream_message('created_assignee_v2', expected_topic, expected_message) self.check_webhook("created_assignee_v2", expected_topic, expected_message)
def test_commented(self) -> None: def test_commented(self) -> None:
expected_topic = "BUG-15: New bug with hook" expected_topic = "BUG-15: New bug with hook"
@ -120,8 +120,8 @@ Leo Franchi commented on [BUG-15: New bug with hook](http://lfranchi.com:8080/br
Adding a comment. Oh, what a comment it is! Adding a comment. Oh, what a comment it is!
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('commented_v1', expected_topic, expected_message) self.check_webhook("commented_v1", expected_topic, expected_message)
self.send_and_test_stream_message('commented_v2', expected_topic, expected_message) self.check_webhook("commented_v2", expected_topic, expected_message)
def test_commented_with_two_full_links(self) -> None: def test_commented_with_two_full_links(self) -> None:
expected_topic = "BUG-15: New bug with hook" expected_topic = "BUG-15: New bug with hook"
@ -132,7 +132,7 @@ Leo Franchi commented on [BUG-15: New bug with hook](http://lfranchi.com:8080/br
This is the [first link](https://google.com) and this is the [second link](https://google.com) and this is the end. This is the [first link](https://google.com) and this is the [second link](https://google.com) and this is the end.
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('commented_v2_with_two_full_links', expected_topic, expected_message) self.check_webhook("commented_v2_with_two_full_links", expected_topic, expected_message)
def test_comment_edited(self) -> None: def test_comment_edited(self) -> None:
expected_topic = "BUG-15: New bug with hook" expected_topic = "BUG-15: New bug with hook"
@ -143,49 +143,49 @@ Leo Franchi edited a comment on [BUG-15: New bug with hook](http://lfranchi.com:
Adding a comment. Oh, what a comment it is! Adding a comment. Oh, what a comment it is!
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('comment_edited_v2', expected_topic, expected_message) self.check_webhook("comment_edited_v2", expected_topic, expected_message)
def test_comment_deleted(self) -> None: def test_comment_deleted(self) -> None:
expected_topic = "TOM-1: New Issue" expected_topic = "TOM-1: New Issue"
expected_message = "Tomasz Kolek deleted a comment from [TOM-1: New Issue](https://zuliptomek.atlassian.net/browse/TOM-1) (assigned to **kolaszek@go2.pl**)." expected_message = "Tomasz Kolek deleted a comment from [TOM-1: New Issue](https://zuliptomek.atlassian.net/browse/TOM-1) (assigned to **kolaszek@go2.pl**)."
self.send_and_test_stream_message('comment_deleted_v2', expected_topic, expected_message) self.check_webhook("comment_deleted_v2", expected_topic, expected_message)
def test_commented_markup(self) -> None: def test_commented_markup(self) -> None:
expected_topic = "TEST-7: Testing of rich text" expected_topic = "TEST-7: Testing of rich text"
expected_message = """Leonardo Franchi [Administrator] commented on [TEST-7: Testing of rich text](https://zulipp.atlassian.net/browse/TEST-7):\n\n``` quote\nThis is a comment that likes to **exercise** a lot of _different_ `conventions` that `jira uses`.\r\n\r\n~~~\n\r\nthis code is not highlighted, but monospaced\r\n\n~~~\r\n\r\n~~~\n\r\ndef python():\r\n print "likes to be formatted"\r\n\n~~~\r\n\r\n[http://www.google.com](http://www.google.com) is a bare link, and [Google](http://www.google.com) is given a title.\r\n\r\nThanks!\r\n\r\n~~~ quote\n\r\nSomeone said somewhere\r\n\n~~~\n```""" expected_message = """Leonardo Franchi [Administrator] commented on [TEST-7: Testing of rich text](https://zulipp.atlassian.net/browse/TEST-7):\n\n``` quote\nThis is a comment that likes to **exercise** a lot of _different_ `conventions` that `jira uses`.\r\n\r\n~~~\n\r\nthis code is not highlighted, but monospaced\r\n\n~~~\r\n\r\n~~~\n\r\ndef python():\r\n print "likes to be formatted"\r\n\n~~~\r\n\r\n[http://www.google.com](http://www.google.com) is a bare link, and [Google](http://www.google.com) is given a title.\r\n\r\nThanks!\r\n\r\n~~~ quote\n\r\nSomeone said somewhere\r\n\n~~~\n```"""
self.send_and_test_stream_message('commented_markup_v1', expected_topic, expected_message) self.check_webhook("commented_markup_v1", expected_topic, expected_message)
self.send_and_test_stream_message('commented_markup_v2', expected_topic, expected_message) self.check_webhook("commented_markup_v2", expected_topic, expected_message)
def test_deleted(self) -> None: def test_deleted(self) -> None:
expected_topic = "BUG-15: New bug with hook" expected_topic = "BUG-15: New bug with hook"
expected_message = "Leo Franchi deleted [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15)." expected_message = "Leo Franchi deleted [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15)."
self.send_and_test_stream_message('deleted_v1', expected_topic, expected_message) self.check_webhook("deleted_v1", expected_topic, expected_message)
self.send_and_test_stream_message('deleted_v2', expected_topic, expected_message) self.check_webhook("deleted_v2", expected_topic, expected_message)
def test_reassigned(self) -> None: def test_reassigned(self) -> None:
expected_topic = "BUG-15: New bug with hook" expected_topic = "BUG-15: New bug with hook"
expected_message = """Leo Franchi updated [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**): expected_message = """Leo Franchi updated [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**):
* Changed assignee to **Othello, the Moor of Venice**""" * Changed assignee to **Othello, the Moor of Venice**"""
self.send_and_test_stream_message('reassigned_v1', expected_topic, expected_message) self.check_webhook("reassigned_v1", expected_topic, expected_message)
self.send_and_test_stream_message('reassigned_v2', expected_topic, expected_message) self.check_webhook("reassigned_v2", expected_topic, expected_message)
def test_priority_updated(self) -> None: def test_priority_updated(self) -> None:
expected_topic = "TEST-1: Fix That" expected_topic = "TEST-1: Fix That"
expected_message = """Leonardo Franchi [Administrator] updated [TEST-1: Fix That](https://zulipp.atlassian.net/browse/TEST-1) (assigned to **leo@zulip.com**): expected_message = """Leonardo Franchi [Administrator] updated [TEST-1: Fix That](https://zulipp.atlassian.net/browse/TEST-1) (assigned to **leo@zulip.com**):
* Changed priority from **Critical** to **Major**""" * Changed priority from **Critical** to **Major**"""
self.send_and_test_stream_message('updated_priority_v1', expected_topic, expected_message) self.check_webhook("updated_priority_v1", expected_topic, expected_message)
self.send_and_test_stream_message('updated_priority_v2', expected_topic, expected_message) self.check_webhook("updated_priority_v2", expected_topic, expected_message)
def test_status_changed(self) -> None: def test_status_changed(self) -> None:
expected_topic = "TEST-1: Fix That" expected_topic = "TEST-1: Fix That"
expected_message = """Leonardo Franchi [Administrator] updated [TEST-1: Fix That](https://zulipp.atlassian.net/browse/TEST-1): expected_message = """Leonardo Franchi [Administrator] updated [TEST-1: Fix That](https://zulipp.atlassian.net/browse/TEST-1):
* Changed status from **To Do** to **In Progress**""" * Changed status from **To Do** to **In Progress**"""
self.send_and_test_stream_message('change_status_v1', expected_topic, expected_message) self.check_webhook("change_status_v1", expected_topic, expected_message)
self.send_and_test_stream_message('change_status_v2', expected_topic, expected_message) self.check_webhook("change_status_v2", expected_topic, expected_message)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data('jira', fixture_name) return self.webhook_fixture_data('jira', fixture_name)
@ -193,20 +193,19 @@ Adding a comment. Oh, what a comment it is!
def test_comment_event_comment_created(self) -> None: def test_comment_event_comment_created(self) -> None:
expected_topic = "SP-1: Add support for newer format Jira issue comment events" expected_topic = "SP-1: Add support for newer format Jira issue comment events"
expected_message = """Hemanth V. Alluri commented on issue: *"Add support for newer format Jira issue comment events"*\n``` quote\nSounds like its pretty important. Ill get this fixed ASAP!\n```""" expected_message = """Hemanth V. Alluri commented on issue: *"Add support for newer format Jira issue comment events"*\n``` quote\nSounds like its pretty important. Ill get this fixed ASAP!\n```"""
self.send_and_test_stream_message("comment_created", expected_topic, expected_message) self.check_webhook("comment_created", expected_topic, expected_message)
def test_comment_event_comment_created_no_issue_details(self) -> None: def test_comment_event_comment_created_no_issue_details(self) -> None:
expected_topic = "10000: Upgrade Jira to get the issue title here." expected_topic = "10000: Upgrade Jira to get the issue title here."
expected_message = """Hemanth V. Alluri commented on issue: *"Upgrade Jira to get the issue title here."*\n``` quote\nSounds like its pretty important. Ill get this fixed ASAP!\n```""" expected_message = """Hemanth V. Alluri commented on issue: *"Upgrade Jira to get the issue title here."*\n``` quote\nSounds like its pretty important. Ill get this fixed ASAP!\n```"""
self.send_and_test_stream_message("comment_created_no_issue_details", self.check_webhook("comment_created_no_issue_details", expected_topic, expected_message)
expected_topic, expected_message)
def test_comment_event_comment_edited(self) -> None: def test_comment_event_comment_edited(self) -> None:
expected_topic = "SP-1: Add support for newer format Jira issue comment events" expected_topic = "SP-1: Add support for newer format Jira issue comment events"
expected_message = """Hemanth V. Alluri updated their comment on issue: *"Add support for newer format Jira issue comment events"*\n``` quote\nThis is a very important issue! Im on it!\n```""" expected_message = """Hemanth V. Alluri updated their comment on issue: *"Add support for newer format Jira issue comment events"*\n``` quote\nThis is a very important issue! Im on it!\n```"""
self.send_and_test_stream_message("comment_updated", expected_topic, expected_message) self.check_webhook("comment_updated", expected_topic, expected_message)
def test_comment_event_comment_deleted(self) -> None: def test_comment_event_comment_deleted(self) -> None:
expected_topic = "SP-1: Add support for newer format Jira issue comment events" expected_topic = "SP-1: Add support for newer format Jira issue comment events"
expected_message = """Hemanth V. Alluri deleted their comment on issue: *"Add support for newer format Jira issue comment events"*\n``` quote\n~~This is a very important issue! Im on it!~~\n```""" expected_message = """Hemanth V. Alluri deleted their comment on issue: *"Add support for newer format Jira issue comment events"*\n``` quote\n~~This is a very important issue! Im on it!~~\n```"""
self.send_and_test_stream_message("comment_deleted", expected_topic, expected_message) self.check_webhook("comment_deleted", expected_topic, expected_message)

View File

@ -17,27 +17,52 @@ class LibratoHookTests(WebhookTestCase):
def test_alert_message_with_default_topic(self) -> None: def test_alert_message_with_default_topic(self) -> None:
expected_topic = 'Alert alert.name' expected_topic = 'Alert alert.name'
expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at 2016-03-31 09:11:42 UTC." expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at 2016-03-31 09:11:42 UTC."
self.send_and_test_stream_message('alert', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") self.check_webhook(
"alert",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_alert_message_with_custom_topic(self) -> None: def test_alert_message_with_custom_topic(self) -> None:
custom_topic = 'custom_name' custom_topic = 'custom_name'
self.url = self.build_webhook_url(topic=custom_topic) self.url = self.build_webhook_url(topic=custom_topic)
expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at 2016-03-31 09:11:42 UTC." expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.google.pl):\n * Metric `librato.cpu.percent.idle`, sum was below 44 by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 300s, recorded at 2016-03-31 09:11:42 UTC.\n * Metric `librato.swap.swap.cached`, derivative was above 9 by 300s, recorded at 2016-03-31 09:11:42 UTC."
self.send_and_test_stream_message('alert', custom_topic, expected_message, content_type="application/x-www-form-urlencoded") self.check_webhook(
"alert",
custom_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_three_conditions_alert_message(self) -> None: def test_three_conditions_alert_message(self) -> None:
expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.use.water.pl):\n * Metric `collectd.interface.eth0.if_octets.tx`, absolute_value was above 4 by 300s, recorded at 2016-04-11 20:40:14 UTC.\n * Metric `collectd.load.load.longterm`, max was above 99, recorded at 2016-04-11 20:40:14 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 60s, recorded at 2016-04-11 20:40:14 UTC." expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6294535) has triggered! [Reaction steps](http://www.use.water.pl):\n * Metric `collectd.interface.eth0.if_octets.tx`, absolute_value was above 4 by 300s, recorded at 2016-04-11 20:40:14 UTC.\n * Metric `collectd.load.load.longterm`, max was above 99, recorded at 2016-04-11 20:40:14 UTC.\n * Metric `librato.swap.swap.cached`, average was absent by 60s, recorded at 2016-04-11 20:40:14 UTC."
expected_topic = 'Alert ToHighTemeprature' expected_topic = 'Alert ToHighTemeprature'
self.send_and_test_stream_message('three_conditions_alert', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") self.check_webhook(
"three_conditions_alert",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_alert_clear(self) -> None: def test_alert_clear(self) -> None:
expected_topic = 'Alert Alert_name' expected_topic = 'Alert Alert_name'
expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6309313) has cleared at 2016-04-12 13:11:44 UTC!" expected_message = "Alert [alert_name](https://metrics.librato.com/alerts#/6309313) has cleared at 2016-04-12 13:11:44 UTC!"
self.send_and_test_stream_message('alert_cleared', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") self.check_webhook(
"alert_cleared",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_snapshot(self) -> None: def test_snapshot(self) -> None:
self.IS_ATTACHMENT = True self.IS_ATTACHMENT = True
expected_topic = 'Snapshots' expected_topic = 'Snapshots'
expected_message = "**Hamlet** sent a [snapshot](http://snapshots.librato.com/chart/nr5l3n0c-82162.png) of [metric](https://metrics.librato.com/s/spaces/167315/explore/1731491?duration=72039&end_time=1460569409)." expected_message = "**Hamlet** sent a [snapshot](http://snapshots.librato.com/chart/nr5l3n0c-82162.png) of [metric](https://metrics.librato.com/s/spaces/167315/explore/1731491?duration=72039&end_time=1460569409)."
self.send_and_test_stream_message('snapshot', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") self.check_webhook(
"snapshot",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
self.IS_ATTACHMENT = False self.IS_ATTACHMENT = False

View File

@ -18,8 +18,12 @@ Children up and down the country are \u2026
""".strip() """.strip()
# use fixture named mention_webfeeds # use fixture named mention_webfeeds
self.send_and_test_stream_message('webfeeds', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "webfeeds",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("mention", fixture_name, file_type="json") return self.webhook_fixture_data("mention", fixture_name, file_type="json")

View File

@ -10,15 +10,17 @@ class NetlifyHookTests(WebhookTestCase):
expected_topic = "master" expected_topic = "master"
expected_message = 'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now building.' expected_message = 'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now building.'
self.send_and_test_stream_message('deploy_building', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "deploy_building", expected_topic, expected_message, content_type="application/json"
)
def test_created_message(self) -> None: def test_created_message(self) -> None:
expected_topic = "master" expected_topic = "master"
expected_message = 'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now ready.' expected_message = 'The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now ready.'
self.send_and_test_stream_message('deploy_created', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "deploy_created", expected_topic, expected_message, content_type="application/json"
)
def test_failed_message(self) -> None: def test_failed_message(self) -> None:
expected_topic = "master" expected_topic = "master"
@ -26,8 +28,9 @@ class NetlifyHookTests(WebhookTestCase):
"on branch master failed during stage 'building site': Build script returned non-zero exit code: 127" "on branch master failed during stage 'building site': Build script returned non-zero exit code: 127"
) )
self.send_and_test_stream_message('deploy_failed', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "deploy_failed", expected_topic, expected_message, content_type="application/json"
)
def test_locked_message(self) -> None: def test_locked_message(self) -> None:
expected_topic = "master" expected_topic = "master"
@ -35,8 +38,9 @@ class NetlifyHookTests(WebhookTestCase):
"on branch master is now locked." "on branch master is now locked."
) )
self.send_and_test_stream_message('deploy_locked', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "deploy_locked", expected_topic, expected_message, content_type="application/json"
)
def test_unlocked_message(self) -> None: def test_unlocked_message(self) -> None:
expected_topic = "master" expected_topic = "master"
@ -44,8 +48,9 @@ class NetlifyHookTests(WebhookTestCase):
"on branch master is now unlocked." "on branch master is now unlocked."
) )
self.send_and_test_stream_message('deploy_unlocked', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "deploy_unlocked", expected_topic, expected_message, content_type="application/json"
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("netlify", fixture_name, file_type="json") return self.webhook_fixture_data("netlify", fixture_name, file_type="json")

View File

@ -9,8 +9,12 @@ class NewRelicHookTests(WebhookTestCase):
expected_topic = "Apdex score fell below critical level of 0.90" expected_topic = "Apdex score fell below critical level of 0.90"
expected_message = 'Alert opened on [application name]: Apdex score fell below critical level of 0.90 ([view alert](https://rpm.newrelc.com/accounts/[account_id]/applications/[application_id]/incidents/[incident_id])).' expected_message = 'Alert opened on [application name]: Apdex score fell below critical level of 0.90 ([view alert](https://rpm.newrelc.com/accounts/[account_id]/applications/[application_id]/incidents/[incident_id])).'
self.send_and_test_stream_message('alert', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "alert",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_deployment(self) -> None: def test_deployment(self) -> None:
expected_topic = 'Test App deploy' expected_topic = 'Test App deploy'
@ -28,8 +32,12 @@ Changelog string
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('deployment', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "deployment",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("newrelic", fixture_name, file_type="txt") return self.webhook_fixture_data("newrelic", fixture_name, file_type="txt")

View File

@ -19,8 +19,9 @@ test comment
>**Most recent Occurrence** >**Most recent Occurrence**
>in app.py >in app.py
>A warning occurred (42 apples)''' >A warning occurred (42 apples)'''
self.send_and_test_stream_message('new_comment', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "new_comment", expected_topic, expected_message, content_type="application/json"
)
def test_new_app(self) -> None: def test_new_app(self) -> None:
expected_topic = "foo" expected_topic = "foo"
@ -31,8 +32,9 @@ App foo created
**[foo](https://opbeat.com/bar/foo/)** **[foo](https://opbeat.com/bar/foo/)**
>language: nodejs >language: nodejs
>framework: custom''' >framework: custom'''
self.send_and_test_stream_message('new_app', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "new_app", expected_topic, expected_message, content_type="application/json"
)
def test_get_empty_value(self) -> None: def test_get_empty_value(self) -> None:
self.assertEqual(get_value({'key': 'value'}, 'foo'), '') self.assertEqual(get_value({'key': 'value'}, 'foo'), '')
@ -42,11 +44,8 @@ App foo created
expected_message = ''' expected_message = '''
**test title** **test title**
test summary''' test summary'''
self.send_and_test_stream_message( self.check_webhook(
'unsupported_object', "unsupported_object", expected_topic, expected_message, content_type="application/json",
expected_topic,
expected_message,
content_type='application/json',
) )
def test_error_fixed(self) -> None: def test_error_fixed(self) -> None:
@ -60,8 +59,9 @@ foo marked the error group as fixed
>**Most recent Occurrence** >**Most recent Occurrence**
>in app.py >in app.py
>A warning occurred (42 apples)''' >A warning occurred (42 apples)'''
self.send_and_test_stream_message( self.check_webhook(
'error_fixed', expected_topic, expected_message, content_type='application/json') "error_fixed", expected_topic, expected_message, content_type="application/json"
)
def test_error_reopened(self) -> None: def test_error_reopened(self) -> None:
expected_topic = 'foo reopened E#2' expected_topic = 'foo reopened E#2'
@ -74,8 +74,9 @@ foo reopened the error group
>**Most recent Occurrence** >**Most recent Occurrence**
>in app.py >in app.py
>A warning occurred (42 apples)''' >A warning occurred (42 apples)'''
self.send_and_test_stream_message( self.check_webhook(
'error_reopen', expected_topic, expected_message, content_type='application/json') "error_reopen", expected_topic, expected_message, content_type="application/json"
)
def test_error_regressed(self) -> None: def test_error_regressed(self) -> None:
expected_topic = 'E#2 regressed' expected_topic = 'E#2 regressed'
@ -88,5 +89,6 @@ The error group regressed
>**Most recent Occurrence** >**Most recent Occurrence**
>in app.py >in app.py
>A warning occurred (42 apples)''' >A warning occurred (42 apples)'''
self.send_and_test_stream_message( self.check_webhook(
'new_error', expected_topic, expected_message, content_type='application/json') "new_error", expected_topic, expected_message, content_type="application/json"
)

View File

@ -15,8 +15,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('acknowledge', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "acknowledge",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addnote_alert(self) -> None: def test_addnote_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -28,8 +32,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('addnote', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "addnote",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addrecipient_alert(self) -> None: def test_addrecipient_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -41,8 +49,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('addrecipient', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "addrecipient",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addtags_alert(self) -> None: def test_addtags_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -54,8 +66,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2`, `tag3` * **Tags**: `tag1`, `tag2`, `tag3`
""".strip() """.strip()
self.send_and_test_stream_message('addtags', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "addtags",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_addteam_alert(self) -> None: def test_addteam_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -67,8 +83,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('addteam', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "addteam",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_assignownership_alert(self) -> None: def test_assignownership_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -80,8 +100,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('assignownership', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "assignownership",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_close_alert(self) -> None: def test_close_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -91,8 +115,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Message**: test alert * **Message**: test alert
""".strip() """.strip()
self.send_and_test_stream_message('close', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "close",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_create_alert(self) -> None: def test_create_alert(self) -> None:
expected_topic = "Webhook" expected_topic = "Webhook"
@ -103,8 +131,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `vip` * **Tags**: `vip`
""".strip() """.strip()
self.send_and_test_stream_message('create', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "create",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customaction_alert(self) -> None: def test_customaction_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -115,8 +147,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('customaction', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customaction",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_delete_alert(self) -> None: def test_delete_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -126,8 +162,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Message**: test alert * **Message**: test alert
""".strip() """.strip()
self.send_and_test_stream_message('delete', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "delete",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_escalate_alert(self) -> None: def test_escalate_alert(self) -> None:
expected_topic = "Webhook_Test" expected_topic = "Webhook_Test"
@ -137,8 +177,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Escalation**: test_esc * **Escalation**: test_esc
""".strip() """.strip()
self.send_and_test_stream_message('escalate', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "escalate",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_removetags_alert(self) -> None: def test_removetags_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -150,8 +194,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('removetags', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "removetags",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_takeownership_alert(self) -> None: def test_takeownership_alert(self) -> None:
expected_topic = "Webhook" expected_topic = "Webhook"
@ -162,8 +210,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('takeownership', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "takeownership",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_unacknowledge_alert(self) -> None: def test_unacknowledge_alert(self) -> None:
expected_topic = "Integration1" expected_topic = "Integration1"
@ -174,8 +226,12 @@ class OpsGenieHookTests(WebhookTestCase):
* **Tags**: `tag1`, `tag2` * **Tags**: `tag1`, `tag2`
""".strip() """.strip()
self.send_and_test_stream_message('unacknowledge', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "unacknowledge",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("opsgenie", fixture_name, file_type="json") return self.webhook_fixture_data("opsgenie", fixture_name, file_type="json")

View File

@ -8,49 +8,50 @@ class PagerDutyHookTests(WebhookTestCase):
def test_trigger(self) -> None: def test_trigger(self) -> None:
expected_message = 'Incident [3](https://zulip-test.pagerduty.com/incidents/P140S4Y) triggered by [Test service](https://zulip-test.pagerduty.com/services/PIL5CUQ) (assigned to [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ)):\n\n``` quote\nfoo\n```' expected_message = 'Incident [3](https://zulip-test.pagerduty.com/incidents/P140S4Y) triggered by [Test service](https://zulip-test.pagerduty.com/services/PIL5CUQ) (assigned to [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ)):\n\n``` quote\nfoo\n```'
self.send_and_test_stream_message('trigger', "Incident 3", expected_message) self.check_webhook("trigger", "Incident 3", expected_message)
def test_trigger_v2(self) -> None: def test_trigger_v2(self) -> None:
expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV)):\n\n``` quote\nMy new incident\n```' expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV)):\n\n``` quote\nMy new incident\n```'
self.send_and_test_stream_message('trigger_v2', 'Incident 33', expected_message) self.check_webhook("trigger_v2", "Incident 33", expected_message)
def test_trigger_without_assignee_v2(self) -> None: def test_trigger_without_assignee_v2(self) -> None:
expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to nobody):\n\n``` quote\nMy new incident\n```' expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to nobody):\n\n``` quote\nMy new incident\n```'
self.send_and_test_stream_message('trigger_without_assignee_v2', 'Incident 33', expected_message) self.check_webhook("trigger_without_assignee_v2", "Incident 33", expected_message)
def test_unacknowledge(self) -> None: def test_unacknowledge(self) -> None:
expected_message = 'Incident [3](https://zulip-test.pagerduty.com/incidents/P140S4Y) unacknowledged by [Test service](https://zulip-test.pagerduty.com/services/PIL5CUQ) (assigned to [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ)):\n\n``` quote\nfoo\n```' expected_message = 'Incident [3](https://zulip-test.pagerduty.com/incidents/P140S4Y) unacknowledged by [Test service](https://zulip-test.pagerduty.com/services/PIL5CUQ) (assigned to [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ)):\n\n``` quote\nfoo\n```'
self.send_and_test_stream_message('unacknowledge', "Incident 3", expected_message) self.check_webhook("unacknowledge", "Incident 3", expected_message)
def test_resolved(self) -> None: def test_resolved(self) -> None:
expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) resolved by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\nIt is on fire\n```' expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) resolved by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\nIt is on fire\n```'
self.send_and_test_stream_message('resolved', "Incident 1", expected_message) self.check_webhook("resolved", "Incident 1", expected_message)
def test_resolved_v2(self) -> None: def test_resolved_v2(self) -> None:
expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) resolved by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV):\n\n``` quote\nMy new incident\n```' expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) resolved by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV):\n\n``` quote\nMy new incident\n```'
self.send_and_test_stream_message('resolve_v2', 'Incident 33', expected_message) self.check_webhook("resolve_v2", "Incident 33", expected_message)
def test_auto_resolved(self) -> None: def test_auto_resolved(self) -> None:
expected_message = 'Incident [2](https://zulip-test.pagerduty.com/incidents/PX7K9J2) resolved:\n\n``` quote\nnew\n```' expected_message = 'Incident [2](https://zulip-test.pagerduty.com/incidents/PX7K9J2) resolved:\n\n``` quote\nnew\n```'
self.send_and_test_stream_message('auto_resolved', "Incident 2", expected_message) self.check_webhook("auto_resolved", "Incident 2", expected_message)
def test_acknowledge(self) -> None: def test_acknowledge(self) -> None:
expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) acknowledged by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\nIt is on fire\n```' expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) acknowledged by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\nIt is on fire\n```'
self.send_and_test_stream_message('acknowledge', "Incident 1", expected_message) self.check_webhook("acknowledge", "Incident 1", expected_message)
def test_acknowledge_without_trigger_summary_data(self) -> None: def test_acknowledge_without_trigger_summary_data(self) -> None:
expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) acknowledged by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\n\n```' expected_message = 'Incident [1](https://zulip-test.pagerduty.com/incidents/PO1XIJ5) acknowledged by [armooo](https://zulip-test.pagerduty.com/users/POBCFRJ):\n\n``` quote\n\n```'
self.send_and_test_stream_message('acknowledge_without_trigger_summary_data', self.check_webhook(
"Incident 1", expected_message) "acknowledge_without_trigger_summary_data", "Incident 1", expected_message
)
def test_acknowledge_v2(self) -> None: def test_acknowledge_v2(self) -> None:
expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) acknowledged by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV):\n\n``` quote\nMy new incident\n```' expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) acknowledged by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV):\n\n``` quote\nMy new incident\n```'
self.send_and_test_stream_message('acknowledge_v2', 'Incident 33', expected_message) self.check_webhook("acknowledge_v2", "Incident 33", expected_message)
def test_incident_assigned_v2(self) -> None: def test_incident_assigned_v2(self) -> None:
expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) assigned to [Wiley Jacobson](https://webdemo.pagerduty.com/users/PFBSJ2Z):\n\n``` quote\nMy new incident\n```' expected_message = 'Incident [33](https://webdemo.pagerduty.com/incidents/PRORDTY) assigned to [Wiley Jacobson](https://webdemo.pagerduty.com/users/PFBSJ2Z):\n\n``` quote\nMy new incident\n```'
self.send_and_test_stream_message('assign_v2', 'Incident 33', expected_message) self.check_webhook("assign_v2", "Incident 33", expected_message)
def test_no_subject(self) -> None: def test_no_subject(self) -> None:
expected_message = 'Incident [48219](https://dropbox.pagerduty.com/incidents/PJKGZF9) resolved:\n\n``` quote\nmp_error_block_down_critical\u2119\u01b4\n```' expected_message = 'Incident [48219](https://dropbox.pagerduty.com/incidents/PJKGZF9) resolved:\n\n``` quote\nmp_error_block_down_critical\u2119\u01b4\n```'
self.send_and_test_stream_message('mp_fail', "Incident 48219", expected_message) self.check_webhook("mp_fail", "Incident 48219", expected_message)

View File

@ -23,8 +23,12 @@ A short event
``` ```
""".strip() """.strip()
self.send_and_test_stream_message('short_post', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "short_post",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_long_message(self) -> None: def test_long_message(self) -> None:
expected_topic = "logs" expected_topic = "logs"
@ -50,13 +54,18 @@ message body 4
[See more](https://papertrailapp.com/searches/42) [See more](https://papertrailapp.com/searches/42)
""".strip() """.strip()
self.send_and_test_stream_message('long_post', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "long_post",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_incorrect_message(self) -> None: def test_incorrect_message(self) -> None:
with self.assertRaises(AssertionError) as e: with self.assertRaises(AssertionError) as e:
self.send_and_test_stream_message('incorrect_post', '', '', self.check_webhook(
content_type="application/x-www-form-urlencoded") "incorrect_post", "", "", content_type="application/x-www-form-urlencoded"
)
self.assertIn("events key is missing from payload", e.exception.args[0]) self.assertIn("events key is missing from payload", e.exception.args[0])

View File

@ -11,25 +11,25 @@ class PingdomHookTests(WebhookTestCase):
Tests if pingdom http check from up to down is handled correctly Tests if pingdom http check from up to down is handled correctly
""" """
expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```" expected_message = "Service someurl.com changed its HTTP status from UP to DOWN:\n\n``` quote\nNon-recoverable failure in name resolution\n```"
self.send_and_test_stream_message('http_up_to_down', "Test check status.", expected_message) self.check_webhook("http_up_to_down", "Test check status.", expected_message)
def test_pingdom_from_up_to_down_smtp_check_message(self) -> None: def test_pingdom_from_up_to_down_smtp_check_message(self) -> None:
""" """
Tests if pingdom smtp check from up to down is handled correctly Tests if pingdom smtp check from up to down is handled correctly
""" """
expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```" expected_message = "Service smtp.someurl.com changed its SMTP status from UP to DOWN:\n\n``` quote\nConnection refused\n```"
self.send_and_test_stream_message('smtp_up_to_down', "SMTP check status.", expected_message) self.check_webhook("smtp_up_to_down", "SMTP check status.", expected_message)
def test_pingdom_from_up_to_down_imap_check_message(self) -> None: def test_pingdom_from_up_to_down_imap_check_message(self) -> None:
""" """
Tests if pingdom imap check from up to down is handled correctly Tests if pingdom imap check from up to down is handled correctly
""" """
expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```" expected_message = "Service imap.someurl.com changed its IMAP status from UP to DOWN:\n\n``` quote\nInvalid hostname, address or socket\n```"
self.send_and_test_stream_message('imap_up_to_down', "IMAP check status.", expected_message) self.check_webhook("imap_up_to_down", "IMAP check status.", expected_message)
def test_pingdom_from_down_to_up_imap_check_message(self) -> None: def test_pingdom_from_down_to_up_imap_check_message(self) -> None:
""" """
Tests if pingdom imap check from down to up is handled correctly Tests if pingdom imap check from down to up is handled correctly
""" """
expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP." expected_message = "Service imap.someurl.com changed its IMAP status from DOWN to UP."
self.send_and_test_stream_message('imap_down_to_up', "IMAP check status.", expected_message) self.check_webhook("imap_down_to_up", "IMAP check status.", expected_message)

View File

@ -9,63 +9,83 @@ class PivotalV3HookTests(WebhookTestCase):
expected_topic = 'My new Feature story' expected_topic = 'My new Feature story'
expected_message = 'Leo Franchi accepted "My new Feature story" \ expected_message = 'Leo Franchi accepted "My new Feature story" \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).'
self.send_and_test_stream_message('accepted', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"accepted", expected_topic, expected_message, content_type="application/xml"
)
def test_commented(self) -> None: def test_commented(self) -> None:
expected_topic = 'Comment added' expected_topic = 'Comment added'
expected_message = 'Leo Franchi added comment: "FIX THIS NOW" \ expected_message = 'Leo Franchi added comment: "FIX THIS NOW" \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).'
self.send_and_test_stream_message('commented', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"commented", expected_topic, expected_message, content_type="application/xml"
)
def test_created(self) -> None: def test_created(self) -> None:
expected_topic = 'My new Feature story' expected_topic = 'My new Feature story'
expected_message = 'Leo Franchi added "My new Feature story" \ expected_message = 'Leo Franchi added "My new Feature story" \
(unscheduled feature):\n\n~~~ quote\nThis is my long description\n~~~\n\n \ (unscheduled feature):\n\n~~~ quote\nThis is my long description\n~~~\n\n \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).'
self.send_and_test_stream_message('created', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"created", expected_topic, expected_message, content_type="application/xml"
)
def test_delivered(self) -> None: def test_delivered(self) -> None:
expected_topic = 'Another new story' expected_topic = 'Another new story'
expected_message = 'Leo Franchi delivered "Another new story" \ expected_message = 'Leo Franchi delivered "Another new story" \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).'
self.send_and_test_stream_message('delivered', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"delivered", expected_topic, expected_message, content_type="application/xml"
)
def test_finished(self) -> None: def test_finished(self) -> None:
expected_topic = 'Another new story' expected_topic = 'Another new story'
expected_message = 'Leo Franchi finished "Another new story" \ expected_message = 'Leo Franchi finished "Another new story" \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).'
self.send_and_test_stream_message('finished', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"finished", expected_topic, expected_message, content_type="application/xml"
)
def test_moved(self) -> None: def test_moved(self) -> None:
expected_topic = 'My new Feature story' expected_topic = 'My new Feature story'
expected_message = 'Leo Franchi edited "My new Feature story" \ expected_message = 'Leo Franchi edited "My new Feature story" \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).'
self.send_and_test_stream_message('moved', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"moved", expected_topic, expected_message, content_type="application/xml"
)
def test_rejected(self) -> None: def test_rejected(self) -> None:
expected_topic = 'Another new story' expected_topic = 'Another new story'
expected_message = 'Leo Franchi rejected "Another new story" with comments: \ expected_message = 'Leo Franchi rejected "Another new story" with comments: \
"Not good enough, sorry" [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).' "Not good enough, sorry" [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).'
self.send_and_test_stream_message('rejected', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"rejected", expected_topic, expected_message, content_type="application/xml"
)
def test_started(self) -> None: def test_started(self) -> None:
expected_topic = 'Another new story' expected_topic = 'Another new story'
expected_message = 'Leo Franchi started "Another new story" \ expected_message = 'Leo Franchi started "Another new story" \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).'
self.send_and_test_stream_message('started', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"started", expected_topic, expected_message, content_type="application/xml"
)
def test_created_estimate(self) -> None: def test_created_estimate(self) -> None:
expected_topic = 'Another new story' expected_topic = 'Another new story'
expected_message = 'Leo Franchi added "Another new story" \ expected_message = 'Leo Franchi added "Another new story" \
(unscheduled feature worth 2 story points):\n\n~~~ quote\nSome loong description\n~~~\n\n \ (unscheduled feature worth 2 story points):\n\n~~~ quote\nSome loong description\n~~~\n\n \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289).'
self.send_and_test_stream_message('created_estimate', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"created_estimate", expected_topic, expected_message, content_type="application/xml"
)
def test_type_changed(self) -> None: def test_type_changed(self) -> None:
expected_topic = 'My new Feature story' expected_topic = 'My new Feature story'
expected_message = 'Leo Franchi edited "My new Feature story" \ expected_message = 'Leo Franchi edited "My new Feature story" \
[(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).' [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573).'
self.send_and_test_stream_message('type_changed', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"type_changed", expected_topic, expected_message, content_type="application/xml"
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data('pivotal', fixture_name, file_type='xml') return self.webhook_fixture_data('pivotal', fixture_name, file_type='xml')
@ -78,7 +98,9 @@ class PivotalV5HookTests(WebhookTestCase):
expected_topic = '#63486316: Story of the Year' expected_topic = '#63486316: Story of the Year'
expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story of the Year](http://www.pivotaltracker.com/story/show/63486316): expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story of the Year](http://www.pivotaltracker.com/story/show/63486316):
* state changed from **unstarted** to **accepted**""" * state changed from **unstarted** to **accepted**"""
self.send_and_test_stream_message('accepted', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"accepted", expected_topic, expected_message, content_type="application/xml"
)
def test_commented(self) -> None: def test_commented(self) -> None:
expected_topic = '#63486316: Story of the Year' expected_topic = '#63486316: Story of the Year'
@ -86,7 +108,9 @@ class PivotalV5HookTests(WebhookTestCase):
~~~quote ~~~quote
A comment on the story A comment on the story
~~~""" ~~~"""
self.send_and_test_stream_message('commented', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"commented", expected_topic, expected_message, content_type="application/xml"
)
def test_created(self) -> None: def test_created(self) -> None:
expected_topic = '#63495662: Story that I created' expected_topic = '#63495662: Story that I created'
@ -95,24 +119,32 @@ A comment on the story
* Description is * Description is
> What a description""" > What a description"""
self.send_and_test_stream_message('created', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"created", expected_topic, expected_message, content_type="application/xml"
)
def test_delivered(self) -> None: def test_delivered(self) -> None:
expected_topic = '#63486316: Story of the Year' expected_topic = '#63486316: Story of the Year'
expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story of the Year](http://www.pivotaltracker.com/story/show/63486316): expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story of the Year](http://www.pivotaltracker.com/story/show/63486316):
* state changed from **accepted** to **delivered**""" * state changed from **accepted** to **delivered**"""
self.send_and_test_stream_message('delivered', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"delivered", expected_topic, expected_message, content_type="application/xml"
)
def test_finished(self) -> None: def test_finished(self) -> None:
expected_topic = '#63486316: Story of the Year' expected_topic = '#63486316: Story of the Year'
expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story of the Year](http://www.pivotaltracker.com/story/show/63486316): expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story of the Year](http://www.pivotaltracker.com/story/show/63486316):
* state changed from **delivered** to **accepted**""" * state changed from **delivered** to **accepted**"""
self.send_and_test_stream_message('finished', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"finished", expected_topic, expected_message, content_type="application/xml"
)
def test_moved(self) -> None: def test_moved(self) -> None:
expected_topic = '#63496066: Pivotal Test' expected_topic = '#63496066: Pivotal Test'
expected_message = """Leo Franchi moved [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Pivotal Test](http://www.pivotaltracker.com/story/show/63496066) from **unstarted** to **unscheduled**.""" expected_message = """Leo Franchi moved [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Pivotal Test](http://www.pivotaltracker.com/story/show/63496066) from **unstarted** to **unscheduled**."""
self.send_and_test_stream_message('moved', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"moved", expected_topic, expected_message, content_type="application/xml"
)
def test_rejected(self) -> None: def test_rejected(self) -> None:
expected_topic = '#63486316: Story of the Year' expected_topic = '#63486316: Story of the Year'
@ -122,26 +154,34 @@ A comment on the story
Try again next time Try again next time
~~~ ~~~
* state changed from **delivered** to **rejected**""" * state changed from **delivered** to **rejected**"""
self.send_and_test_stream_message('rejected', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"rejected", expected_topic, expected_message, content_type="application/xml"
)
def test_started(self) -> None: def test_started(self) -> None:
expected_topic = '#63495972: Fresh Story' expected_topic = '#63495972: Fresh Story'
expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Fresh Story](http://www.pivotaltracker.com/story/show/63495972): expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Fresh Story](http://www.pivotaltracker.com/story/show/63495972):
* state changed from **unstarted** to **started**""" * state changed from **unstarted** to **started**"""
self.send_and_test_stream_message('started', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"started", expected_topic, expected_message, content_type="application/xml"
)
def test_created_estimate(self) -> None: def test_created_estimate(self) -> None:
expected_topic = '#63496066: Pivotal Test' expected_topic = '#63496066: Pivotal Test'
expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Pivotal Test](http://www.pivotaltracker.com/story/show/63496066): expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Pivotal Test](http://www.pivotaltracker.com/story/show/63496066):
* estimate is now **3 points**""" * estimate is now **3 points**"""
self.send_and_test_stream_message('created_estimate', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"created_estimate", expected_topic, expected_message, content_type="application/xml"
)
def test_type_changed(self) -> None: def test_type_changed(self) -> None:
expected_topic = '#63496066: Pivotal Test' expected_topic = '#63496066: Pivotal Test'
expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Pivotal Test](http://www.pivotaltracker.com/story/show/63496066): expected_message = """Leo Franchi updated [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Pivotal Test](http://www.pivotaltracker.com/story/show/63496066):
* estimate changed from 3 to **0 points** * estimate changed from 3 to **0 points**
* type changed from **feature** to **bug**""" * type changed from **feature** to **bug**"""
self.send_and_test_stream_message('type_changed', expected_topic, expected_message, content_type="application/xml") self.check_webhook(
"type_changed", expected_topic, expected_message, content_type="application/xml"
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data('pivotal', f"v5_{fixture_name}", file_type='json') return self.webhook_fixture_data('pivotal', f"v5_{fixture_name}", file_type='json')

View File

@ -14,11 +14,12 @@ class RaygunHookTests(WebhookTestCase):
* **Application details**: [Best App](http://app.raygun.io/application-url) * **Application details**: [Best App](http://app.raygun.io/application-url)
""".strip() """.strip()
self.send_and_test_stream_message('error_status_changed', self.check_webhook(
expected_topic, "error_status_changed",
expected_message, expected_topic,
content_type= expected_message,
"application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded",
)
def test_comment_added_to_error_message(self) -> None: def test_comment_added_to_error_message(self) -> None:
expected_topic = "test" expected_topic = "test"
@ -32,11 +33,12 @@ Ignoring these errors
* **Application details**: [application name](http://app.raygun.io/application-url) * **Application details**: [application name](http://app.raygun.io/application-url)
""".strip() """.strip()
self.send_and_test_stream_message('comment_added_to_error', self.check_webhook(
expected_topic, "comment_added_to_error",
expected_message, expected_topic,
content_type= expected_message,
"application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded",
)
def test_error_assigned_to_user_message(self) -> None: def test_error_assigned_to_user_message(self) -> None:
expected_topic = "test" expected_topic = "test"
@ -46,11 +48,12 @@ Amy Loondon assigned [Error](https://app.raygun.com/error-url) to Kyle Kenny:
* **Application details**: [application name](http://app.raygun.io/application-url) * **Application details**: [application name](http://app.raygun.io/application-url)
""".strip() """.strip()
self.send_and_test_stream_message('error_assigned_to_user', self.check_webhook(
expected_topic, "error_assigned_to_user",
expected_message, expected_topic,
content_type= expected_message,
"application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded",
)
def test_one_minute_followup_error_message(self) -> None: def test_one_minute_followup_error_message(self) -> None:
expected_topic = "test" expected_topic = "test"
@ -62,11 +65,12 @@ One minute [follow-up error](http://app.raygun.io/error-url):
* **Application details**: [application name](http://app.raygun.io/application-url) * **Application details**: [application name](http://app.raygun.io/application-url)
""".strip() """.strip()
self.send_and_test_stream_message('one_minute_followup_error', self.check_webhook(
expected_topic, "one_minute_followup_error",
expected_message, expected_topic,
content_type= expected_message,
"application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded",
)
def test_hourly_followup_error_message(self) -> None: def test_hourly_followup_error_message(self) -> None:
expected_topic = "test" expected_topic = "test"
@ -78,11 +82,12 @@ Hourly [follow-up error](http://app.raygun.io/error-url):
* **Application details**: [application name](http://app.raygun.io/application-url) * **Application details**: [application name](http://app.raygun.io/application-url)
""".strip() """.strip()
self.send_and_test_stream_message('hourly_followup_error', self.check_webhook(
expected_topic, "hourly_followup_error",
expected_message, expected_topic,
content_type= expected_message,
"application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded",
)
def test_new_error_message(self) -> None: def test_new_error_message(self) -> None:
expected_topic = "test" expected_topic = "test"
@ -98,11 +103,12 @@ New [Error](http://app.raygun.io/error-url) occurred:
* **Application details**: [application name](http://app.raygun.io/application-url) * **Application details**: [application name](http://app.raygun.io/application-url)
""".strip() """.strip()
self.send_and_test_stream_message('new_error', self.check_webhook(
expected_topic, "new_error",
expected_message, expected_topic,
content_type= expected_message,
"application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded",
)
def test_reoccurred_error_message(self) -> None: def test_reoccurred_error_message(self) -> None:
expected_topic = "test" expected_topic = "test"
@ -118,11 +124,12 @@ New [Error](http://app.raygun.io/error-url) occurred:
* **Application details**: [application name](http://app.raygun.io/application-url) * **Application details**: [application name](http://app.raygun.io/application-url)
""".strip() """.strip()
self.send_and_test_stream_message('reoccurred_error', self.check_webhook(
expected_topic, "reoccurred_error",
expected_message, expected_topic,
content_type= expected_message,
"application/x-www-form-urlencoded") content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("raygun", fixture_name, file_type="json") return self.webhook_fixture_data("raygun", fixture_name, file_type="json")

View File

@ -9,41 +9,33 @@ class ReviewBoardHookTests(WebhookTestCase):
def test_review_request_published(self) -> None: def test_review_request_published(self) -> None:
expected_topic = 'Scheduler' expected_topic = 'Scheduler'
expected_message = '**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```' expected_message = '**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```'
self.send_and_test_stream_message( self.check_webhook("review_request_published", expected_topic, expected_message)
'review_request_published',
expected_topic, expected_message)
def test_review_request_published_with_multiple_target_people(self) -> None: def test_review_request_published_with_multiple_target_people(self) -> None:
expected_topic = 'Scheduler' expected_topic = 'Scheduler'
expected_message = '**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**, **johndoe**, and **janedoe**\n**Branch**: master\n```' expected_message = '**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**, **johndoe**, and **janedoe**\n**Branch**: master\n```'
self.send_and_test_stream_message( self.check_webhook(
'review_request_published__with_multiple_target_people', "review_request_published__with_multiple_target_people",
expected_topic, expected_message) expected_topic,
expected_message,
)
def test_review_request_reopened(self) -> None: def test_review_request_reopened(self) -> None:
expected_topic = 'Scheduler' expected_topic = 'Scheduler'
expected_message = '**eeshangarg** reopened [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```' expected_message = '**eeshangarg** reopened [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```'
self.send_and_test_stream_message( self.check_webhook("review_request_reopened", expected_topic, expected_message)
'review_request_reopened',
expected_topic, expected_message)
def test_review_request_closed(self) -> None: def test_review_request_closed(self) -> None:
expected_topic = 'Scheduler' expected_topic = 'Scheduler'
expected_message = '**eeshangarg** closed [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: submitted\n**Target people**: **drsbgarg**\n**Close type**: submitted\n**Branch**: master\n```' expected_message = '**eeshangarg** closed [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: submitted\n**Target people**: **drsbgarg**\n**Close type**: submitted\n**Branch**: master\n```'
self.send_and_test_stream_message( self.check_webhook("review_request_closed", expected_topic, expected_message)
'review_request_closed',
expected_topic, expected_message)
def test_review_published(self) -> None: def test_review_published(self) -> None:
expected_topic = 'Scheduler' expected_topic = 'Scheduler'
expected_message = '**eeshangarg** [reviewed](https://rbcommons.com/s/zulip/r/1/#review651728) [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n**Review**:\n``` quote\nLeft some minor comments, thanks!\n```' expected_message = '**eeshangarg** [reviewed](https://rbcommons.com/s/zulip/r/1/#review651728) [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n**Review**:\n``` quote\nLeft some minor comments, thanks!\n```'
self.send_and_test_stream_message( self.check_webhook("review_published", expected_topic, expected_message)
'review_published',
expected_topic, expected_message)
def test_reply_published(self) -> None: def test_reply_published(self) -> None:
expected_topic = 'Scheduler' expected_topic = 'Scheduler'
expected_message = '**drsbgarg** [replied](https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/) to [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/api/review-requests/1/):\n\n**Reply**:\n``` quote\n\n```' expected_message = '**drsbgarg** [replied](https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/) to [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/api/review-requests/1/):\n\n**Reply**:\n``` quote\n\n```'
self.send_and_test_stream_message( self.check_webhook("reply_published", expected_topic, expected_message)
'reply_published',
expected_topic, expected_message)

View File

@ -21,8 +21,12 @@ class SemaphoreHookTests(WebhookTestCase):
* **Commit**: [a490b8d: Create user account for Rocinante](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf) * **Commit**: [a490b8d: Create user account for Rocinante](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf)
* **Author**: don@lamancha.com * **Author**: don@lamancha.com
""".strip() """.strip()
self.send_and_test_stream_message('build', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "build",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_semaphore_deploy(self) -> None: def test_semaphore_deploy(self) -> None:
expected_topic = "knighthood/master" expected_topic = "knighthood/master"
@ -32,8 +36,12 @@ class SemaphoreHookTests(WebhookTestCase):
* **Author**: don@lamancha.com * **Author**: don@lamancha.com
* **Server**: lamancha-271 * **Server**: lamancha-271
""".strip() """.strip()
self.send_and_test_stream_message('deploy', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "deploy",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# Tests For Semaphore 2.0 # Tests For Semaphore 2.0
@ -45,8 +53,9 @@ class SemaphoreHookTests(WebhookTestCase):
* **Branch**: rw/webhook_impl * **Branch**: rw/webhook_impl
* **Author**: [radwo](https://github.com/radwo) * **Author**: [radwo](https://github.com/radwo)
""".strip() """.strip()
self.send_and_test_stream_message('push', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "push", expected_topic, expected_message, content_type="application/json"
)
def test_semaphore2_push_non_gh_repo(self) -> None: def test_semaphore2_push_non_gh_repo(self) -> None:
expected_topic = "notifications/rw/webhook_impl" # repo/branch expected_topic = "notifications/rw/webhook_impl" # repo/branch
@ -57,8 +66,9 @@ class SemaphoreHookTests(WebhookTestCase):
* **Author**: radwo * **Author**: radwo
""".strip() """.strip()
with patch('zerver.webhooks.semaphore.view.is_github_repo', return_value=False): with patch('zerver.webhooks.semaphore.view.is_github_repo', return_value=False):
self.send_and_test_stream_message('push', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "push", expected_topic, expected_message, content_type="application/json"
)
def test_semaphore_pull_request(self) -> None: def test_semaphore_pull_request(self) -> None:
expected_topic = "notifications/test-notifications" expected_topic = "notifications/test-notifications"
@ -68,8 +78,9 @@ class SemaphoreHookTests(WebhookTestCase):
* **Branch**: test-notifications * **Branch**: test-notifications
* **Author**: [radwo](https://github.com/radwo) * **Author**: [radwo](https://github.com/radwo)
""".strip() """.strip()
self.send_and_test_stream_message('pull_request', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "pull_request", expected_topic, expected_message, content_type="application/json"
)
def test_semaphore_pull_request_non_gh_repo(self) -> None: def test_semaphore_pull_request_non_gh_repo(self) -> None:
expected_topic = "notifications/test-notifications" expected_topic = "notifications/test-notifications"
@ -80,8 +91,9 @@ class SemaphoreHookTests(WebhookTestCase):
* **Author**: radwo * **Author**: radwo
""".strip() """.strip()
with patch('zerver.webhooks.semaphore.view.is_github_repo', return_value=False): with patch('zerver.webhooks.semaphore.view.is_github_repo', return_value=False):
self.send_and_test_stream_message('pull_request', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "pull_request", expected_topic, expected_message, content_type="application/json"
)
def test_semaphore_tag(self) -> None: def test_semaphore_tag(self) -> None:
expected_topic = "notifications" expected_topic = "notifications"
@ -90,8 +102,7 @@ class SemaphoreHookTests(WebhookTestCase):
* **Tag**: [v1.0.1](https://github.com/renderedtext/notifications/tree/v1.0.1) * **Tag**: [v1.0.1](https://github.com/renderedtext/notifications/tree/v1.0.1)
* **Author**: [radwo](https://github.com/radwo) * **Author**: [radwo](https://github.com/radwo)
""".strip() """.strip()
self.send_and_test_stream_message('tag', expected_topic, expected_message, self.check_webhook("tag", expected_topic, expected_message, content_type="application/json")
content_type="application/json")
def test_semaphore_tag_non_gh_repo(self) -> None: def test_semaphore_tag_non_gh_repo(self) -> None:
expected_topic = "notifications" expected_topic = "notifications"
@ -101,8 +112,9 @@ class SemaphoreHookTests(WebhookTestCase):
* **Author**: radwo * **Author**: radwo
""".strip() """.strip()
with patch('zerver.webhooks.semaphore.view.is_github_repo', return_value=False): with patch('zerver.webhooks.semaphore.view.is_github_repo', return_value=False):
self.send_and_test_stream_message('tag', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "tag", expected_topic, expected_message, content_type="application/json"
)
def test_semaphore_unknown_event(self) -> None: def test_semaphore_unknown_event(self) -> None:
expected_topic = "notifications" expected_topic = "notifications"
@ -110,8 +122,9 @@ class SemaphoreHookTests(WebhookTestCase):
[Notifications](https://semaphore.semaphoreci.com/workflows/a8704319-2422-4828-9b11-6b2afa3554e6) pipeline **stopped** for unknown event [Notifications](https://semaphore.semaphoreci.com/workflows/a8704319-2422-4828-9b11-6b2afa3554e6) pipeline **stopped** for unknown event
""".strip() """.strip()
with patch('zerver.webhooks.semaphore.tests.SemaphoreHookTests.get_body', self.get_unknown_event): with patch('zerver.webhooks.semaphore.tests.SemaphoreHookTests.get_body', self.get_unknown_event):
self.send_and_test_stream_message('tag', expected_topic, expected_message, self.check_webhook(
content_type="application/json") "tag", expected_topic, expected_message, content_type="application/json"
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("semaphore", fixture_name, file_type="json") return self.webhook_fixture_data("semaphore", fixture_name, file_type="json")

View File

@ -30,7 +30,7 @@ Traceback:
defer resp.Body.Close() defer resp.Body.Close()
```""" ```"""
self.send_and_test_stream_message('event_for_exception_golang', expected_topic, expected_message) self.check_webhook("event_for_exception_golang", expected_topic, expected_message)
def test_event_for_exception_node(self) -> None: def test_event_for_exception_node(self) -> None:
expected_topic = "Error: Sample error from node." expected_topic = "Error: Sample error from node."
@ -56,7 +56,7 @@ Traceback:
```""" ```"""
self.send_and_test_stream_message('event_for_exception_node', expected_topic, expected_message) self.check_webhook("event_for_exception_node", expected_topic, expected_message)
def test_event_for_exception_python(self) -> None: def test_event_for_exception_python(self) -> None:
expected_topic = "Exception: Custom exception!" expected_topic = "Exception: Custom exception!"
@ -80,7 +80,7 @@ Traceback:
sentry_sdk.capture_exception(e) sentry_sdk.capture_exception(e)
```""" ```"""
self.send_and_test_stream_message('event_for_exception_python', expected_topic, expected_message) self.check_webhook("event_for_exception_python", expected_topic, expected_message)
def test_event_for_message_golang(self) -> None: def test_event_for_message_golang(self) -> None:
expected_topic = "A test message event from golang." expected_topic = "A test message event from golang."
@ -90,7 +90,7 @@ Traceback:
**level:** info **level:** info
**timestamp:** 2020-04-30 06:14:13 **timestamp:** 2020-04-30 06:14:13
```""" ```"""
self.send_and_test_stream_message('event_for_message_golang', expected_topic, expected_message) self.check_webhook("event_for_message_golang", expected_topic, expected_message)
def test_event_for_message_node(self) -> None: def test_event_for_message_node(self) -> None:
expected_topic = "Test event from node." expected_topic = "Test event from node."
@ -100,7 +100,7 @@ Traceback:
**level:** info **level:** info
**timestamp:** 2020-04-30 06:09:56 **timestamp:** 2020-04-30 06:09:56
```""" ```"""
self.send_and_test_stream_message('event_for_message_node', expected_topic, expected_message) self.check_webhook("event_for_message_node", expected_topic, expected_message)
def test_event_for_message_python(self) -> None: def test_event_for_message_python(self) -> None:
expected_topic = "A simple message-based issue." expected_topic = "A simple message-based issue."
@ -110,17 +110,17 @@ Traceback:
**level:** info **level:** info
**timestamp:** 2020-04-28 14:05:04 **timestamp:** 2020-04-28 14:05:04
```""" ```"""
self.send_and_test_stream_message('event_for_message_python', expected_topic, expected_message) self.check_webhook("event_for_message_python", expected_topic, expected_message)
def test_issue_assigned_to_individual(self) -> None: def test_issue_assigned_to_individual(self) -> None:
expected_topic = "A test message event from golang." expected_topic = "A test message event from golang."
expected_message = """\nIssue **A test message event from golang.** has now been assigned to **Hemanth V. Alluri** by **Hemanth V. Alluri**.""" expected_message = """\nIssue **A test message event from golang.** has now been assigned to **Hemanth V. Alluri** by **Hemanth V. Alluri**."""
self.send_and_test_stream_message('issue_assigned_to_individual', expected_topic, expected_message) self.check_webhook("issue_assigned_to_individual", expected_topic, expected_message)
def test_issue_assigned_to_team(self) -> None: def test_issue_assigned_to_team(self) -> None:
expected_topic = "Exception: program has entered an invalid state." expected_topic = "Exception: program has entered an invalid state."
expected_message = """\nIssue **Exception: program has entered an invalid state.** has now been assigned to **team lone-wolf** by **Hemanth V. Alluri**.""" expected_message = """\nIssue **Exception: program has entered an invalid state.** has now been assigned to **team lone-wolf** by **Hemanth V. Alluri**."""
self.send_and_test_stream_message('issue_assigned_to_team', expected_topic, expected_message) self.check_webhook("issue_assigned_to_team", expected_topic, expected_message)
def test_issue_created_for_exception(self) -> None: def test_issue_created_for_exception(self) -> None:
expected_topic = "Exception: Custom exception!" expected_topic = "Exception: Custom exception!"
@ -131,7 +131,7 @@ Traceback:
**timestamp:** 2020-04-28 13:56:05 **timestamp:** 2020-04-28 13:56:05
**assignee:** No one **assignee:** No one
```""" ```"""
self.send_and_test_stream_message('issue_created_for_exception', expected_topic, expected_message) self.check_webhook("issue_created_for_exception", expected_topic, expected_message)
def test_issue_created_for_message(self) -> None: def test_issue_created_for_message(self) -> None:
expected_topic = "A simple message-based issue." expected_topic = "A simple message-based issue."
@ -142,17 +142,17 @@ Traceback:
**timestamp:** 2020-04-28 14:05:04 **timestamp:** 2020-04-28 14:05:04
**assignee:** No one **assignee:** No one
```""" ```"""
self.send_and_test_stream_message('issue_created_for_message', expected_topic, expected_message) self.check_webhook("issue_created_for_message", expected_topic, expected_message)
def test_issue_ignored(self) -> None: def test_issue_ignored(self) -> None:
expected_topic = "Exception: program has entered an invalid state." expected_topic = "Exception: program has entered an invalid state."
expected_message = """\nIssue **Exception: program has entered an invalid state.** was ignored by **Hemanth V. Alluri**.""" expected_message = """\nIssue **Exception: program has entered an invalid state.** was ignored by **Hemanth V. Alluri**."""
self.send_and_test_stream_message('issue_ignored', expected_topic, expected_message) self.check_webhook("issue_ignored", expected_topic, expected_message)
def test_issue_resolved(self) -> None: def test_issue_resolved(self) -> None:
expected_topic = "Exception: program has entered an invalid state." expected_topic = "Exception: program has entered an invalid state."
expected_message = """\nIssue **Exception: program has entered an invalid state.** was marked as resolved by **Hemanth V. Alluri**.""" expected_message = """\nIssue **Exception: program has entered an invalid state.** was marked as resolved by **Hemanth V. Alluri**."""
self.send_and_test_stream_message('issue_resolved', expected_topic, expected_message) self.check_webhook("issue_resolved", expected_topic, expected_message)
def test_deprecated_exception_message(self) -> None: def test_deprecated_exception_message(self) -> None:
expected_topic = "zulip" expected_topic = "zulip"
@ -162,4 +162,4 @@ New [issue](https://sentry.io/zulip/zulip/issues/156699934/) (level: ERROR):
``` quote ``` quote
This is an example python exception This is an example python exception
```""" ```"""
self.send_and_test_stream_message('deprecated_exception_message', expected_topic, expected_message) self.check_webhook("deprecated_exception_message", expected_topic, expected_message)

View File

@ -10,8 +10,12 @@ class SlackWebhookTests(WebhookTestCase):
expected_topic = "channel: general" expected_topic = "channel: general"
expected_message = "**slack_user**: `test\n`" expected_message = "**slack_user**: `test\n`"
self.send_and_test_stream_message('message_info', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "message_info",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_slack_channel_to_stream(self) -> None: def test_slack_channel_to_stream(self) -> None:
@ -19,8 +23,12 @@ class SlackWebhookTests(WebhookTestCase):
self.url = "{}{}".format(self.url, "&channels_map_to_topics=0") self.url = "{}{}".format(self.url, "&channels_map_to_topics=0")
expected_topic = "Message from Slack" expected_topic = "Message from Slack"
expected_message = "**slack_user**: `test\n`" expected_message = "**slack_user**: `test\n`"
self.send_and_test_stream_message('message_info', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "message_info",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_missing_data_user_name(self) -> None: def test_missing_data_user_name(self) -> None:

View File

@ -12,10 +12,8 @@ class SlackIncomingHookTests(WebhookTestCase):
Hello, world. Hello, world.
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'text', "text", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_message_as_www_urlencoded(self) -> None: def test_message_as_www_urlencoded(self) -> None:
@ -24,8 +22,8 @@ Hello, world.
:zap: chris has started deploying project tag v0.0.2rc10 to staging :zap: chris has started deploying project tag v0.0.2rc10 to staging
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'urlencoded_text', "urlencoded_text",
expected_topic, expected_topic,
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
@ -40,10 +38,8 @@ Danny Torrence left the following review for your property:
[Haunted hotel image](https://is5-ssl.mzstatic.com/image/thumb/Purple3/v4/d3/72/5c/d3725c8f-c642-5d69-1904-aa36e4297885/source/256x256bb.jpg) [Haunted hotel image](https://is5-ssl.mzstatic.com/image/thumb/Purple3/v4/d3/72/5c/d3725c8f-c642-5d69-1904-aa36e4297885/source/256x256bb.jpg)
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'actions', "actions", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_message_with_blocks(self) -> None: def test_message_with_blocks(self) -> None:
@ -55,10 +51,8 @@ Danny Torrence left the following review for your property:
[Haunted hotel image](https://is5-ssl.mzstatic.com/image/thumb/Purple3/v4/d3/72/5c/d3725c8f-c642-5d69-1904-aa36e4297885/source/256x256bb.jpg) [Haunted hotel image](https://is5-ssl.mzstatic.com/image/thumb/Purple3/v4/d3/72/5c/d3725c8f-c642-5d69-1904-aa36e4297885/source/256x256bb.jpg)
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'blocks', "blocks", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def test_message_with_attachment(self) -> None: def test_message_with_attachment(self) -> None:
@ -85,10 +79,8 @@ Danny Torrence left the following review for your property:
**severity:** `critical` **severity:** `critical`
""".strip() """.strip()
self.send_and_test_stream_message( self.check_webhook(
'attachment', "attachment", expected_topic, expected_message,
expected_topic,
expected_message,
) )
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:

View File

@ -18,8 +18,12 @@ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316175)):
* **Status**: failed :thumbs_down: * **Status**: failed :thumbs_down:
""".strip() """.strip()
self.send_and_test_stream_message('build_001', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "build_001",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_solano_message_002(self) -> None: def test_solano_message_002(self) -> None:
""" """
@ -33,8 +37,12 @@ Build update (see [build log](https://ci.solanolabs.com:443/reports/3316723)):
* **Status**: failed :thumbs_down: * **Status**: failed :thumbs_down:
""".strip() """.strip()
self.send_and_test_stream_message('build_002', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "build_002",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_solano_message_received(self) -> None: def test_solano_message_received(self) -> None:
""" """
@ -48,15 +56,23 @@ Build update (see [build log](https://ci.solanolabs.com:443/reports/3317799)):
* **Status**: running :arrows_counterclockwise: * **Status**: running :arrows_counterclockwise:
""".strip() """.strip()
self.send_and_test_stream_message('received', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "received",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_solano_test_message(self) -> None: def test_solano_test_message(self) -> None:
expected_topic = 'build update' expected_topic = 'build update'
expected_message = "Solano webhook set up correctly." expected_message = "Solano webhook set up correctly."
self.send_and_test_stream_message('test', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "test",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data(self.FIXTURE_DIR_NAME, fixture_name, file_type="json") return self.webhook_fixture_data(self.FIXTURE_DIR_NAME, fixture_name, file_type="json")

View File

@ -21,10 +21,12 @@ Splunk alert from saved search:
""".strip() """.strip()
# using fixture named splunk_search_one_result, execute this test # using fixture named splunk_search_one_result, execute this test
self.send_and_test_stream_message('search_one_result', self.check_webhook(
expected_topic, "search_one_result",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_splunk_short_search_name(self) -> None: def test_splunk_short_search_name(self) -> None:
@ -38,10 +40,12 @@ Splunk alert from saved search:
* **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root` * **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root`
""".strip() """.strip()
self.send_and_test_stream_message('short_search_name', self.check_webhook(
expected_topic, "short_search_name",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_splunk_long_search_name(self) -> None: def test_splunk_long_search_name(self) -> None:
@ -55,10 +59,12 @@ Splunk alert from saved search:
* **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root` * **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root`
""".strip() """.strip()
self.send_and_test_stream_message('long_search_name', self.check_webhook(
expected_topic, "long_search_name",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_splunk_missing_results_link(self) -> None: def test_splunk_missing_results_link(self) -> None:
@ -73,10 +79,12 @@ Splunk alert from saved search:
* **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root` * **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root`
""".strip() """.strip()
self.send_and_test_stream_message('missing_results_link', self.check_webhook(
expected_topic, "missing_results_link",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_splunk_missing_search_name(self) -> None: def test_splunk_missing_search_name(self) -> None:
@ -91,10 +99,12 @@ Splunk alert from saved search:
* **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root` * **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root`
""".strip() """.strip()
self.send_and_test_stream_message('missing_search_name', self.check_webhook(
expected_topic, "missing_search_name",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_splunk_missing_host(self) -> None: def test_splunk_missing_host(self) -> None:
@ -109,10 +119,12 @@ Splunk alert from saved search:
* **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root` * **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root`
""".strip() """.strip()
self.send_and_test_stream_message('missing_host', self.check_webhook(
expected_topic, "missing_host",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_splunk_missing_source(self) -> None: def test_splunk_missing_source(self) -> None:
@ -127,10 +139,12 @@ Splunk alert from saved search:
* **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root` * **Raw**: `Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root`
""".strip() """.strip()
self.send_and_test_stream_message('missing_source', self.check_webhook(
expected_topic, "missing_source",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_splunk_missing_raw(self) -> None: def test_splunk_missing_raw(self) -> None:
@ -145,10 +159,12 @@ Splunk alert from saved search:
* **Raw**: `Missing _raw` * **Raw**: `Missing _raw`
""".strip() """.strip()
self.send_and_test_stream_message('missing_raw', self.check_webhook(
expected_topic, "missing_raw",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("splunk", fixture_name, file_type="json") return self.webhook_fixture_data("splunk", fixture_name, file_type="json")

View File

@ -12,10 +12,12 @@ class StatuspageHookTests(WebhookTestCase):
* State: **identified** * State: **identified**
* Description: We just encountered that database queries are timing out resulting in inconvenience to our end users...we'll do quick fix latest by tomorrow !!! * Description: We just encountered that database queries are timing out resulting in inconvenience to our end users...we'll do quick fix latest by tomorrow !!!
""".strip() """.strip()
self.send_and_test_stream_message('incident_created', self.check_webhook(
expected_topic, "incident_created",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_statuspage_incident_update(self) -> None: def test_statuspage_incident_update(self) -> None:
expected_topic = "Database query delays: All Systems Operational" expected_topic = "Database query delays: All Systems Operational"
@ -24,18 +26,22 @@ class StatuspageHookTests(WebhookTestCase):
* State: **resolved** * State: **resolved**
* Description: The database issue is resolved. * Description: The database issue is resolved.
""".strip() """.strip()
self.send_and_test_stream_message('incident_update', self.check_webhook(
expected_topic, "incident_update",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_statuspage_component(self) -> None: def test_statuspage_component(self) -> None:
expected_topic = "Database component: Service Under Maintenance" expected_topic = "Database component: Service Under Maintenance"
expected_message = "**Database component** has changed status from **operational** to **under_maintenance**." expected_message = "**Database component** has changed status from **operational** to **under_maintenance**."
self.send_and_test_stream_message('component_status_update', self.check_webhook(
expected_topic, "component_status_update",
expected_message, expected_topic,
content_type="application/x-www-form-urlencoded") expected_message,
content_type="application/x-www-form-urlencoded",
)
def get_body(self, fixture_name: str) -> str: def get_body(self, fixture_name: str) -> str:
return self.webhook_fixture_data("statuspage", fixture_name, file_type="json") return self.webhook_fixture_data("statuspage", fixture_name, file_type="json")

View File

@ -12,52 +12,84 @@ class StripeHookTests(WebhookTestCase):
def test_charge_dispute_closed(self) -> None: def test_charge_dispute_closed(self) -> None:
expected_topic = "disputes" expected_topic = "disputes"
expected_message = "[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) closed. Current status: won." expected_message = "[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) closed. Current status: won."
self.send_and_test_stream_message('charge_dispute_closed', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "charge_dispute_closed",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_charge_dispute_created(self) -> None: def test_charge_dispute_created(self) -> None:
expected_topic = "disputes" expected_topic = "disputes"
expected_message = "[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) created. Current status: needs response." expected_message = "[Dispute](https://dashboard.stripe.com/disputes/dp_00000000000000) created. Current status: needs response."
self.send_and_test_stream_message('charge_dispute_created', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "charge_dispute_created",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_charge_failed(self) -> None: def test_charge_failed(self) -> None:
expected_topic = "charges" expected_topic = "charges"
expected_message = "[Charge](https://dashboard.stripe.com/charges/ch_00000000000000) for 1.00 AUD failed" expected_message = "[Charge](https://dashboard.stripe.com/charges/ch_00000000000000) for 1.00 AUD failed"
self.send_and_test_stream_message('charge_failed', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "charge_failed",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# Credit card charge # Credit card charge
def test_charge_succeeded__card(self) -> None: def test_charge_succeeded__card(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Charge](https://dashboard.stripe.com/charges/ch_000000000000000000000000) for 1.00 AUD succeeded" expected_message = "[Charge](https://dashboard.stripe.com/charges/ch_000000000000000000000000) for 1.00 AUD succeeded"
self.send_and_test_stream_message('charge_succeeded__card', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "charge_succeeded__card",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
# ACH payment (really a 'payment', rather than a 'charge') # ACH payment (really a 'payment', rather than a 'charge')
def test_charge_succeeded__invoice(self) -> None: def test_charge_succeeded__invoice(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Payment](https://dashboard.stripe.com/payments/py_000000000000000000000000) for $1.00 succeeded" expected_message = "[Payment](https://dashboard.stripe.com/payments/py_000000000000000000000000) for $1.00 succeeded"
self.send_and_test_stream_message('charge_succeeded__invoice', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "charge_succeeded__invoice",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_created(self) -> None: def test_customer_created(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created" expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created"
self.send_and_test_stream_message('customer_created', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_created",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_created_email(self) -> None: def test_customer_created_email(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created\nEmail: example@abc.com" expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) created\nEmail: example@abc.com"
self.send_and_test_stream_message('customer_created_email', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_created_email",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_deleted(self) -> None: def test_customer_deleted(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) deleted" expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) deleted"
self.send_and_test_stream_message('customer_deleted', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_deleted",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_subscription_created(self) -> None: def test_customer_subscription_created(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
@ -66,14 +98,22 @@ class StripeHookTests(WebhookTestCase):
Plan: [flatrate](https://dashboard.stripe.com/plans/plan_E6SQ6RAtmLVtzg) Plan: [flatrate](https://dashboard.stripe.com/plans/plan_E6SQ6RAtmLVtzg)
Quantity: 800 Quantity: 800
Billing method: send invoice""" Billing method: send invoice"""
self.send_and_test_stream_message('customer_subscription_created', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_subscription_created",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_subscription_deleted(self) -> None: def test_customer_subscription_deleted(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Subscription](https://dashboard.stripe.com/subscriptions/sub_00000000000000) deleted" expected_message = "[Subscription](https://dashboard.stripe.com/subscriptions/sub_00000000000000) deleted"
self.send_and_test_stream_message('customer_subscription_deleted', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_subscription_deleted",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_subscription_updated(self) -> None: def test_customer_subscription_updated(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
@ -86,8 +126,12 @@ Billing method: send invoice"""
* Status is now trialing * Status is now trialing
* Trial end is now Nov 01, 2019, 12:00:00 UTC * Trial end is now Nov 01, 2019, 12:00:00 UTC
* Trial start is now Dec 06, 2018, 05:53:55 UTC""" * Trial start is now Dec 06, 2018, 05:53:55 UTC"""
self.send_and_test_stream_message('customer_subscription_updated', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_subscription_updated",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_subscription_trial_will_end(self) -> None: def test_customer_subscription_trial_will_end(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
@ -95,28 +139,43 @@ Billing method: send invoice"""
# 3 days before the end of the trial, plus a little bit to make sure the rounding is working # 3 days before the end of the trial, plus a little bit to make sure the rounding is working
with mock.patch('time.time', return_value=1480892861 - 3*3600*24 + 100): with mock.patch('time.time', return_value=1480892861 - 3*3600*24 + 100):
# use fixture named stripe_customer_subscription_trial_will_end # use fixture named stripe_customer_subscription_trial_will_end
self.send_and_test_stream_message('customer_subscription_trial_will_end', self.check_webhook(
expected_topic, expected_message, "customer_subscription_trial_will_end",
content_type="application/x-www-form-urlencoded") expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_updated__account_balance(self) -> None: def test_customer_updated__account_balance(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) updated" + \ expected_message = "[Customer](https://dashboard.stripe.com/customers/cus_00000000000000) updated" + \
"\n* Account balance is now 100" "\n* Account balance is now 100"
self.send_and_test_stream_message('customer_updated__account_balance', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_updated__account_balance",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_customer_discount_created(self) -> None: def test_customer_discount_created(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "Discount created ([25.5% off](https://dashboard.stripe.com/coupons/25_00000000000000))." expected_message = "Discount created ([25.5% off](https://dashboard.stripe.com/coupons/25_00000000000000))."
self.send_and_test_stream_message('customer_discount_created', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "customer_discount_created",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_invoice_payment_failed(self) -> None: def test_invoice_payment_failed(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Invoice](https://dashboard.stripe.com/invoices/in_00000000000000) payment failed" expected_message = "[Invoice](https://dashboard.stripe.com/invoices/in_00000000000000) payment failed"
self.send_and_test_stream_message('invoice_payment_failed', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "invoice_payment_failed",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_invoice_created(self) -> None: def test_invoice_created(self) -> None:
expected_topic = "cus_HH97asvHvaYQYp" expected_topic = "cus_HH97asvHvaYQYp"
@ -125,13 +184,13 @@ Billing method: send invoice"""
Total: 0.00 INR Total: 0.00 INR
Amount due: 0.00 INR Amount due: 0.00 INR
""".strip() """.strip()
self.send_and_test_stream_message("invoice_created", expected_topic, expected_message) self.check_webhook("invoice_created", expected_topic, expected_message)
def test_invoiceitem_created(self) -> None: def test_invoiceitem_created(self) -> None:
expected_topic = "cus_00000000000000" expected_topic = "cus_00000000000000"
expected_message = "[Invoice item](https://dashboard.stripe.com/invoiceitems/ii_00000000000000) created for 10.00 CAD" expected_message = "[Invoice item](https://dashboard.stripe.com/invoiceitems/ii_00000000000000) created for 10.00 CAD"
self.send_and_test_stream_message( self.check_webhook(
'invoiceitem_created', "invoiceitem_created",
expected_topic, expected_topic,
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
@ -140,8 +199,8 @@ Amount due: 0.00 INR
def test_invoice_paid(self) -> None: def test_invoice_paid(self) -> None:
expected_topic = "cus_FDmrSwQt9Fck5M" expected_topic = "cus_FDmrSwQt9Fck5M"
expected_message = "[Invoice](https://dashboard.stripe.com/invoices/in_1EjLINHuGUuNWDDZjDf2WNqd) is now paid" expected_message = "[Invoice](https://dashboard.stripe.com/invoices/in_1EjLINHuGUuNWDDZjDf2WNqd) is now paid"
self.send_and_test_stream_message( self.check_webhook(
'invoice_updated__paid', "invoice_updated__paid",
expected_topic, expected_topic,
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
@ -150,12 +209,12 @@ Amount due: 0.00 INR
def test_refund_event(self) -> None: def test_refund_event(self) -> None:
expected_topic = "refunds" expected_topic = "refunds"
expected_message = "A [refund](https://dashboard.stripe.com/refunds/re_1Gib6ZHLwdCOCoR7VrzCnXlj) for a [charge](https://dashboard.stripe.com/charges/ch_1Gib61HLwdCOCoR71rnkccye) of 30000000 INR was updated." expected_message = "A [refund](https://dashboard.stripe.com/refunds/re_1Gib6ZHLwdCOCoR7VrzCnXlj) for a [charge](https://dashboard.stripe.com/charges/ch_1Gib61HLwdCOCoR71rnkccye) of 30000000 INR was updated."
self.send_and_test_stream_message('refund_event', expected_topic, expected_message) self.check_webhook("refund_event", expected_topic, expected_message)
def test_pseudo_refund_event(self) -> None: def test_pseudo_refund_event(self) -> None:
expected_topic = "refunds" expected_topic = "refunds"
expected_message = "A [refund](https://dashboard.stripe.com/refunds/pyr_abcde12345ABCDF) for a [payment](https://dashboard.stripe.com/payments/py_abcde12345ABCDG) of 1234 EUR was updated." expected_message = "A [refund](https://dashboard.stripe.com/refunds/pyr_abcde12345ABCDF) for a [payment](https://dashboard.stripe.com/payments/py_abcde12345ABCDG) of 1234 EUR was updated."
self.send_and_test_stream_message('pseudo_refund_event', expected_topic, expected_message) self.check_webhook("pseudo_refund_event", expected_topic, expected_message)
@patch('zerver.webhooks.stripe.view.check_send_webhook_message') @patch('zerver.webhooks.stripe.view.check_send_webhook_message')
def test_account_updated_without_previous_attributes_ignore( def test_account_updated_without_previous_attributes_ignore(

View File

@ -13,284 +13,284 @@ class TaigaHookTests(WebhookTestCase):
def test_taiga_userstory_deleted(self) -> None: def test_taiga_userstory_deleted(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted user story **New userstory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted user story **New userstory**.'
self.send_and_test_stream_message("userstory_deleted", self.TOPIC, message) self.check_webhook("userstory_deleted", self.TOPIC, message)
def test_taiga_userstory_created(self) -> None: def test_taiga_userstory_created(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created user story **New userstory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created user story **New userstory**.'
self.send_and_test_stream_message("userstory_created", self.TOPIC, message) self.check_webhook("userstory_created", self.TOPIC, message)
def test_taiga_userstory_changed_unblocked(self) -> None: def test_taiga_userstory_changed_unblocked(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_unblocked", self.TOPIC, message) self.check_webhook("userstory_changed_unblocked", self.TOPIC, message)
def test_taiga_userstory_changed_subject(self) -> None: def test_taiga_userstory_changed_subject(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed user story from UserStory to **UserStoryNewSubject**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed user story from UserStory to **UserStoryNewSubject**.'
self.send_and_test_stream_message("userstory_changed_subject", self.TOPIC, message) self.check_webhook("userstory_changed_subject", self.TOPIC, message)
def test_taiga_userstory_changed_status(self) -> None: def test_taiga_userstory_changed_status(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Ready to In progress.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Ready to In progress.'
self.send_and_test_stream_message("userstory_changed_status", self.TOPIC, message) self.check_webhook("userstory_changed_status", self.TOPIC, message)
def test_taiga_userstory_changed_reassigned(self) -> None: def test_taiga_userstory_changed_reassigned(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned user story **UserStory** from TomaszKolek to HanSolo.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned user story **UserStory** from TomaszKolek to HanSolo.'
self.send_and_test_stream_message("userstory_changed_reassigned", self.TOPIC, message) self.check_webhook("userstory_changed_reassigned", self.TOPIC, message)
def test_taiga_userstory_changed_unassigned(self) -> None: def test_taiga_userstory_changed_unassigned(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unassigned user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unassigned user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_unassigned", self.TOPIC, message) self.check_webhook("userstory_changed_unassigned", self.TOPIC, message)
def test_taiga_userstory_changed_points(self) -> None: def test_taiga_userstory_changed_points(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimation of user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimation of user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_points", self.TOPIC, message) self.check_webhook("userstory_changed_points", self.TOPIC, message)
def test_taiga_userstory_changed_new_sprint(self) -> None: def test_taiga_userstory_changed_new_sprint(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) added user story **UserStory** to sprint Sprint1.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) added user story **UserStory** to sprint Sprint1.'
self.send_and_test_stream_message("userstory_changed_new_sprint", self.TOPIC, message) self.check_webhook("userstory_changed_new_sprint", self.TOPIC, message)
def test_taiga_userstory_changed_sprint(self) -> None: def test_taiga_userstory_changed_sprint(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed sprint of user story **UserStory** from Sprint1 to Sprint2.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed sprint of user story **UserStory** from Sprint1 to Sprint2.'
self.send_and_test_stream_message("userstory_changed_sprint", self.TOPIC, message) self.check_webhook("userstory_changed_sprint", self.TOPIC, message)
def test_taiga_userstory_changed_remove_sprint(self) -> None: def test_taiga_userstory_changed_remove_sprint(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) removed user story **UserStory** from sprint Sprint2.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) removed user story **UserStory** from sprint Sprint2.'
self.send_and_test_stream_message("userstory_changed_remove_sprint", self.TOPIC, message) self.check_webhook("userstory_changed_remove_sprint", self.TOPIC, message)
def test_taiga_userstory_changed_description(self) -> None: def test_taiga_userstory_changed_description(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_description", self.TOPIC, message) self.check_webhook("userstory_changed_description", self.TOPIC, message)
def test_taiga_userstory_changed_closed(self) -> None: def test_taiga_userstory_changed_closed(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from New to Done.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) closed user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from New to Done.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) closed user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_closed", self.TOPIC, message) self.check_webhook("userstory_changed_closed", self.TOPIC, message)
def test_taiga_userstory_changed_reopened(self) -> None: def test_taiga_userstory_changed_reopened(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Done to Ready.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reopened user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of user story **UserStory** from Done to Ready.\n[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reopened user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_reopened", self.TOPIC, message) self.check_webhook("userstory_changed_reopened", self.TOPIC, message)
def test_taiga_userstory_changed_blocked(self) -> None: def test_taiga_userstory_changed_blocked(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_blocked", self.TOPIC, message) self.check_webhook("userstory_changed_blocked", self.TOPIC, message)
def test_taiga_userstory_changed_assigned(self) -> None: def test_taiga_userstory_changed_assigned(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned user story **UserStory** to TomaszKolek.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned user story **UserStory** to TomaszKolek.'
self.send_and_test_stream_message("userstory_changed_assigned", self.TOPIC, message) self.check_webhook("userstory_changed_assigned", self.TOPIC, message)
def test_taiga_userstory_comment_added(self) -> None: def test_taiga_userstory_comment_added(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on user story **UserStory**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on user story **UserStory**.'
self.send_and_test_stream_message("userstory_changed_comment_added", self.TOPIC, message) self.check_webhook("userstory_changed_comment_added", self.TOPIC, message)
def test_taiga_userstory_changed_due_date(self) -> None: def test_taiga_userstory_changed_due_date(self) -> None:
message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of user story ' + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of user story ' +
'[Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) from 2020-02-15 to 2020-02-22.') '[Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) from 2020-02-15 to 2020-02-22.')
self.send_and_test_stream_message("userstory_changed_due_date", self.TOPIC, message) self.check_webhook("userstory_changed_due_date", self.TOPIC, message)
def test_taiga_userstory_changed_new_due_date(self) -> None: def test_taiga_userstory_changed_new_due_date(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of user story [random](https://tree.taiga.io/project/orientor-sd/us/58) to 2020-02-15.' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of user story [random](https://tree.taiga.io/project/orientor-sd/us/58) to 2020-02-15.'
self.send_and_test_stream_message("userstory_changed_new_due_date", self.TOPIC, message) self.check_webhook("userstory_changed_new_due_date", self.TOPIC, message)
def test_taiga_task_created(self) -> None: def test_taiga_task_created(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created task **New Task**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created task **New Task**.'
self.send_and_test_stream_message("task_created", self.TOPIC, message) self.check_webhook("task_created", self.TOPIC, message)
def test_taiga_task_changed_user_stories(self) -> None: def test_taiga_task_changed_user_stories(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added task **Get this task done** to sprint Another one.\n[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) moved task **Get this task done** from user story #7 Yaar ne scirra! to #8 A related user story, which is epic.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added task **Get this task done** to sprint Another one.\n[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) moved task **Get this task done** from user story #7 Yaar ne scirra! to #8 A related user story, which is epic.'
self.send_and_test_stream_message("task_changed_user_stories", self.TOPIC, message) self.check_webhook("task_changed_user_stories", self.TOPIC, message)
def test_taiga_task_changed_status(self) -> None: def test_taiga_task_changed_status(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of task **New Task** from New to In progress.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of task **New Task** from New to In progress.'
self.send_and_test_stream_message("task_changed_status", self.TOPIC, message) self.check_webhook("task_changed_status", self.TOPIC, message)
def test_taiga_task_changed_blocked(self) -> None: def test_taiga_task_changed_blocked(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked task **New Task**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) blocked task **New Task**.'
self.send_and_test_stream_message("task_changed_blocked", self.TOPIC, message) self.check_webhook("task_changed_blocked", self.TOPIC, message)
def test_taiga_task_changed_blocked_link(self) -> None: def test_taiga_task_changed_blocked_link(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked task [nice task](https://tree.taiga.io/project/orientor-sd/task/56).' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked task [nice task](https://tree.taiga.io/project/orientor-sd/task/56).'
self.send_and_test_stream_message("task_changed_blocked_link", self.TOPIC, message) self.check_webhook("task_changed_blocked_link", self.TOPIC, message)
def test_taiga_task_changed_unblocked(self) -> None: def test_taiga_task_changed_unblocked(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked task **New Task**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) unblocked task **New Task**.'
self.send_and_test_stream_message("task_changed_unblocked", self.TOPIC, message) self.check_webhook("task_changed_unblocked", self.TOPIC, message)
def test_taiga_task_changed_assigned(self) -> None: def test_taiga_task_changed_assigned(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned task **New Task** to TomaszKolek.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned task **New Task** to TomaszKolek.'
self.send_and_test_stream_message("task_changed_assigned", self.TOPIC, message) self.check_webhook("task_changed_assigned", self.TOPIC, message)
def test_taiga_task_changed_reassigned(self) -> None: def test_taiga_task_changed_reassigned(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned task **New Task** from HanSolo to TomaszKolek.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned task **New Task** from HanSolo to TomaszKolek.'
self.send_and_test_stream_message("task_changed_reassigned", self.TOPIC, message) self.check_webhook("task_changed_reassigned", self.TOPIC, message)
def test_taiga_task_changed_subject(self) -> None: def test_taiga_task_changed_subject(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed task New Task to **New Task Subject**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed task New Task to **New Task Subject**.'
self.send_and_test_stream_message("task_changed_subject", self.TOPIC, message) self.check_webhook("task_changed_subject", self.TOPIC, message)
def test_taiga_task_changed_description(self) -> None: def test_taiga_task_changed_description(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of task **New Task**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of task **New Task**.'
self.send_and_test_stream_message("task_changed_description", self.TOPIC, message) self.check_webhook("task_changed_description", self.TOPIC, message)
def test_taiga_task_deleted(self) -> None: def test_taiga_task_deleted(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted task **New Task**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted task **New Task**.'
self.send_and_test_stream_message("task_deleted", self.TOPIC, message) self.check_webhook("task_deleted", self.TOPIC, message)
def test_taiga_task_changed_comment_added(self) -> None: def test_taiga_task_changed_comment_added(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on task **New Task**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on task **New Task**.'
self.send_and_test_stream_message("task_changed_comment_added", self.TOPIC, message) self.check_webhook("task_changed_comment_added", self.TOPIC, message)
def test_taiga_task_changed_due_date(self) -> None: def test_taiga_task_changed_due_date(self) -> None:
message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of task' + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of task' +
' [nice task](https://tree.taiga.io/project/orientor-sd/task/56) from 2020-02-22 to 2020-02-15.') ' [nice task](https://tree.taiga.io/project/orientor-sd/task/56) from 2020-02-22 to 2020-02-15.')
self.send_and_test_stream_message("task_changed_due_date", self.TOPIC, message) self.check_webhook("task_changed_due_date", self.TOPIC, message)
def test_taiga_task_changed_new_due_date(self) -> None: def test_taiga_task_changed_new_due_date(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of task [nice task](https://tree.taiga.io/project/orientor-sd/task/56) to 2020-02-22.' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of task [nice task](https://tree.taiga.io/project/orientor-sd/task/56) to 2020-02-22.'
self.send_and_test_stream_message("task_changed_new_due_date", self.TOPIC, message) self.check_webhook("task_changed_new_due_date", self.TOPIC, message)
def test_taiga_sprint_created(self) -> None: def test_taiga_sprint_created(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created sprint **New sprint**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created sprint **New sprint**.'
self.send_and_test_stream_message("sprint_created", self.TOPIC, message) self.check_webhook("sprint_created", self.TOPIC, message)
def test_taiga_sprint_deleted(self) -> None: def test_taiga_sprint_deleted(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted sprint **New name**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted sprint **New name**.'
self.send_and_test_stream_message("sprint_deleted", self.TOPIC, message) self.check_webhook("sprint_deleted", self.TOPIC, message)
def test_taiga_sprint_changed_time(self) -> None: def test_taiga_sprint_changed_time(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimated finish of sprint **New sprint** from 2017-01-24 to 2017-01-25.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed estimated finish of sprint **New sprint** from 2017-01-24 to 2017-01-25.'
self.send_and_test_stream_message("sprint_changed_time", self.TOPIC, message) self.check_webhook("sprint_changed_time", self.TOPIC, message)
def test_taiga_sprint_changed_name(self) -> None: def test_taiga_sprint_changed_name(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed sprint from New sprint to **New name**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed sprint from New sprint to **New name**.'
self.send_and_test_stream_message("sprint_changed_name", self.TOPIC, message) self.check_webhook("sprint_changed_name", self.TOPIC, message)
def test_taiga_issue_created(self) -> None: def test_taiga_issue_created(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created issue **New issue**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) created issue **New issue**.'
self.send_and_test_stream_message("issue_created", self.TOPIC, message) self.check_webhook("issue_created", self.TOPIC, message)
def test_taiga_issue_created_link(self) -> None: def test_taiga_issue_created_link(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) created issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) created issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).'
self.send_and_test_stream_message("issue_created_link", self.TOPIC, message) self.check_webhook("issue_created_link", self.TOPIC, message)
def test_taiga_issue_deleted(self) -> None: def test_taiga_issue_deleted(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted issue **New issue**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) deleted issue **New issue**.'
self.send_and_test_stream_message("issue_deleted", self.TOPIC, message) self.check_webhook("issue_deleted", self.TOPIC, message)
def test_taiga_issue_changed_assigned(self) -> None: def test_taiga_issue_changed_assigned(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned issue **New issue** to TomaszKolek.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) assigned issue **New issue** to TomaszKolek.'
self.send_and_test_stream_message("issue_changed_assigned", self.TOPIC, message) self.check_webhook("issue_changed_assigned", self.TOPIC, message)
def test_taiga_issue_changed_reassigned(self) -> None: def test_taiga_issue_changed_reassigned(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned issue **New issue** from TomaszKolek to HanSolo.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) reassigned issue **New issue** from TomaszKolek to HanSolo.'
self.send_and_test_stream_message("issue_changed_reassigned", self.TOPIC, message) self.check_webhook("issue_changed_reassigned", self.TOPIC, message)
def test_taiga_issue_changed_subject(self) -> None: def test_taiga_issue_changed_subject(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed issue New issue to **New issueNewSubject**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) renamed issue New issue to **New issueNewSubject**.'
self.send_and_test_stream_message("issue_changed_subject", self.TOPIC, message) self.check_webhook("issue_changed_subject", self.TOPIC, message)
def test_taiga_issue_changed_description(self) -> None: def test_taiga_issue_changed_description(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of issue **New issue**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) updated description of issue **New issue**.'
self.send_and_test_stream_message("issue_changed_description", self.TOPIC, message) self.check_webhook("issue_changed_description", self.TOPIC, message)
def test_taiga_issue_changed_type(self) -> None: def test_taiga_issue_changed_type(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed type of issue **New issue** from Bug to Question.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed type of issue **New issue** from Bug to Question.'
self.send_and_test_stream_message("issue_changed_type", self.TOPIC, message) self.check_webhook("issue_changed_type", self.TOPIC, message)
def test_taiga_issue_changed_status(self) -> None: def test_taiga_issue_changed_status(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of issue **New issue** from New to In progress.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed status of issue **New issue** from New to In progress.'
self.send_and_test_stream_message("issue_changed_status", self.TOPIC, message) self.check_webhook("issue_changed_status", self.TOPIC, message)
def test_taiga_issue_changed_severity(self) -> None: def test_taiga_issue_changed_severity(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed severity of issue **New issue** from Normal to Minor.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed severity of issue **New issue** from Normal to Minor.'
self.send_and_test_stream_message("issue_changed_severity", self.TOPIC, message) self.check_webhook("issue_changed_severity", self.TOPIC, message)
def test_taiga_issue_changed_priority(self) -> None: def test_taiga_issue_changed_priority(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed priority of issue **New issue** from Normal to Low.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) changed priority of issue **New issue** from Normal to Low.'
self.send_and_test_stream_message("issue_changed_priority", self.TOPIC, message) self.check_webhook("issue_changed_priority", self.TOPIC, message)
def test_taiga_issue_changed_comment_added(self) -> None: def test_taiga_issue_changed_comment_added(self) -> None:
message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on issue **New issue**.' message = '[TomaszKolek](https://tree.taiga.io/profile/kolaszek) commented on issue **New issue**.'
self.send_and_test_stream_message("issue_changed_comment_added", self.TOPIC, message) self.check_webhook("issue_changed_comment_added", self.TOPIC, message)
def test_taiga_issue_changed_blocked(self) -> None: def test_taiga_issue_changed_blocked(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) blocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).'
self.send_and_test_stream_message("issue_changed_blocked", self.TOPIC, message) self.check_webhook("issue_changed_blocked", self.TOPIC, message)
def test_taiga_issue_changed_unblocked(self) -> None: def test_taiga_issue_changed_unblocked(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) unblocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) unblocked issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49).'
self.send_and_test_stream_message("issue_changed_unblocked", self.TOPIC, message) self.check_webhook("issue_changed_unblocked", self.TOPIC, message)
def test_taiga_issue_changed_due_date(self) -> None: def test_taiga_issue_changed_due_date(self) -> None:
message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49) ' + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) changed due date of issue [Issues](https://tree.taiga.io/project/orientor-sd/issue/49) ' +
'from 2020-03-08 to 2020-02-22.') 'from 2020-03-08 to 2020-02-22.')
self.send_and_test_stream_message("issue_changed_due_date", self.TOPIC, message) self.check_webhook("issue_changed_due_date", self.TOPIC, message)
def test_taiga_issue_changed_new_due_date(self) -> None: def test_taiga_issue_changed_new_due_date(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to 2020-02-22.' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) set due date of issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to 2020-02-22.'
self.send_and_test_stream_message("issue_changed_new_due_date", self.TOPIC, message) self.check_webhook("issue_changed_new_due_date", self.TOPIC, message)
def test_taiga_issue_changed_new_sprint(self) -> None: def test_taiga_issue_changed_new_sprint(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) added issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to sprint eres.' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) added issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) to sprint eres.'
self.send_and_test_stream_message("issue_changed_new_sprint", self.TOPIC, message) self.check_webhook("issue_changed_new_sprint", self.TOPIC, message)
def test_taiga_issue_changed_remove_sprint(self) -> None: def test_taiga_issue_changed_remove_sprint(self) -> None:
message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) detached issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) from sprint eres.' message = '[Aditya Verma](https://tree.taiga.io/profile/orientor) detached issue [Nice Issue](https://tree.taiga.io/project/orientor-sd/issue/53) from sprint eres.'
self.send_and_test_stream_message("issue_changed_remove_sprint", self.TOPIC, message) self.check_webhook("issue_changed_remove_sprint", self.TOPIC, message)
def test_taiga_epic_created(self) -> None: def test_taiga_epic_created(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) created epic **Zulip is awesome!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) created epic **Zulip is awesome!**.'
self.send_and_test_stream_message("epic_created", self.TOPIC, message) self.check_webhook("epic_created", self.TOPIC, message)
def test_taiga_epic_changed_assigned(self) -> None: def test_taiga_epic_changed_assigned(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) assigned epic **Zulip is awesome!** to Eeshan Garg.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) assigned epic **Zulip is awesome!** to Eeshan Garg.'
self.send_and_test_stream_message("epic_changed_assigned", self.TOPIC, message) self.check_webhook("epic_changed_assigned", self.TOPIC, message)
def test_taiga_epic_changed_unassigned(self) -> None: def test_taiga_epic_changed_unassigned(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unassigned epic **Zulip is awesome!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unassigned epic **Zulip is awesome!**.'
self.send_and_test_stream_message("epic_changed_unassigned", self.TOPIC, message) self.check_webhook("epic_changed_unassigned", self.TOPIC, message)
def test_taiga_epic_changed_reassigned(self) -> None: def test_taiga_epic_changed_reassigned(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) reassigned epic **Zulip is awesome!** from Eeshan Garg to Angela Johnson.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) reassigned epic **Zulip is awesome!** from Eeshan Garg to Angela Johnson.'
self.send_and_test_stream_message("epic_changed_reassigned", self.TOPIC, message) self.check_webhook("epic_changed_reassigned", self.TOPIC, message)
def test_taiga_epic_changed_blocked(self) -> None: def test_taiga_epic_changed_blocked(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) blocked epic **Zulip is awesome!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) blocked epic **Zulip is awesome!**.'
self.send_and_test_stream_message("epic_changed_blocked", self.TOPIC, message) self.check_webhook("epic_changed_blocked", self.TOPIC, message)
def test_taiga_epic_changed_unblocked(self) -> None: def test_taiga_epic_changed_unblocked(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unblocked epic **Zulip is awesome!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) unblocked epic **Zulip is awesome!**.'
self.send_and_test_stream_message("epic_changed_unblocked", self.TOPIC, message) self.check_webhook("epic_changed_unblocked", self.TOPIC, message)
def test_taiga_epic_changed_status(self) -> None: def test_taiga_epic_changed_status(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) changed status of epic **Zulip is awesome!** from New to In progress.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) changed status of epic **Zulip is awesome!** from New to In progress.'
self.send_and_test_stream_message("epic_changed_status", self.TOPIC, message) self.check_webhook("epic_changed_status", self.TOPIC, message)
def test_taiga_epic_changed_renamed(self) -> None: def test_taiga_epic_changed_renamed(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) renamed epic from **Zulip is awesome!** to **Zulip is great!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) renamed epic from **Zulip is awesome!** to **Zulip is great!**.'
self.send_and_test_stream_message("epic_changed_renamed", self.TOPIC, message) self.check_webhook("epic_changed_renamed", self.TOPIC, message)
def test_taiga_epic_changed_description(self) -> None: def test_taiga_epic_changed_description(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) updated description of epic **Zulip is great!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) updated description of epic **Zulip is great!**.'
self.send_and_test_stream_message("epic_changed_description", self.TOPIC, message) self.check_webhook("epic_changed_description", self.TOPIC, message)
def test_taiga_epic_changed_commented(self) -> None: def test_taiga_epic_changed_commented(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) commented on epic **Zulip is great!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) commented on epic **Zulip is great!**.'
self.send_and_test_stream_message("epic_changed_commented", self.TOPIC, message) self.check_webhook("epic_changed_commented", self.TOPIC, message)
def test_taiga_epic_deleted(self) -> None: def test_taiga_epic_deleted(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) deleted epic **Zulip is great!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) deleted epic **Zulip is great!**.'
self.send_and_test_stream_message("epic_deleted", self.TOPIC, message) self.check_webhook("epic_deleted", self.TOPIC, message)
def test_taiga_relateduserstory_created(self) -> None: def test_taiga_relateduserstory_created(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added a related user story **A related user story** to the epic **This is Epic!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) added a related user story **A related user story** to the epic **This is Epic!**.'
self.send_and_test_stream_message("relateduserstory_created", self.TOPIC, message) self.check_webhook("relateduserstory_created", self.TOPIC, message)
def test_taiga_relateduserstory_created_link(self) -> None: def test_taiga_relateduserstory_created_link(self) -> None:
message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) added a related user story [Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) ' + message = ('[Aditya Verma](https://tree.taiga.io/profile/orientor) added a related user story [Nice Issue](https://tree.taiga.io/project/orientor-sd/us/54) ' +
'to the epic [ASAS](https://tree.taiga.io/project/orientor-sd/epic/42).') 'to the epic [ASAS](https://tree.taiga.io/project/orientor-sd/epic/42).')
self.send_and_test_stream_message("relateduserstory_created_link", self.TOPIC, message) self.check_webhook("relateduserstory_created_link", self.TOPIC, message)
def test_taiga_relateduserstory_deleted(self) -> None: def test_taiga_relateduserstory_deleted(self) -> None:
message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) removed a related user story **A related user story, which is epic** from the epic **This is Epic!**.' message = '[Eeshan Garg](https://tree.taiga.io/profile/eeshangarg) removed a related user story **A related user story, which is epic** from the epic **This is Epic!**.'
self.send_and_test_stream_message("relateduserstory_deleted", self.TOPIC, message) self.check_webhook("relateduserstory_deleted", self.TOPIC, message)
def test_taiga_webhook_test(self) -> None: def test_taiga_webhook_test(self) -> None:
message = '[Jan](https://tree.taiga.io/profile/kostek) triggered a test of the Taiga integration.' message = '[Jan](https://tree.taiga.io/profile/kostek) triggered a test of the Taiga integration.'
self.send_and_test_stream_message("webhook_test", self.TOPIC, message) self.check_webhook("webhook_test", self.TOPIC, message)

View File

@ -14,24 +14,24 @@ class TeamcityHookTests(WebhookTestCase):
def test_teamcity_success(self) -> None: def test_teamcity_success(self) -> None:
expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
self.send_and_test_stream_message('success', self.TOPIC, expected_message) self.check_webhook("success", self.TOPIC, expected_message)
def test_teamcity_success_branch(self) -> None: def test_teamcity_success_branch(self) -> None:
expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
expected_topic = "Project :: Compile (MyBranch)" expected_topic = "Project :: Compile (MyBranch)"
self.send_and_test_stream_message('success_branch', expected_topic, expected_message) self.check_webhook("success_branch", expected_topic, expected_message)
def test_teamcity_broken(self) -> None: def test_teamcity_broken(self) -> None:
expected_message = "Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." expected_message = "Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
self.send_and_test_stream_message('broken', self.TOPIC, expected_message) self.check_webhook("broken", self.TOPIC, expected_message)
def test_teamcity_failure(self) -> None: def test_teamcity_failure(self) -> None:
expected_message = "Project :: Compile build 5535 - CL 123456 is still broken with status Exit code 1! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." expected_message = "Project :: Compile build 5535 - CL 123456 is still broken with status Exit code 1! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
self.send_and_test_stream_message('failure', self.TOPIC, expected_message) self.check_webhook("failure", self.TOPIC, expected_message)
def test_teamcity_fixed(self) -> None: def test_teamcity_fixed(self) -> None:
expected_message = "Project :: Compile build 5535 - CL 123456 has been fixed! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." expected_message = "Project :: Compile build 5535 - CL 123456 has been fixed! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
self.send_and_test_stream_message('fixed', self.TOPIC, expected_message) self.check_webhook("fixed", self.TOPIC, expected_message)
def test_teamcity_personal(self) -> None: def test_teamcity_personal(self) -> None:
expected_message = "Your personal build for Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)." expected_message = "Your personal build for Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."

View File

@ -21,9 +21,9 @@ class ThinkstHookTests(WebhookTestCase):
"**Field3:** VALUE3" "**Field3:** VALUE3"
) )
self.send_and_test_stream_message( self.check_webhook(
'canary_dummy', "canary_dummy",
'canary alert - 0000000testnode', "canary alert - 0000000testnode",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -46,9 +46,9 @@ class ThinkstHookTests(WebhookTestCase):
"**Background Context:** You have had 8 incidents from 1.0.0.1 previously." "**Background Context:** You have had 8 incidents from 1.0.0.1 previously."
) )
self.send_and_test_stream_message( self.check_webhook(
'canary_consolidated_port_scan', "canary_consolidated_port_scan",
'canary alert - foo-bar', "canary alert - foo-bar",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -73,9 +73,9 @@ class ThinkstHookTests(WebhookTestCase):
"**Background Context:** You have had 20 incidents from 1.1.1.1 previously." "**Background Context:** You have had 20 incidents from 1.1.1.1 previously."
) )
self.send_and_test_stream_message( self.check_webhook(
'canary_file_access', "canary_file_access",
'canary alert - bar-foo', "canary alert - bar-foo",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -95,9 +95,9 @@ class ThinkstHookTests(WebhookTestCase):
"**Partial Ports:** 443, 554, 80, 1723, 22" "**Partial Ports:** 443, 554, 80, 1723, 22"
) )
self.send_and_test_stream_message( self.check_webhook(
'canary_host_port_scan', "canary_host_port_scan",
'canary alert - foo-bar', "canary alert - foo-bar",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -120,9 +120,9 @@ class ThinkstHookTests(WebhookTestCase):
"**Background Context:** You have had 14 incidents from 1.1.1.1 previously." "**Background Context:** You have had 14 incidents from 1.1.1.1 previously."
) )
self.send_and_test_stream_message( self.check_webhook(
'canary_http_login', "canary_http_login",
'canary alert - foo-bar', "canary alert - foo-bar",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -144,9 +144,9 @@ class ThinkstHookTests(WebhookTestCase):
"**Background Context:** You have had 9 incidents from 1.1.1.1 previously." "**Background Context:** You have had 9 incidents from 1.1.1.1 previously."
) )
self.send_and_test_stream_message( self.check_webhook(
'canary_ssh_login', "canary_ssh_login",
'canary alert - foo-bar', "canary alert - foo-bar",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -167,9 +167,9 @@ class ThinkstHookTests(WebhookTestCase):
"**Field3:** VALUE3" "**Field3:** VALUE3"
) )
self.send_and_test_stream_message( self.check_webhook(
'canary_dummy', "canary_dummy",
'foo', "foo",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -194,9 +194,9 @@ class ThinkstHookTests(WebhookTestCase):
"**User-Agent:** Mozilla/4.0 (compatible; ms-office; MSOffice 16)" "**User-Agent:** Mozilla/4.0 (compatible; ms-office; MSOffice 16)"
) )
self.send_and_test_stream_message( self.check_webhook(
'canarytoken_msword', "canarytoken_msword",
'canarytoken alert - test document', "canarytoken alert - test document",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -224,9 +224,9 @@ class ThinkstHookTests(WebhookTestCase):
"Firefox/78.0" "Firefox/78.0"
) )
self.send_and_test_stream_message( self.check_webhook(
'canarytoken_remote_image', "canarytoken_remote_image",
'canarytoken alert - test image', "canarytoken alert - test image",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )
@ -252,9 +252,9 @@ class ThinkstHookTests(WebhookTestCase):
"**User-Agent:** Mozilla/4.0 (compatible; ms-office; MSOffice 16)" "**User-Agent:** Mozilla/4.0 (compatible; ms-office; MSOffice 16)"
) )
self.send_and_test_stream_message( self.check_webhook(
'canarytoken_msword', "canarytoken_msword",
'foo', "foo",
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",
) )

View File

@ -25,7 +25,7 @@ class TransifexHookTests(WebhookTestCase):
language=self.LANGUAGE, language=self.LANGUAGE,
resource=self.RESOURCE, resource=self.RESOURCE,
) )
self.send_and_test_stream_message("", expected_topic, expected_message) self.check_webhook("", expected_topic, expected_message)
def test_transifex_translated_message(self) -> None: def test_transifex_translated_message(self) -> None:
self.REVIEWED = False self.REVIEWED = False
@ -37,7 +37,7 @@ class TransifexHookTests(WebhookTestCase):
language=self.LANGUAGE, language=self.LANGUAGE,
resource=self.RESOURCE, resource=self.RESOURCE,
) )
self.send_and_test_stream_message("", expected_topic, expected_message) self.check_webhook("", expected_topic, expected_message)
def get_body(self, fixture_name: str) -> Dict[str, Any]: def get_body(self, fixture_name: str) -> Dict[str, Any]:
return {} return {}

View File

@ -21,11 +21,8 @@ class TravisHookTests(WebhookTestCase):
"n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht" "n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht"
"tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)") "tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)")
self.send_and_test_stream_message( self.check_webhook(
'build', "build", self.TOPIC, expected_message, content_type="application/x-www-form-urlencoded",
self.TOPIC,
expected_message,
content_type="application/x-www-form-urlencoded",
) )
def test_ignore_travis_pull_request_by_default(self) -> None: def test_ignore_travis_pull_request_by_default(self) -> None:
@ -46,8 +43,8 @@ class TravisHookTests(WebhookTestCase):
"n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht" "n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht"
"tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)") "tps://travis-ci.org/hl7-fhir/fhir-svn/builds/92495257)")
self.send_and_test_stream_message( self.check_webhook(
'pull_request', "pull_request",
self.TOPIC, self.TOPIC,
expected_message, expected_message,
content_type="application/x-www-form-urlencoded", content_type="application/x-www-form-urlencoded",

View File

@ -14,87 +14,87 @@ class TrelloHookTests(WebhookTestCase):
def test_trello_webhook_when_card_was_moved_to_another_list(self) -> None: def test_trello_webhook_when_card_was_moved_to_another_list(self) -> None:
expected_message = "TomaszKolek moved [This is a card.](https://trello.com/c/r33ylX2Z) from Basics to Intermediate." expected_message = "TomaszKolek moved [This is a card.](https://trello.com/c/r33ylX2Z) from Basics to Intermediate."
self.send_and_test_stream_message('changing_cards_list', "Welcome Board", expected_message) self.check_webhook("changing_cards_list", "Welcome Board", expected_message)
def test_trello_webhook_when_card_was_renamed(self) -> None: def test_trello_webhook_when_card_was_renamed(self) -> None:
expected_message = "TomaszKolek renamed the card from \"Old name\" to [New name](https://trello.com/c/r33ylX2Z)." expected_message = "TomaszKolek renamed the card from \"Old name\" to [New name](https://trello.com/c/r33ylX2Z)."
self.send_and_test_stream_message('renaming_card', "Welcome Board", expected_message) self.check_webhook("renaming_card", "Welcome Board", expected_message)
def test_trello_webhook_when_label_was_added_to_card(self) -> None: def test_trello_webhook_when_label_was_added_to_card(self) -> None:
expected_message = "TomaszKolek added a green label with \"text value\" to [Card name](https://trello.com/c/r33ylX2Z)." expected_message = "TomaszKolek added a green label with \"text value\" to [Card name](https://trello.com/c/r33ylX2Z)."
self.send_and_test_stream_message('adding_label_to_card', "Welcome Board", expected_message) self.check_webhook("adding_label_to_card", "Welcome Board", expected_message)
def test_trello_webhook_when_label_was_removing_from_card(self) -> None: def test_trello_webhook_when_label_was_removing_from_card(self) -> None:
expected_message = "TomaszKolek removed a green label with \"text value\" from [New Card](https://trello.com/c/r33ylX2Z)." expected_message = "TomaszKolek removed a green label with \"text value\" from [New Card](https://trello.com/c/r33ylX2Z)."
self.send_and_test_stream_message('removing_label_from_card', "Welcome Board", expected_message) self.check_webhook("removing_label_from_card", "Welcome Board", expected_message)
def test_trello_webhook_when_member_was_added_to_card(self) -> None: def test_trello_webhook_when_member_was_added_to_card(self) -> None:
expected_message = "TomaszKolek added TomaszKolek to [Card name](https://trello.com/c/9BduUcVQ)." expected_message = "TomaszKolek added TomaszKolek to [Card name](https://trello.com/c/9BduUcVQ)."
self.send_and_test_stream_message('adding_member_to_card', "Welcome Board", expected_message) self.check_webhook("adding_member_to_card", "Welcome Board", expected_message)
def test_trello_webhook_when_member_was_removed_from_card(self) -> None: def test_trello_webhook_when_member_was_removed_from_card(self) -> None:
expected_message = "TomaszKolek removed Trello from [Card name](https://trello.com/c/9BduUcVQ)." expected_message = "TomaszKolek removed Trello from [Card name](https://trello.com/c/9BduUcVQ)."
self.send_and_test_stream_message('removing_member_from_card', "Welcome Board", expected_message) self.check_webhook("removing_member_from_card", "Welcome Board", expected_message)
def test_trello_webhook_when_due_date_was_set(self) -> None: def test_trello_webhook_when_due_date_was_set(self) -> None:
expected_message = "TomaszKolek set due date for [Card name](https://trello.com/c/9BduUcVQ) to 2016-05-11 10:00:00 UTC." expected_message = "TomaszKolek set due date for [Card name](https://trello.com/c/9BduUcVQ) to 2016-05-11 10:00:00 UTC."
self.send_and_test_stream_message('setting_due_date_to_card', "Welcome Board", expected_message) self.check_webhook("setting_due_date_to_card", "Welcome Board", expected_message)
def test_trello_webhook_when_due_date_was_changed(self) -> None: def test_trello_webhook_when_due_date_was_changed(self) -> None:
expected_message = "TomaszKolek changed due date for [Card name](https://trello.com/c/9BduUcVQ) from 2016-05-11 10:00:00 UTC to 2016-05-24 10:00:00 UTC." expected_message = "TomaszKolek changed due date for [Card name](https://trello.com/c/9BduUcVQ) from 2016-05-11 10:00:00 UTC to 2016-05-24 10:00:00 UTC."
self.send_and_test_stream_message('changing_due_date_on_card', "Welcome Board", expected_message) self.check_webhook("changing_due_date_on_card", "Welcome Board", expected_message)
def test_trello_webhook_when_due_date_was_removed(self) -> None: def test_trello_webhook_when_due_date_was_removed(self) -> None:
expected_message = "TomaszKolek removed the due date from [Card name](https://trello.com/c/9BduUcVQ)." expected_message = "TomaszKolek removed the due date from [Card name](https://trello.com/c/9BduUcVQ)."
self.send_and_test_stream_message('removing_due_date_from_card', "Welcome Board", expected_message) self.check_webhook("removing_due_date_from_card", "Welcome Board", expected_message)
def test_trello_webhook_when_card_was_archived(self) -> None: def test_trello_webhook_when_card_was_archived(self) -> None:
expected_message = "TomaszKolek archived [Card name](https://trello.com/c/9BduUcVQ)." expected_message = "TomaszKolek archived [Card name](https://trello.com/c/9BduUcVQ)."
self.send_and_test_stream_message('archiving_card', "Welcome Board", expected_message) self.check_webhook("archiving_card", "Welcome Board", expected_message)
def test_trello_webhook_when_card_was_reopened(self) -> None: def test_trello_webhook_when_card_was_reopened(self) -> None:
expected_message = "TomaszKolek reopened [Card name](https://trello.com/c/9BduUcVQ)." expected_message = "TomaszKolek reopened [Card name](https://trello.com/c/9BduUcVQ)."
self.send_and_test_stream_message('reopening_card', "Welcome Board", expected_message) self.check_webhook("reopening_card", "Welcome Board", expected_message)
def test_trello_webhook_when_card_was_created(self) -> None: def test_trello_webhook_when_card_was_created(self) -> None:
expected_message = "TomaszKolek created [New card](https://trello.com/c/5qrgGdD5)." expected_message = "TomaszKolek created [New card](https://trello.com/c/5qrgGdD5)."
self.send_and_test_stream_message('creating_card', "Welcome Board", expected_message) self.check_webhook("creating_card", "Welcome Board", expected_message)
def test_trello_webhook_when_attachment_was_added_to_card(self) -> None: def test_trello_webhook_when_attachment_was_added_to_card(self) -> None:
expected_message = "TomaszKolek added [attachment_name](http://url.com) to [New card](https://trello.com/c/xPKXoSTQ)." expected_message = "TomaszKolek added [attachment_name](http://url.com) to [New card](https://trello.com/c/xPKXoSTQ)."
self.send_and_test_stream_message('adding_attachment_to_card', "Welcome Board", expected_message) self.check_webhook("adding_attachment_to_card", "Welcome Board", expected_message)
def test_trello_webhook_when_checklist_was_added_to_card(self) -> None: def test_trello_webhook_when_checklist_was_added_to_card(self) -> None:
expected_message = "TomaszKolek added the Checklist checklist to [New card](https://trello.com/c/xPKXoSTQ)." expected_message = "TomaszKolek added the Checklist checklist to [New card](https://trello.com/c/xPKXoSTQ)."
self.send_and_test_stream_message('adding_checklist_to_card', "Welcome Board", expected_message) self.check_webhook("adding_checklist_to_card", "Welcome Board", expected_message)
def test_trello_webhook_when_check_item_is_checked(self) -> None: def test_trello_webhook_when_check_item_is_checked(self) -> None:
expected_message = "Eeshan Garg checked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))." expected_message = "Eeshan Garg checked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))."
self.send_and_test_stream_message('check_item_on_card_checklist', "Zulip", expected_message) self.check_webhook("check_item_on_card_checklist", "Zulip", expected_message)
def test_trello_webhook_when_check_item_is_unchecked(self) -> None: def test_trello_webhook_when_check_item_is_unchecked(self) -> None:
expected_message = "Eeshan Garg unchecked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))." expected_message = "Eeshan Garg unchecked **Tomatoes** in **Checklist** ([Something something](https://trello.com/c/R2thJK3P))."
self.send_and_test_stream_message('uncheck_item_on_card_checklist', "Zulip", expected_message) self.check_webhook("uncheck_item_on_card_checklist", "Zulip", expected_message)
def test_trello_webhook_when_member_was_removed_from_board(self) -> None: def test_trello_webhook_when_member_was_removed_from_board(self) -> None:
expected_message = "TomaszKolek removed Trello from [Welcome Board](https://trello.com/b/iqXXzYEj)." expected_message = "TomaszKolek removed Trello from [Welcome Board](https://trello.com/b/iqXXzYEj)."
self.send_and_test_stream_message('removing_member_from_board', "Welcome Board", expected_message) self.check_webhook("removing_member_from_board", "Welcome Board", expected_message)
def test_trello_webhook_when_member_was_added_to_board(self) -> None: def test_trello_webhook_when_member_was_added_to_board(self) -> None:
expected_message = "TomaszKolek added Trello to [Welcome Board](https://trello.com/b/iqXXzYEj)." expected_message = "TomaszKolek added Trello to [Welcome Board](https://trello.com/b/iqXXzYEj)."
self.send_and_test_stream_message('adding_member_to_board', "Welcome Board", expected_message) self.check_webhook("adding_member_to_board", "Welcome Board", expected_message)
def test_trello_webhook_when_list_was_added_to_board(self) -> None: def test_trello_webhook_when_list_was_added_to_board(self) -> None:
expected_message = "TomaszKolek added New list list to [Welcome Board](https://trello.com/b/iqXXzYEj)." expected_message = "TomaszKolek added New list list to [Welcome Board](https://trello.com/b/iqXXzYEj)."
self.send_and_test_stream_message('adding_new_list_to_board', "Welcome Board", expected_message) self.check_webhook("adding_new_list_to_board", "Welcome Board", expected_message)
def test_trello_webhook_when_comment_was_added_to_card(self) -> None: def test_trello_webhook_when_comment_was_added_to_card(self) -> None:
expected_message = "TomaszKolek commented on [New card](https://trello.com/c/xPKXoSTQ):\n~~~ quote\nNew comment\n~~~" expected_message = "TomaszKolek commented on [New card](https://trello.com/c/xPKXoSTQ):\n~~~ quote\nNew comment\n~~~"
self.send_and_test_stream_message('adding_comment_to_card', "Welcome Board", expected_message) self.check_webhook("adding_comment_to_card", "Welcome Board", expected_message)
def test_trello_webhook_when_board_was_renamed(self) -> None: def test_trello_webhook_when_board_was_renamed(self) -> None:
expected_message = "TomaszKolek renamed the board from Welcome Board to [New name](https://trello.com/b/iqXXzYEj)." expected_message = "TomaszKolek renamed the board from Welcome Board to [New name](https://trello.com/b/iqXXzYEj)."
self.send_and_test_stream_message('renaming_board', "New name", expected_message) self.check_webhook("renaming_board", "New name", expected_message)
@patch('zerver.webhooks.trello.view.check_send_webhook_message') @patch('zerver.webhooks.trello.view.check_send_webhook_message')
def test_trello_webhook_when_card_is_moved_within_single_list_ignore( def test_trello_webhook_when_card_is_moved_within_single_list_ignore(
@ -122,12 +122,12 @@ class TrelloHookTests(WebhookTestCase):
def test_trello_webhook_when_description_was_added_to_card(self) -> None: def test_trello_webhook_when_description_was_added_to_card(self) -> None:
expected_message = "Marco Matarazzo set description for [New Card](https://trello.com/c/P2r0z66z) to:\n~~~ quote\nNew Description\n~~~" expected_message = "Marco Matarazzo set description for [New Card](https://trello.com/c/P2r0z66z) to:\n~~~ quote\nNew Description\n~~~"
self.send_and_test_stream_message('adding_description_to_card', "Welcome Board", expected_message) self.check_webhook("adding_description_to_card", "Welcome Board", expected_message)
def test_trello_webhook_when_description_was_removed_from_card(self) -> None: def test_trello_webhook_when_description_was_removed_from_card(self) -> None:
expected_message = "Marco Matarazzo removed description from [New Card](https://trello.com/c/P2r0z66z)." expected_message = "Marco Matarazzo removed description from [New Card](https://trello.com/c/P2r0z66z)."
self.send_and_test_stream_message('removing_description_from_card', "Welcome Board", expected_message) self.check_webhook("removing_description_from_card", "Welcome Board", expected_message)
def test_trello_webhook_when_description_was_changed_on_card(self) -> None: def test_trello_webhook_when_description_was_changed_on_card(self) -> None:
expected_message = "Marco Matarazzo changed description for [New Card](https://trello.com/c/P2r0z66z) from\n~~~ quote\nNew Description\n~~~\nto\n~~~ quote\nChanged Description\n~~~" expected_message = "Marco Matarazzo changed description for [New Card](https://trello.com/c/P2r0z66z) from\n~~~ quote\nNew Description\n~~~\nto\n~~~ quote\nChanged Description\n~~~"
self.send_and_test_stream_message('changing_description_on_card', "Welcome Board", expected_message) self.check_webhook("changing_description_on_card", "Welcome Board", expected_message)

View File

@ -9,17 +9,17 @@ class UpdownHookTests(WebhookTestCase):
def test_updown_check_down_event(self) -> None: def test_updown_check_down_event(self) -> None:
expected_topic = "https://updown.io" expected_topic = "https://updown.io"
expected_message = "Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC." expected_message = "Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC."
self.send_and_test_stream_message('check_down_one_event', expected_topic, expected_message) self.check_webhook("check_down_one_event", expected_topic, expected_message)
def test_updown_check_up_again_event(self) -> None: def test_updown_check_up_again_event(self) -> None:
expected_topic = "https://updown.io" expected_topic = "https://updown.io"
expected_message = "Service is `up` again after 4 minutes 25 seconds." expected_message = "Service is `up` again after 4 minutes 25 seconds."
self.send_and_test_stream_message('check_up_again_one_event', expected_topic, expected_message) self.check_webhook("check_up_again_one_event", expected_topic, expected_message)
def test_updown_check_up_event(self) -> None: def test_updown_check_up_event(self) -> None:
expected_topic = "https://updown.io" expected_topic = "https://updown.io"
expected_message = "Service is `up`." expected_message = "Service is `up`."
self.send_and_test_stream_message('check_up_first_time', expected_topic, expected_message) self.check_webhook("check_up_first_time", expected_topic, expected_message)
def test_updown_check_up_multiple_events(self) -> None: def test_updown_check_up_multiple_events(self) -> None:
first_message_expected_topic = "https://updown.io" first_message_expected_topic = "https://updown.io"
@ -28,7 +28,7 @@ class UpdownHookTests(WebhookTestCase):
second_message_expected_topic = "https://updown.io" second_message_expected_topic = "https://updown.io"
second_message_expected_message = "Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC." second_message_expected_message = "Service is `down`. It returned a 500 error at 2016-02-07 13:11:43 UTC."
self.send_and_test_stream_message('check_multiple_events') self.check_webhook("check_multiple_events")
last_message = self.get_last_message() last_message = self.get_last_message()
self.do_test_topic(last_message, first_message_expected_topic) self.do_test_topic(last_message, first_message_expected_topic)
self.do_test_message(last_message, first_message_expected_message) self.do_test_message(last_message, first_message_expected_message)

View File

@ -11,17 +11,24 @@ class WordPressHookTests(WebhookTestCase):
expected_topic = "WordPress Post" expected_topic = "WordPress Post"
expected_message = "New post published:\n* [New Blog Post](http://example.com\n)" expected_message = "New post published:\n* [New Blog Post](http://example.com\n)"
self.send_and_test_stream_message('publish_post', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "publish_post",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_publish_post_type_not_provided(self) -> None: def test_publish_post_type_not_provided(self) -> None:
expected_topic = "WordPress Post" expected_topic = "WordPress Post"
expected_message = "New post published:\n* [New Blog Post](http://example.com\n)" expected_message = "New post published:\n* [New Blog Post](http://example.com\n)"
self.send_and_test_stream_message('publish_post_type_not_provided', self.check_webhook(
expected_topic, expected_message, "publish_post_type_not_provided",
content_type="application/x-www-form-urlencoded") expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_publish_post_no_data_provided(self) -> None: def test_publish_post_no_data_provided(self) -> None:
@ -29,37 +36,52 @@ class WordPressHookTests(WebhookTestCase):
expected_topic = "WordPress Notification" expected_topic = "WordPress Notification"
expected_message = "New post published:\n* [New WordPress Post](WordPress Post URL)" expected_message = "New post published:\n* [New WordPress Post](WordPress Post URL)"
self.send_and_test_stream_message('publish_post_no_data_provided', self.check_webhook(
expected_topic, expected_message, "publish_post_no_data_provided",
content_type="application/x-www-form-urlencoded") expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_publish_page(self) -> None: def test_publish_page(self) -> None:
expected_topic = "WordPress Page" expected_topic = "WordPress Page"
expected_message = "New page published:\n* [New Blog Page](http://example.com\n)" expected_message = "New page published:\n* [New Blog Page](http://example.com\n)"
self.send_and_test_stream_message('publish_page', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "publish_page",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_user_register(self) -> None: def test_user_register(self) -> None:
expected_topic = "New Blog Users" expected_topic = "New Blog Users"
expected_message = "New blog user registered:\n* **Name**: test_user\n* **Email**: test_user@example.com" expected_message = "New blog user registered:\n* **Name**: test_user\n* **Email**: test_user@example.com"
self.send_and_test_stream_message('user_register', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "user_register",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_wp_login(self) -> None: def test_wp_login(self) -> None:
expected_topic = "New Login" expected_topic = "New Login"
expected_message = "User testuser logged in." expected_message = "User testuser logged in."
self.send_and_test_stream_message('wp_login', expected_topic, expected_message, self.check_webhook(
content_type="application/x-www-form-urlencoded") "wp_login",
expected_topic,
expected_message,
content_type="application/x-www-form-urlencoded",
)
def test_unknown_action_no_data(self) -> None: def test_unknown_action_no_data(self) -> None:
# Mimic send_and_test_stream_message() to manually execute a negative test. # Mimic check_webhook() to manually execute a negative test.
# Otherwise its call to send_json_payload() would assert on the non-success # Otherwise its call to send_json_payload() would assert on the non-success
# we are testing. The value of result is the error message the webhook should # we are testing. The value of result is the error message the webhook should
# return if no params are sent. The fixture for this test is an empty file. # return if no params are sent. The fixture for this test is an empty file.

View File

@ -15,7 +15,7 @@ class ZabbixHookTests(WebhookTestCase):
""" """
expected_topic = "www.example.com" expected_topic = "www.example.com"
expected_message = "PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\n* Zabbix agent on www.example.com is unreachable for 5 minutes\n* Agent ping is Up (1)" expected_message = "PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\n* Zabbix agent on www.example.com is unreachable for 5 minutes\n* Agent ping is Up (1)"
self.send_and_test_stream_message('zabbix_alert', expected_topic, expected_message) self.check_webhook("zabbix_alert", expected_topic, expected_message)
def test_zabbix_invalid_payload_with_missing_data(self) -> None: def test_zabbix_invalid_payload_with_missing_data(self) -> None:
""" """

View File

@ -9,17 +9,17 @@ class ZapierHookTests(WebhookTestCase):
def test_zapier_when_subject_and_body_are_correct(self) -> None: def test_zapier_when_subject_and_body_are_correct(self) -> None:
expected_topic = "New email from zulip@zulip.com" expected_topic = "New email from zulip@zulip.com"
expected_message = "Your email content is: \nMy Email content." expected_message = "Your email content is: \nMy Email content."
self.send_and_test_stream_message('correct_subject_and_body', expected_topic, expected_message) self.check_webhook("correct_subject_and_body", expected_topic, expected_message)
def test_zapier_when_topic_and_body_are_correct(self) -> None: def test_zapier_when_topic_and_body_are_correct(self) -> None:
expected_topic = "New email from zulip@zulip.com" expected_topic = "New email from zulip@zulip.com"
expected_message = "Your email content is: \nMy Email content." expected_message = "Your email content is: \nMy Email content."
self.send_and_test_stream_message('correct_topic_and_body', expected_topic, expected_message) self.check_webhook("correct_topic_and_body", expected_topic, expected_message)
def test_zapier_weather_update(self) -> None: def test_zapier_weather_update(self) -> None:
expected_topic = "Here is your weather update for the day:" expected_topic = "Here is your weather update for the day:"
expected_message = "Foggy in the morning.\nMaximum temperature to be 24.\nMinimum temperature to be 12" expected_message = "Foggy in the morning.\nMaximum temperature to be 24.\nMinimum temperature to be 12"
self.send_and_test_stream_message('weather_update', expected_topic, expected_message) self.check_webhook("weather_update", expected_topic, expected_message)
class ZapierZulipAppTests(WebhookTestCase): class ZapierZulipAppTests(WebhookTestCase):
STREAM_NAME = 'zapier' STREAM_NAME = 'zapier'