diff --git a/templates/zerver/api/incoming-webhooks-walkthrough.md b/templates/zerver/api/incoming-webhooks-walkthrough.md index 4a94a95bb1..c9f67660fb 100644 --- a/templates/zerver/api/incoming-webhooks-walkthrough.md +++ b/templates/zerver/api/incoming-webhooks-walkthrough.md @@ -236,11 +236,11 @@ class HelloWorldHookTests(WebhookTestCase): # Note: Include a test function per each distinct message condition your integration supports def test_hello_message(self) -> None: - expected_subject = "Hello World"; + expected_topic = "Hello World"; 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 - self.send_and_test_stream_message('hello', expected_subject, expected_message, + self.send_and_test_stream_message('hello', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: @@ -277,11 +277,11 @@ class called something like `test_goodbye_message`: ``` def test_goodbye_message(self) -> None: - expected_subject = "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)**"; # use fixture named helloworld_goodbye - self.send_and_test_stream_message('goodbye', expected_subject, expected_message, + self.send_and_test_stream_message('goodbye', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") ``` @@ -503,10 +503,10 @@ class QuerytestHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=self.TOPIC) # define the expected message contents - expected_subject = "Query Test" + expected_topic = "Query Test" expected_message = "This is a test of custom query parameters." - self.send_and_test_stream_message('test_one', expected_subject, expected_message, + self.send_and_test_stream_message('test_one', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/airbrake/tests.py b/zerver/webhooks/airbrake/tests.py index ca73adc842..76fa287330 100644 --- a/zerver/webhooks/airbrake/tests.py +++ b/zerver/webhooks/airbrake/tests.py @@ -7,6 +7,6 @@ class AirbrakeHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'airbrake' def test_airbrake_error_message(self) -> None: - expected_subject = u"ZulipIntegrationTest" + expected_topic = u"ZulipIntegrationTest" expected_message = u"[ZeroDivisionError](https://zulip.airbrake.io/projects/125209/groups/1705190192091077626): \"Error message from logger\" occurred." - self.send_and_test_stream_message('error_message', expected_subject, expected_message) + self.send_and_test_stream_message('error_message', expected_topic, expected_message) diff --git a/zerver/webhooks/ansibletower/tests.py b/zerver/webhooks/ansibletower/tests.py index c139bb8945..096c32c497 100644 --- a/zerver/webhooks/ansibletower/tests.py +++ b/zerver/webhooks/ansibletower/tests.py @@ -10,27 +10,27 @@ class AnsibletowerHookTests(WebhookTestCase): """ Tests if ansibletower project update successful notification is handled correctly """ - expected_subject = "AWX - Project Update" + expected_topic = "AWX - Project Update" expected_message = ("Project Update: [#2677 AWX - Project Update]" "(http://awx.example.co.uk/#/jobs/project/2677) was successful") - self.send_and_test_stream_message('project_update_successful', expected_subject, expected_message) + self.send_and_test_stream_message('project_update_successful', expected_topic, expected_message) def test_ansibletower_project_update_failed_message(self) -> None: """ Tests if ansibletower project update failed notification is handled correctly """ - expected_subject = "AWX - Project Update" + expected_topic = "AWX - Project Update" expected_message = ("Project Update: [#2678 AWX - Project Update]" "(http://awx.example.co.uk/#/jobs/project/2678) failed") - self.send_and_test_stream_message('project_update_failed', expected_subject, expected_message) + self.send_and_test_stream_message('project_update_failed', expected_topic, expected_message) def test_ansibletower_job_successful_multiple_hosts_message(self) -> None: """ Tests if ansibletower job successful multiple hosts notification is handled correctly """ - expected_subject = "System - Deploy - Zabbix Agent" + expected_topic = "System - Deploy - Zabbix Agent" expected_message = ("Job: [#2674 System - Deploy - Zabbix Agent]" "(http://awx.example.co.uk/#/jobs/playbook/2674) was successful\n" "* chat.example.co.uk: Success\n" @@ -39,35 +39,35 @@ class AnsibletowerHookTests(WebhookTestCase): "* ipa.example.co.uk: Success\n" "* mail.example.co.uk: Success") - self.send_and_test_stream_message('job_successful_multiple_hosts', expected_subject, expected_message) + self.send_and_test_stream_message('job_successful_multiple_hosts', expected_topic, expected_message) def test_ansibletower_job_successful_message(self) -> None: """ Tests if ansibletower job successful notification is handled correctly """ - expected_subject = "System - Deploy - Zabbix Agent" + expected_topic = "System - Deploy - Zabbix Agent" expected_message = ("Job: [#2674 System - Deploy - Zabbix Agent]" "(http://awx.example.co.uk/#/jobs/playbook/2674) was successful\n" "* chat.example.co.uk: Success") - self.send_and_test_stream_message('job_successful', expected_subject, expected_message) + self.send_and_test_stream_message('job_successful', expected_topic, expected_message) def test_ansibletower_job_failed_message(self) -> None: """ Tests if ansibletower job failed notification is handled correctly """ - expected_subject = "System - Updates - Ubuntu" + expected_topic = "System - Updates - Ubuntu" expected_message = ("Job: [#2722 System - Updates - Ubuntu]" "(http://awx.example.co.uk/#/jobs/playbook/2722) failed\n" "* chat.example.co.uk: Failed") - self.send_and_test_stream_message('job_failed', expected_subject, expected_message) + self.send_and_test_stream_message('job_failed', expected_topic, expected_message) def test_ansibletower_job_failed_multiple_hosts_message(self) -> None: """ Tests if ansibletower job failed notification is handled correctly """ - expected_subject = "System - Updates - Ubuntu" + expected_topic = "System - Updates - Ubuntu" expected_message = ("Job: [#2722 System - Updates - Ubuntu]" "(http://awx.example.co.uk/#/jobs/playbook/2722) failed\n" "* chat.example.co.uk: Failed\n" @@ -76,67 +76,67 @@ class AnsibletowerHookTests(WebhookTestCase): "* ipa.example.co.uk: Failed\n" "* mail.example.co.uk: Failed") - self.send_and_test_stream_message('job_failed_multiple_hosts', expected_subject, expected_message) + self.send_and_test_stream_message('job_failed_multiple_hosts', expected_topic, expected_message) def test_ansibletower_inventory_update_successful_message(self) -> None: """ Tests if ansibletower inventory update successful notification is handled correctly """ - expected_subject = "AWX - Inventory Update" + expected_topic = "AWX - Inventory Update" expected_message = ("Inventory Update: [#2724 AWX - Inventory Update]" "(http://awx.example.co.uk/#/jobs/inventory/2724) was successful") - self.send_and_test_stream_message('inventory_update_successful', expected_subject, expected_message) + self.send_and_test_stream_message('inventory_update_successful', expected_topic, expected_message) def test_ansibletower_inventory_update_failed_message(self) -> None: """ Tests if ansibletower inventory update failed notification is handled correctly """ - expected_subject = "AWX - Inventory Update" + expected_topic = "AWX - Inventory Update" expected_message = ("Inventory Update: [#2724 AWX - Inventory Update]" "(http://awx.example.co.uk/#/jobs/inventory/2724) failed") - self.send_and_test_stream_message('inventory_update_failed', expected_subject, expected_message) + self.send_and_test_stream_message('inventory_update_failed', expected_topic, expected_message) def test_ansibletower_adhoc_command_successful_message(self) -> None: """ Tests if ansibletower adhoc command successful notification is handled correctly """ - expected_subject = "shell: uname -r" + expected_topic = "shell: uname -r" expected_message = ("AdHoc Command: [#2726 shell: uname -r]" "(http://awx.example.co.uk/#/jobs/command/2726) was successful") - self.send_and_test_stream_message('adhoc_command_successful', expected_subject, expected_message) + self.send_and_test_stream_message('adhoc_command_successful', expected_topic, expected_message) def test_ansibletower_adhoc_command_failed_message(self) -> None: """ Tests if ansibletower adhoc command failed notification is handled correctly """ - expected_subject = "shell: uname -r" + expected_topic = "shell: uname -r" expected_message = ("AdHoc Command: [#2726 shell: uname -r]" "(http://awx.example.co.uk/#/jobs/command/2726) failed") - self.send_and_test_stream_message('adhoc_command_failed', expected_subject, expected_message) + self.send_and_test_stream_message('adhoc_command_failed', expected_topic, expected_message) def test_ansibletower_system_job_successful_message(self) -> None: """ Tests if ansibletower system job successful notification is handled correctly """ - expected_subject = "Cleanup Job Details" + expected_topic = "Cleanup Job Details" expected_message = ("System Job: [#2721 Cleanup Job Details]" "(http://awx.example.co.uk/#/jobs/system/2721) was successful") - self.send_and_test_stream_message('system_job_successful', expected_subject, expected_message) + self.send_and_test_stream_message('system_job_successful', expected_topic, expected_message) def test_ansibletower_system_job_failed_message(self) -> None: """ Tests if ansibletower system job failed notification is handled correctly """ - expected_subject = "Cleanup Job Details" + expected_topic = "Cleanup Job Details" expected_message = ("System Job: [#2721 Cleanup Job Details]" "(http://awx.example.co.uk/#/jobs/system/2721) failed") - self.send_and_test_stream_message('system_job_failed', expected_subject, expected_message) + self.send_and_test_stream_message('system_job_failed', expected_topic, expected_message) def get_body(self, fixture_name: str) -> str: return self.webhook_fixture_data("ansibletower", fixture_name, file_type="json") diff --git a/zerver/webhooks/appfollow/tests.py b/zerver/webhooks/appfollow/tests.py index 55926dee49..66df310258 100644 --- a/zerver/webhooks/appfollow/tests.py +++ b/zerver/webhooks/appfollow/tests.py @@ -10,14 +10,14 @@ class AppFollowHookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/appfollow?stream={stream}&api_key={api_key}" def test_sample(self) -> None: - expected_subject = "Webhook integration was successful." + expected_topic = "Webhook integration was successful." expected_message = u"""Webhook integration was successful. Test User / Acme (Google Play)""" - self.send_and_test_stream_message('sample', expected_subject, expected_message, + self.send_and_test_stream_message('sample', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_reviews(self) -> None: - expected_subject = "Acme - Group chat" + expected_topic = "Acme - Group chat" expected_message = u"""Acme - Group chat App Store, Acme Technologies, Inc. ★★★★★ United States @@ -25,7 +25,7 @@ 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. *by* **Mr RESOLUTIONARY** *for v3.9* [Permalink](http://appfollow.io/permalink) · [Add tag](http://watch.appfollow.io/add_tag)""" - self.send_and_test_stream_message('review', expected_subject, expected_message, + self.send_and_test_stream_message('review', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_reviews_with_topic(self) -> None: @@ -34,7 +34,7 @@ Acme enables me to manage the flow of information quite well. I only wish I coul original_url_template = self.URL_TEMPLATE self.URL_TEMPLATE = original_url_template + "&topic=foo" self.url = self.build_webhook_url() - expected_subject = "foo" + expected_topic = "foo" expected_message = u"""Acme - Group chat App Store, Acme Technologies, Inc. ★★★★★ United States @@ -42,7 +42,7 @@ 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. *by* **Mr RESOLUTIONARY** *for v3.9* [Permalink](http://appfollow.io/permalink) · [Add tag](http://watch.appfollow.io/add_tag)""" - self.send_and_test_stream_message('review', expected_subject, expected_message, + self.send_and_test_stream_message('review', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") self.URL_TEMPLATE = original_url_template diff --git a/zerver/webhooks/appveyor/tests.py b/zerver/webhooks/appveyor/tests.py index 2d92388716..0bc1accc6b 100644 --- a/zerver/webhooks/appveyor/tests.py +++ b/zerver/webhooks/appveyor/tests.py @@ -10,7 +10,7 @@ class AppveyorHookTests(WebhookTestCase): """ Tests if appveyor build success notification is handled correctly """ - expected_subject = "Hubot-DSC-Resource" + expected_topic = "Hubot-DSC-Resource" expected_message = ("[Build Hubot-DSC-Resource 2.0.59 completed](https://ci.appveyor.com/project" "/joebloggs/hubot-dsc-resource/build/2.0.59)\n" "Commit [c06e208b47](https://github.com/joebloggs/Hubot-DSC-Resource" @@ -19,13 +19,13 @@ class AppveyorHookTests(WebhookTestCase): "Build Started: 9/9/2018 7:04 PM\n" "Build Finished: 9/9/2018 7:06 PM") - self.send_and_test_stream_message('appveyor_build_success', expected_subject, expected_message) + self.send_and_test_stream_message('appveyor_build_success', expected_topic, expected_message) def test_appveyor_build_failure_message(self) -> None: """ Tests if appveyor build failure notification is handled correctly """ - expected_subject = "Hubot-DSC-Resource" + expected_topic = "Hubot-DSC-Resource" expected_message = ("[Build Hubot-DSC-Resource 2.0.59 failed](https://ci.appveyor.com/project" "/joebloggs/hubot-dsc-resource/build/2.0.59)\n" "Commit [c06e208b47](https://github.com/joebloggs/Hubot-DSC-Resource" @@ -34,7 +34,7 @@ class AppveyorHookTests(WebhookTestCase): "Build Started: 9/9/2018 7:04 PM\n" "Build Finished: 9/9/2018 7:06 PM") - self.send_and_test_stream_message('appveyor_build_failure', expected_subject, expected_message) + self.send_and_test_stream_message('appveyor_build_failure', expected_topic, expected_message) def get_body(self, fixture_name: str) -> str: return self.webhook_fixture_data("appveyor", fixture_name, file_type="json") diff --git a/zerver/webhooks/basecamp/tests.py b/zerver/webhooks/basecamp/tests.py index 5d589fb69a..2b1ecc9193 100644 --- a/zerver/webhooks/basecamp/tests.py +++ b/zerver/webhooks/basecamp/tests.py @@ -6,7 +6,7 @@ class BasecampHookTests(WebhookTestCase): STREAM_NAME = 'basecamp' URL_TEMPLATE = u"/api/v1/external/basecamp?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'basecamp' - EXPECTED_SUBJECT = "Zulip HQ" + EXPECTED_TOPIC = "Zulip HQ" def test_basecamp_makes_doc_active(self) -> None: expected_message = u"Tomasz activated the document [New doc](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)" @@ -129,4 +129,4 @@ class BasecampHookTests(WebhookTestCase): self._send_and_test_message('comment_created', expected_message) def _send_and_test_message(self, fixture_name: str, expected_message: str) -> None: - self.send_and_test_stream_message(fixture_name, self.EXPECTED_SUBJECT, expected_message) + self.send_and_test_stream_message(fixture_name, self.EXPECTED_TOPIC, expected_message) diff --git a/zerver/webhooks/beanstalk/tests.py b/zerver/webhooks/beanstalk/tests.py index 3d3323fa15..48ae0e48cb 100644 --- a/zerver/webhooks/beanstalk/tests.py +++ b/zerver/webhooks/beanstalk/tests.py @@ -11,81 +11,81 @@ class BeanstalkHookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/beanstalk?stream={stream}" def test_git_single(self) -> None: - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 1 commit to branch master. * add some stuff ([e50508d](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df))""" - self.api_stream_message(self.TEST_USER_EMAIL, 'git_singlecommit', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_singlecommit', expected_topic, expected_message, content_type=None) def test_git_single_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 1 commit to branch master. * add some stuff ([e50508d](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df))""" - self.api_stream_message(self.TEST_USER_EMAIL, 'git_singlecommit', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_singlecommit', expected_topic, expected_message, content_type=None) def test_git_multiple_committers(self) -> None: - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 3 commits to branch master. Commits by Leo Franchi (2) and Tomasz Kolek (1). * Added new file ([edf529c](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7)) * Filled in new file with some stuff ([c2a191b](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9)) * More work to fix some bugs ([2009815](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))""" - self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple_committers', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple_committers', expected_topic, expected_message, content_type=None) def test_git_multiple_committers_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 3 commits to branch master. Commits by Leo Franchi (2) and Tomasz Kolek (1). * Added new file ([edf529c](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7)) * Filled in new file with some stuff ([c2a191b](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9)) * More work to fix some bugs ([2009815](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))""" - self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple_committers', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple_committers', expected_topic, expected_message, content_type=None) def test_git_multiple(self) -> None: - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 3 commits to branch master. * Added new file ([edf529c](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7)) * Filled in new file with some stuff ([c2a191b](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9)) * More work to fix some bugs ([2009815](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))""" - self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple', expected_topic, expected_message, content_type=None) def test_git_multiple_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 3 commits to branch master. * Added new file ([edf529c](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7)) * Filled in new file with some stuff ([c2a191b](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9)) * More work to fix some bugs ([2009815](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))""" - self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_multiple', expected_topic, expected_message, content_type=None) def test_git_more_than_limit(self) -> None: commits_info = "* add some stuff ([e50508d](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df))\n" - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 50 commits to branch master. {}[and {} more commit(s)]""".format((commits_info * COMMITS_LIMIT), 50 - COMMITS_LIMIT) - self.api_stream_message(self.TEST_USER_EMAIL, 'git_morethanlimitcommits', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_morethanlimitcommits', expected_topic, expected_message, content_type=None) def test_git_more_than_limit_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') commits_info = "* add some stuff ([e50508d](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df))\n" - expected_subject = "work-test / master" + expected_topic = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 50 commits to branch master. {}[and {} more commit(s)]""".format((commits_info * COMMITS_LIMIT), 50 - COMMITS_LIMIT) - self.api_stream_message(self.TEST_USER_EMAIL, 'git_morethanlimitcommits', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'git_morethanlimitcommits', expected_topic, expected_message, content_type=None) @patch('zerver.webhooks.beanstalk.view.check_send_webhook_message') @@ -124,19 +124,19 @@ class BeanstalkHookTests(WebhookTestCase): self.assert_json_success(result) def test_svn_addremove(self) -> None: - expected_subject = "svn r3" + expected_topic = "svn r3" expected_message = """Leo Franchi pushed [revision 3](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/3): > Removed a file and added another one!""" - self.api_stream_message(self.TEST_USER_EMAIL, 'svn_addremove', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'svn_addremove', expected_topic, expected_message, content_type=None) def test_svn_changefile(self) -> None: - expected_subject = "svn r2" + expected_topic = "svn r2" expected_message = """Leo Franchi pushed [revision 2](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/2): > Added some code""" - self.api_stream_message(self.TEST_USER_EMAIL, 'svn_changefile', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'svn_changefile', expected_topic, expected_message, content_type=None) def get_body(self, fixture_name: str) -> Dict[str, str]: diff --git a/zerver/webhooks/beeminder/tests.py b/zerver/webhooks/beeminder/tests.py index 4958faf2ef..5272cb9a49 100644 --- a/zerver/webhooks/beeminder/tests.py +++ b/zerver/webhooks/beeminder/tests.py @@ -10,7 +10,7 @@ class BeeminderHookTests(WebhookTestCase): @patch('zerver.webhooks.beeminder.view.time.time') def test_beeminder_derail(self, time: Any) -> None: time.return_value = 1517739100 # 5.6 hours from fixture value - expected_subject = u"beekeeper" + expected_topic = u"beekeeper" expected_message = '\n'.join([ 'You are going to derail from goal **gainweight** in **{:0.1f} hours**'.format(5.6), ' You need **+2 in 7 days (60)** to avoid derailing', @@ -18,21 +18,21 @@ class BeeminderHookTests(WebhookTestCase): ]) self.send_and_test_stream_message('derail', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @patch('zerver.webhooks.beeminder.view.time.time') def test_beeminder_derail_worried(self, time: Any) -> None: time.return_value = 1517739100 # 5.6 hours from fixture value - expected_subject = u"beekeeper" + expected_topic = u"beekeeper" expected_message = '\n'.join([ 'You are going to derail from goal **gainweight** in **{:0.1f} hours**'.format(5.6), ' You need **+2 in 7 days (60)** to avoid derailing', ' * Pledge: **5$** :worried:' ]) self.send_and_test_stream_message('derail_worried', - expected_subject, + expected_topic, expected_message, content_type="application/json") diff --git a/zerver/webhooks/bitbucket/tests.py b/zerver/webhooks/bitbucket/tests.py index 0473f5711c..bf7f58539c 100644 --- a/zerver/webhooks/bitbucket/tests.py +++ b/zerver/webhooks/bitbucket/tests.py @@ -9,15 +9,15 @@ class BitbucketHookTests(WebhookTestCase): STREAM_NAME = 'bitbucket' URL_TEMPLATE = "/api/v1/external/bitbucket?stream={stream}" FIXTURE_DIR_NAME = 'bitbucket' - EXPECTED_SUBJECT = u"Repository name" - EXPECTED_SUBJECT_BRANCH_EVENTS = u"Repository name / master" + EXPECTED_TOPIC = u"Repository name" + EXPECTED_TOPIC_BRANCH_EVENTS = u"Repository name / master" def test_bitbucket_on_push_event(self) -> None: fixture_name = 'push' self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' expected_message = u"kolaszek pushed 1 commit to branch master.\n\n{}".format(commit_info) - self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_SUBJECT_BRANCH_EVENTS, + self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket_on_push_event_filtered_by_branches(self) -> None: @@ -26,7 +26,7 @@ class BitbucketHookTests(WebhookTestCase): branches='master,development') commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))' expected_message = u"kolaszek pushed 1 commit to branch master.\n\n{}".format(commit_info) - self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_SUBJECT_BRANCH_EVENTS, + self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket_on_push_commits_above_limit_event(self) -> None: @@ -34,7 +34,7 @@ class BitbucketHookTests(WebhookTestCase): self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n' expected_message = u"kolaszek pushed 50 commits to branch master.\n\n{}[and 30 more commit(s)]".format(commit_info * 20) - self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_SUBJECT_BRANCH_EVENTS, + self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket_on_push_commits_above_limit_event_filtered_by_branches(self) -> None: @@ -43,14 +43,14 @@ class BitbucketHookTests(WebhookTestCase): branches='master,development') commit_info = u'* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n' expected_message = u"kolaszek pushed 50 commits to branch master.\n\n{}[and 30 more commit(s)]".format(commit_info * 20) - self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_SUBJECT_BRANCH_EVENTS, + self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket_on_force_push_event(self) -> None: fixture_name = 'force_push' self.url = self.build_webhook_url(payload=self.get_body(fixture_name)) expected_message = u"kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name)" - self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_SUBJECT, + self.api_stream_message(self.TEST_USER_EMAIL, fixture_name, self.EXPECTED_TOPIC, expected_message) @patch('zerver.webhooks.bitbucket.view.check_send_webhook_message') diff --git a/zerver/webhooks/bitbucket2/tests.py b/zerver/webhooks/bitbucket2/tests.py index 967f7f3251..7174e5c5ee 100644 --- a/zerver/webhooks/bitbucket2/tests.py +++ b/zerver/webhooks/bitbucket2/tests.py @@ -9,50 +9,50 @@ class Bitbucket2HookTests(WebhookTestCase): STREAM_NAME = 'bitbucket2' URL_TEMPLATE = "/api/v1/external/bitbucket2?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'bitbucket2' - EXPECTED_SUBJECT = u"Repository name" - EXPECTED_SUBJECT_PR_EVENTS = u"Repository name / PR #1 new commit" - EXPECTED_SUBJECT_ISSUE_EVENTS = u"Repository name / Issue #1 Bug" - EXPECTED_SUBJECT_BRANCH_EVENTS = u"Repository name / master" + EXPECTED_TOPIC = u"Repository name" + EXPECTED_TOPIC_PR_EVENTS = u"Repository name / PR #1 new commit" + EXPECTED_TOPIC_ISSUE_EVENTS = u"Repository name / Issue #1 Bug" + EXPECTED_TOPIC_BRANCH_EVENTS = u"Repository name / master" def test_bitbucket2_on_push_event(self) -> None: commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{}".format(commit_info) - self.send_and_test_stream_message('push', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers(self) -> None: commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' expected_message = u"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*2) - self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None: commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' expected_message = u"""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{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*9) - self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' expected_message = u"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*2) - self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n' expected_message = u"""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{}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))""".format(commit_info*9) - self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_event_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') commit_info = u'* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))' expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{}".format(commit_info) - self.send_and_test_stream_message('push', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_above_limit_event(self) -> None: commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n' expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{}[and more commit(s)]".format( (commit_info * 5), ) - self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_push_commits_above_limit_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') @@ -60,161 +60,161 @@ class Bitbucket2HookTests(WebhookTestCase): expected_message = u"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{}[and more commit(s)]".format( (commit_info * 5), ) - self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_force_push_event(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('force_push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_force_push_event_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') expected_message = u"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', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('force_push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_remove_branch_event(self) -> None: expected_message = u"kolaszek deleted branch master" - self.send_and_test_stream_message('remove_branch', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message) + self.send_and_test_stream_message('remove_branch', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message) def test_bitbucket2_on_fork_event(self) -> None: expected_message = u"User Tomasz(login: kolaszek) forked the repository into [kolaszek/repository-name2](https://bitbucket.org/kolaszek/repository-name2)." - self.send_and_test_stream_message('fork', self.EXPECTED_SUBJECT, expected_message) + self.send_and_test_stream_message('fork', self.EXPECTED_TOPIC, expected_message) def test_bitbucket2_on_commit_comment_created_event(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT, expected_message) + self.send_and_test_stream_message('commit_comment_created', self.EXPECTED_TOPIC, expected_message) def test_bitbucket2_on_commit_status_changed_event(self) -> None: expected_message = u"[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', self.EXPECTED_SUBJECT, expected_message) + self.send_and_test_stream_message('commit_status_changed', self.EXPECTED_TOPIC, expected_message) def test_bitbucket2_on_issue_created_event(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_ISSUE_EVENTS, expected_message) + self.send_and_test_stream_message('issue_created', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_bitbucket2_on_issue_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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_subject, expected_message) + self.send_and_test_stream_message('issue_created', expected_topic, expected_message) def test_bitbucket2_on_issue_updated_event(self) -> None: expected_message = u"kolaszek updated [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)" - self.send_and_test_stream_message('issue_updated', self.EXPECTED_SUBJECT_ISSUE_EVENTS, expected_message) + self.send_and_test_stream_message('issue_updated', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_bitbucket2_on_issue_commented_event(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_ISSUE_EVENTS, expected_message) + self.send_and_test_stream_message('issue_commented', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message) def test_bitbucket2_on_issue_commented_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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_subject, expected_message) + self.send_and_test_stream_message('issue_commented', expected_topic, expected_message) def test_bitbucket2_on_pull_request_created_event(self) -> None: expected_message = u"kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)(assigned to tkolek)\nfrom `new-branch` to `master`\n\n~~~ quote\ndescription\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:created' } - self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"kolaszek created [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)(assigned to tkolek)\nfrom `new-branch` to `master`\n\n~~~ quote\ndescription\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:created' } - self.send_and_test_stream_message('pull_request_created_or_updated', expected_subject, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_created_or_updated', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_updated_event(self) -> None: expected_message = u"kolaszek updated [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)(assigned to tkolek)\nfrom `new-branch` to `master`\n\n~~~ quote\ndescription\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:updated' } - self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_approved_event(self) -> None: expected_message = u"kolaszek approved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:approved' } - self.send_and_test_stream_message('pull_request_approved_or_unapproved', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_approved_or_unapproved', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_approved_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"kolaszek approved [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:approved' } - self.send_and_test_stream_message('pull_request_approved_or_unapproved', expected_subject, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_approved_or_unapproved', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_unapproved_event(self) -> None: expected_message = u"kolaszek unapproved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:unapproved' } - self.send_and_test_stream_message('pull_request_approved_or_unapproved', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_approved_or_unapproved', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_declined_event(self) -> None: expected_message = u"kolaszek rejected [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:rejected' } - self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_fulfilled_event(self) -> None: expected_message = u"kolaszek merged [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:fulfilled' } - self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_created_event(self) -> None: expected_message = u"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 = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_created' } - self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3)\n\n~~~ quote\nComment1\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_created' } - self.send_and_test_stream_message('pull_request_comment_action', expected_subject, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_comment_action', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_updated_event(self) -> None: expected_message = u"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 = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_updated' } - self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_updated_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"kolaszek updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3)\n\n~~~ quote\nComment1\n~~~" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_updated' } - self.send_and_test_stream_message('pull_request_comment_action', expected_subject, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_comment_action', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_pull_request_comment_deleted_event(self) -> None: expected_message = u"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 = { "HTTP_X_EVENT_KEY": 'pullrequest:comment_deleted' } - self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, **kwargs) + self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs) def test_bitbucket2_on_repo_updated_event(self) -> None: expected_message = u"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_subject = u"new-name" + expected_topic = u"new-name" kwargs = {"HTTP_X_EVENT_KEY": 'repo:updated'} - self.send_and_test_stream_message('repo_updated', expected_subject, + self.send_and_test_stream_message('repo_updated', expected_topic, expected_message, **kwargs) def test_bitbucket2_on_push_one_tag_event(self) -> None: @@ -222,14 +222,14 @@ class Bitbucket2HookTests(WebhookTestCase): kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:push' } - self.send_and_test_stream_message('push_one_tag', self.EXPECTED_SUBJECT, expected_message, **kwargs) + self.send_and_test_stream_message('push_one_tag', self.EXPECTED_TOPIC, expected_message, **kwargs) def test_bitbucket2_on_push_remove_tag_event(self) -> None: expected_message = u"kolaszek removed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)" kwargs = { "HTTP_X_EVENT_KEY": 'pullrequest:push' } - self.send_and_test_stream_message('push_remove_tag', self.EXPECTED_SUBJECT, expected_message, **kwargs) + self.send_and_test_stream_message('push_remove_tag', self.EXPECTED_TOPIC, expected_message, **kwargs) def test_bitbucket2_on_push_more_than_one_tag_event(self) -> None: expected_message = u"kolaszek pushed tag [{name}](https://bitbucket.org/kolaszek/repository-name/commits/tag/{name})" @@ -238,10 +238,10 @@ class Bitbucket2HookTests(WebhookTestCase): } self.send_and_test_stream_message('push_more_than_one_tag', **kwargs) msg = self.get_last_message() - self.do_test_topic(msg, self.EXPECTED_SUBJECT) + self.do_test_topic(msg, self.EXPECTED_TOPIC) self.do_test_message(msg, expected_message.format(name='b')) msg = self.get_second_to_last_message() - self.do_test_topic(msg, self.EXPECTED_SUBJECT) + self.do_test_topic(msg, self.EXPECTED_TOPIC) self.do_test_message(msg, expected_message.format(name='a')) def test_bitbucket2_on_more_than_one_push_event(self) -> None: @@ -251,10 +251,10 @@ class Bitbucket2HookTests(WebhookTestCase): self.send_and_test_stream_message('more_than_one_push_event', **kwargs) 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_topic(msg, self.EXPECTED_SUBJECT_BRANCH_EVENTS) + self.do_test_topic(msg, self.EXPECTED_TOPIC_BRANCH_EVENTS) msg = self.get_last_message() self.do_test_message(msg, 'kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)') - self.do_test_topic(msg, self.EXPECTED_SUBJECT) + self.do_test_topic(msg, self.EXPECTED_TOPIC) def test_bitbucket2_on_more_than_one_push_event_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') @@ -264,10 +264,10 @@ class Bitbucket2HookTests(WebhookTestCase): self.send_and_test_stream_message('more_than_one_push_event', **kwargs) 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_topic(msg, self.EXPECTED_SUBJECT_BRANCH_EVENTS) + self.do_test_topic(msg, self.EXPECTED_TOPIC_BRANCH_EVENTS) msg = self.get_last_message() self.do_test_message(msg, 'kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)') - self.do_test_topic(msg, self.EXPECTED_SUBJECT) + self.do_test_topic(msg, self.EXPECTED_TOPIC) def test_bitbucket2_on_more_than_one_push_event_filtered_by_branches_ignore(self) -> None: self.url = self.build_webhook_url(branches='changes,development') @@ -276,7 +276,7 @@ class Bitbucket2HookTests(WebhookTestCase): } expected_message = u"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.EXPECTED_SUBJECT, + self.EXPECTED_TOPIC, expected_message, **kwargs) @patch('zerver.webhooks.bitbucket2.view.check_send_webhook_message') diff --git a/zerver/webhooks/circleci/tests.py b/zerver/webhooks/circleci/tests.py index 1664d24068..009588fee7 100644 --- a/zerver/webhooks/circleci/tests.py +++ b/zerver/webhooks/circleci/tests.py @@ -7,21 +7,21 @@ class CircleCiHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'circleci' def test_circleci_build_in_success_status(self) -> None: - expected_subject = u"RepoName" + expected_topic = u"RepoName" expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch succeeded." - self.send_and_test_stream_message('build_passed', expected_subject, expected_message) + self.send_and_test_stream_message('build_passed', expected_topic, expected_message) def test_circleci_build_in_failed_status(self) -> None: - expected_subject = u"RepoName" + expected_topic = u"RepoName" expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch failed." - self.send_and_test_stream_message('build_failed', expected_subject, expected_message) + self.send_and_test_stream_message('build_failed', expected_topic, expected_message) def test_circleci_build_in_failed_status_when_previous_build_failed_too(self) -> None: - expected_subject = u"RepoName" + expected_topic = u"RepoName" expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch is still failing." - self.send_and_test_stream_message('build_failed_when_previous_build_failed', expected_subject, expected_message) + self.send_and_test_stream_message('build_failed_when_previous_build_failed', expected_topic, expected_message) def test_circleci_build_in_success_status_when_previous_build_failed_too(self) -> None: - expected_subject = u"RepoName" + expected_topic = u"RepoName" expected_message = u"[Build](https://circleci.com/gh/username/project/build_number) triggered by username on master branch fixed." - self.send_and_test_stream_message('build_passed_when_previous_build_failed', expected_subject, expected_message) + self.send_and_test_stream_message('build_passed_when_previous_build_failed', expected_topic, expected_message) diff --git a/zerver/webhooks/crashlytics/tests.py b/zerver/webhooks/crashlytics/tests.py index e72cf4be06..aa261a778d 100644 --- a/zerver/webhooks/crashlytics/tests.py +++ b/zerver/webhooks/crashlytics/tests.py @@ -7,11 +7,11 @@ class CrashlyticsHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'crashlytics' def test_crashlytics_verification_message(self) -> None: - expected_subject = u"Setup" + expected_topic = u"Setup" expected_message = u"Webhook has been successfully configured." - self.send_and_test_stream_message('verification', expected_subject, expected_message) + self.send_and_test_stream_message('verification', expected_topic, expected_message) def test_crashlytics_build_in_success_status(self) -> None: - expected_subject = u"123: Issue Title" + expected_topic = u"123: Issue Title" expected_message = u"[Issue](http://crashlytics.com/full/url/to/issue) impacts at least 16 device(s)." - self.send_and_test_stream_message('issue_message', expected_subject, expected_message) + self.send_and_test_stream_message('issue_message', expected_topic, expected_message) diff --git a/zerver/webhooks/delighted/tests.py b/zerver/webhooks/delighted/tests.py index 2c41389e2a..888ab1bbc6 100644 --- a/zerver/webhooks/delighted/tests.py +++ b/zerver/webhooks/delighted/tests.py @@ -8,25 +8,25 @@ class DelightedHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'delighted' def test_feedback_message_promoter(self) -> None: - expected_subject = "Survey Response" + expected_topic = "Survey Response" expected_message = ("Kudos! You have a new promoter.\n" ">Score of 9/10 from charlie_gravis@example.com" "\n>Your service is fast and flawless!") self.send_and_test_stream_message('survey_response_updated_promoter', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_feedback_message_non_promoter(self) -> None: - expected_subject = "Survey Response" + expected_topic = "Survey Response" expected_message = ("Great! You have new feedback.\n" ">Score of 5/10 from paul_gravis@example.com" "\n>Your service is slow, but nearly flawless! " "Keep up the good work!") self.send_and_test_stream_message('survey_response_updated_non_promoter', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/deskdotcom/tests.py b/zerver/webhooks/deskdotcom/tests.py index 01edde977a..daf556e87f 100644 --- a/zerver/webhooks/deskdotcom/tests.py +++ b/zerver/webhooks/deskdotcom/tests.py @@ -19,39 +19,39 @@ class DeskDotComHookTests(WebhookTestCase): def test_static_text_message(self) -> None: - expected_subject = u"static text notification" + expected_topic = u"static text notification" expected_message = u"This is a custom action." - self.api_stream_message(self.TEST_USER_EMAIL, 'static_text', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'static_text', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_case_updated_message(self) -> None: - expected_subject = u"case updated notification" + expected_topic = u"case updated notification" expected_message = (u"Case 2 updated. " u"Link: " u"I have a question") - self.api_stream_message(self.TEST_USER_EMAIL, 'case_updated', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'case_updated', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_unicode_text_italian(self) -> None: - expected_subject = u"case updated notification" + expected_topic = u"case updated notification" expected_message = (u"Case 2 updated. " u"Link: " u"Il mio hovercraft è pieno di anguille.") - self.api_stream_message(self.TEST_USER_EMAIL, 'unicode_text_italian', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'unicode_text_italian', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_unicode_text_japanese(self) -> None: - expected_subject = u"case updated notification" + expected_topic = u"case updated notification" expected_message = (u"Case 2 updated. " u"Link: " u"私のホバークラフトは鰻でいっぱいです") - self.api_stream_message(self.TEST_USER_EMAIL, 'unicode_text_japanese', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'unicode_text_japanese', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/dropbox/tests.py b/zerver/webhooks/dropbox/tests.py index c754be9df8..070a00ba15 100644 --- a/zerver/webhooks/dropbox/tests.py +++ b/zerver/webhooks/dropbox/tests.py @@ -9,10 +9,10 @@ class DropboxHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'dropbox' def test_file_updated(self) -> None: - expected_subject = u"Dropbox" + expected_topic = u"Dropbox" expected_message = u"File has been updated on Dropbox!" - self.send_and_test_stream_message('file_updated', expected_subject, expected_message, + self.send_and_test_stream_message('file_updated', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/flock/tests.py b/zerver/webhooks/flock/tests.py index 4b8a3a5a8d..0266f240c7 100644 --- a/zerver/webhooks/flock/tests.py +++ b/zerver/webhooks/flock/tests.py @@ -6,82 +6,82 @@ class FlockHookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/flock?api_key={api_key}&stream={stream}" def test_flock_message(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"This is the welcome message!" self.send_and_test_stream_message('messages', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_reply(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"It's interesting how high productivity will go..." self.send_and_test_stream_message('reply', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_note(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"Shared a note" self.send_and_test_stream_message('note', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_reply_note(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"This is reply to Note." self.send_and_test_stream_message('reply_note', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_reply_pinned(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"This is reply to pinned message." self.send_and_test_stream_message('reply_pinned', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_reply_reminder(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"This is a reply to Reminder." self.send_and_test_stream_message('reply_reminder', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_reply_todo(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"This is a reply to Todo notification." self.send_and_test_stream_message('reply_todo', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_pinned(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"Rishabh rawat pinned an item to the conversation" self.send_and_test_stream_message('pinned', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_reminder(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"Rishabh rawat wanted me to remind All" self.send_and_test_stream_message('reminder', - expected_subject, + expected_topic, expected_message, content_type="application/json") def test_flock_todo(self) -> None: - expected_subject = u"Flock notifications" + expected_topic = u"Flock notifications" expected_message = u"Rishabh rawat added a to-do in New List 1 list" self.send_and_test_stream_message('todo', - expected_subject, + expected_topic, expected_message, content_type="application/json") diff --git a/zerver/webhooks/freshdesk/tests.py b/zerver/webhooks/freshdesk/tests.py index 8f1cb80bcd..e20014968f 100644 --- a/zerver/webhooks/freshdesk/tests.py +++ b/zerver/webhooks/freshdesk/tests.py @@ -13,7 +13,7 @@ class FreshdeskHookTests(WebhookTestCase): Messages are generated on ticket creation through Freshdesk's "Dispatch'r" service. """ - expected_subject = u"#11: Test ticket subject ☃" + expected_topic = u"#11: Test ticket subject ☃" expected_message = u"""Requester ☃ Bob created [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11): ~~~ quote @@ -23,7 +23,7 @@ Test ticket description ☃. Type: **Incident** Priority: **High** Status: **Pending**""" - self.api_stream_message(self.TEST_USER_EMAIL, 'ticket_created', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'ticket_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_status_change(self) -> None: @@ -31,11 +31,11 @@ Status: **Pending**""" Messages are generated when a ticket's status changes through Freshdesk's "Observer" service. """ - expected_subject = u"#11: Test ticket subject ☃" + expected_topic = u"#11: Test ticket subject ☃" expected_message = """Requester Bob updated [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11): Status: **Resolved** => **Waiting on Customer**""" - self.api_stream_message(self.TEST_USER_EMAIL, 'status_changed', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'status_changed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_status_change_fixture_without_required_key(self) -> None: @@ -56,11 +56,11 @@ Status: **Resolved** => **Waiting on Customer**""" Messages are generated when a ticket's priority changes through Freshdesk's "Observer" service. """ - expected_subject = u"#11: Test ticket subject" + expected_topic = u"#11: Test ticket subject" expected_message = """Requester Bob updated [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11): Priority: **High** => **Low**""" - self.api_stream_message(self.TEST_USER_EMAIL, 'priority_changed', expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, 'priority_changed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @patch('zerver.lib.webhooks.common.check_send_webhook_message') @@ -84,9 +84,9 @@ Priority: **High** => **Low**""" Messages are generated when a note gets added to a ticket through Freshdesk's "Observer" service. """ - expected_subject = u"#11: Test ticket subject" + expected_topic = u"#11: Test ticket subject" expected_message = """Requester Bob added a {} note to [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11).""".format(note_type) - self.api_stream_message(self.TEST_USER_EMAIL, fixture, expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, fixture, expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_private_note_change(self) -> None: @@ -101,9 +101,9 @@ Priority: **High** => **Low**""" descriptions Zulip markdown-friendly while still doing our best to preserve links and images. """ - expected_subject = u"#12: Not enough ☃ guinea pigs" + expected_topic = u"#12: Not enough ☃ guinea pigs" expected_message = u"Requester \u2603 Bob created [ticket #12](http://test1234zzz.freshdesk.com/helpdesk/tickets/12):\n\n~~~ quote\nThere are too many cat pictures on the internet \u2603. We need more guinea pigs. Exhibit 1:\n\n \n\n\n[guinea_pig.png](http://cdn.freshdesk.com/data/helpdesk/attachments/production/12744808/original/guinea_pig.png)\n~~~\n\nType: **Problem**\nPriority: **Urgent**\nStatus: **Open**" - self.api_stream_message(self.TEST_USER_EMAIL, "inline_images", expected_subject, expected_message, + self.api_stream_message(self.TEST_USER_EMAIL, "inline_images", expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/front/tests.py b/zerver/webhooks/front/tests.py index db2ee6d7ad..cd69a95622 100644 --- a/zerver/webhooks/front/tests.py +++ b/zerver/webhooks/front/tests.py @@ -11,161 +11,161 @@ class FrontHookTests(WebhookTestCase): # Conversation automatically assigned to a teammate who started it. def test_conversation_assigned_outbound(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "**Leela Turanga** assigned themselves." self.send_and_test_stream_message('conversation_assigned_outbound', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_outbound_message(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "[Outbound message](https://app.frontapp.com/open/msg_1176ie2) " \ "from **support@planet-express.com** " \ "to **calculon@momsbot.com**.\n" \ "```quote\n*Subject*: Your next delivery is on Epsilon 96Z\n```" self.send_and_test_stream_message('outbound_message', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_conversation_archived(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "Archived by **Leela Turanga**." self.send_and_test_stream_message('conversation_archived', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_conversation_reopened(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "Reopened by **Leela Turanga**." self.send_and_test_stream_message('conversation_reopened', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_conversation_deleted(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "Deleted by **Leela Turanga**." self.send_and_test_stream_message('conversation_deleted', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_conversation_restored(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "Restored by **Leela Turanga**." self.send_and_test_stream_message('conversation_restored', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_conversation_unassigned(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "Unassined by **Leela Turanga**." self.send_and_test_stream_message('conversation_unassigned', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_mention_all(self) -> None: - expected_subject = 'cnv_keo696' + expected_topic = 'cnv_keo696' expected_message = "**Leela Turanga** left a comment:\n" \ "```quote\n@all Could someone else take this?\n```" self.send_and_test_stream_message('mention_all', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") # Scenario 2: Conversation starts from an inbound message. def test_inbound_message(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "[Inbound message](https://app.frontapp.com/open/msg_1176r8y) " \ "from **calculon@momsbot.com** " \ "to **support@planet-express.com**.\n" \ "```quote\n*Subject*: Being a robot is great, but...\n```" self.send_and_test_stream_message('inbound_message', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_conversation_tagged(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "**Leela Turanga** added tag **Urgent**." self.send_and_test_stream_message('conversation_tagged', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") # Conversation automatically assigned to a teammate who replied to it. def test_conversation_assigned_reply(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "**Leela Turanga** assigned themselves." self.send_and_test_stream_message('conversation_assigned_reply', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_outbound_reply(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "[Outbound reply](https://app.frontapp.com/open/msg_1176ryy) " \ "from **support@planet-express.com** " \ "to **calculon@momsbot.com**." self.send_and_test_stream_message('outbound_reply', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_conversation_untagged(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "**Leela Turanga** removed tag **Urgent**." self.send_and_test_stream_message('conversation_untagged', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_mention(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "**Leela Turanga** left a comment:\n" \ "```quote\n@bender Could you take it from here?\n```" self.send_and_test_stream_message('mention', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_comment(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "**Bender Rodriguez** left a comment:\n" \ "```quote\nSure.\n```" self.send_and_test_stream_message('comment', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") # Conversation manually assigned to another teammate. def test_conversation_assigned(self) -> None: - expected_subject = 'cnv_keocka' + expected_topic = 'cnv_keocka' expected_message = "**Leela Turanga** assigned **Bender Rodriguez**." self.send_and_test_stream_message('conversation_assigned', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/gci/tests.py b/zerver/webhooks/gci/tests.py index 37588038a8..49a8ac3949 100644 --- a/zerver/webhooks/gci/tests.py +++ b/zerver/webhooks/gci/tests.py @@ -9,61 +9,61 @@ class GoogleCodeInTests(WebhookTestCase): FIXTURE_DIR_NAME = 'gci' def test_abandon_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_comment_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_submit_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_claim_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_approve_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_approve_pending_pc_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_needswork_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_extend_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_unassign_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'**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', - expected_subject, expected_message) + expected_topic, expected_message) def test_outoftime_event_message(self) -> None: - expected_subject = u'student-yqqtag' + expected_topic = u'student-yqqtag' expected_message = u'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', - expected_subject, expected_message) + expected_topic, expected_message) diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py index 6d1df50be1..5d13cdb20c 100644 --- a/zerver/webhooks/github/tests.py +++ b/zerver/webhooks/github/tests.py @@ -11,17 +11,17 @@ class GithubWebhookTest(WebhookTestCase): STREAM_NAME = 'github' URL_TEMPLATE = "/api/v1/external/github?stream={stream}&api_key={api_key}" FIXTURE_DIR_NAME = 'github' - EXPECTED_SUBJECT_REPO_EVENTS = u"public-repo" - EXPECTED_SUBJECT_ISSUE_EVENTS = u"public-repo / Issue #2 Spelling error in the README file" - EXPECTED_SUBJECT_PR_EVENTS = u"public-repo / PR #1 Update the README with new information" - EXPECTED_SUBJECT_DEPLOYMENT_EVENTS = u"public-repo / Deployment on production" - EXPECTED_SUBJECT_ORGANIZATION_EVENTS = u"baxterandthehackers organization" - EXPECTED_SUBJECT_BRANCH_EVENTS = u"public-repo / changes" - EXPECTED_SUBJECT_WIKI_EVENTS = u"public-repo / Wiki Pages" + EXPECTED_TOPIC_REPO_EVENTS = u"public-repo" + EXPECTED_TOPIC_ISSUE_EVENTS = u"public-repo / Issue #2 Spelling error in the README file" + EXPECTED_TOPIC_PR_EVENTS = u"public-repo / PR #1 Update the README with new information" + EXPECTED_TOPIC_DEPLOYMENT_EVENTS = u"public-repo / Deployment on production" + EXPECTED_TOPIC_ORGANIZATION_EVENTS = u"baxterandthehackers organization" + EXPECTED_TOPIC_BRANCH_EVENTS = u"public-repo / changes" + EXPECTED_TOPIC_WIKI_EVENTS = u"public-repo / Wiki Pages" def test_ping_event(self) -> None: expected_message = u"GitHub webhook has been successfully configured by TomaszKolek" - self.send_and_test_stream_message('ping', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='ping') + self.send_and_test_stream_message('ping', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='ping') def test_ping_organization_event(self) -> None: expected_message = u"GitHub webhook has been successfully configured by eeshangarg" @@ -37,49 +37,49 @@ class GithubWebhookTest(WebhookTestCase): def test_push_1_commit(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_1_commit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_1_commit_without_username(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_1_commit_without_username', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_1_commit_filtered_by_branches(self) -> None: self.url = self.build_webhook_url('master,changes') expected_message = u"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', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_1_commit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_multiple_comitters(self) -> None: commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' expected_message = u"""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{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 5) - self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_multiple_comitters_with_others(self) -> None: commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' expected_message = u"""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{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 9) - self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_multiple_comitters_filtered_by_branches(self) -> None: self.url = self.build_webhook_url('master,changes') commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' expected_message = u"""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{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 5) - self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_multiple_comitters_with_others_filtered_by_branches(self) -> None: self.url = self.build_webhook_url('master,changes') commits_info = u'* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n' expected_message = u"""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{}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))""".format(commits_info * 9) - self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_50_commits(self) -> None: commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n" expected_message = u"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{}[and 30 more commit(s)]".format( commit_info * COMMITS_LIMIT ) - self.send_and_test_stream_message('push_50_commits', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_50_commits', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_push_50_commits_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,changes') @@ -87,185 +87,185 @@ class GithubWebhookTest(WebhookTestCase): expected_message = u"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{}[and 30 more commit(s)]".format( commit_info * COMMITS_LIMIT ) - self.send_and_test_stream_message('push_50_commits', self.EXPECTED_SUBJECT_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_50_commits', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_commit_comment_msg(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='commit_comment') + self.send_and_test_stream_message('commit_comment', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='commit_comment') def test_create_msg(self) -> None: expected_message = u"baxterthehacker created tag 0.0.1" - self.send_and_test_stream_message('create', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='create') + self.send_and_test_stream_message('create', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='create') def test_delete_msg(self) -> None: expected_message = u"baxterthehacker deleted tag simple-tag" - self.send_and_test_stream_message('delete', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='delete') + self.send_and_test_stream_message('delete', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='delete') def test_deployment_msg(self) -> None: expected_message = u"baxterthehacker created new deployment" - self.send_and_test_stream_message('deployment', self.EXPECTED_SUBJECT_DEPLOYMENT_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='deployment') + self.send_and_test_stream_message('deployment', self.EXPECTED_TOPIC_DEPLOYMENT_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='deployment') def test_deployment_status_msg(self) -> None: expected_message = u"Deployment changed status to success" - self.send_and_test_stream_message('deployment_status', self.EXPECTED_SUBJECT_DEPLOYMENT_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='deployment_status') + self.send_and_test_stream_message('deployment_status', self.EXPECTED_TOPIC_DEPLOYMENT_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='deployment_status') def test_fork_msg(self) -> None: expected_message = u"baxterandthehackers forked [public-repo](https://github.com/baxterandthehackers/public-repo)" - self.send_and_test_stream_message('fork', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='fork') + self.send_and_test_stream_message('fork', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='fork') def test_issue_comment_msg(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_ISSUE_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='issue_comment') + self.send_and_test_stream_message('issue_comment', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='issue_comment') def test_issue_comment_deleted_msg(self) -> None: - expected_subject = u"Scheduler / Issue #5 This is a new issue" + expected_topic = u"Scheduler / Issue #5 This is a new issue" expected_message = u"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_subject, + expected_topic, expected_message, HTTP_X_GITHUB_EVENT='issue_comment' ) def test_issue_comment_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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_subject, expected_message, HTTP_X_GITHUB_EVENT='issue_comment') + self.send_and_test_stream_message('issue_comment', expected_topic, expected_message, HTTP_X_GITHUB_EVENT='issue_comment') def test_issue_msg(self) -> None: expected_message = u"baxterthehacker opened [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2)\n\n~~~ quote\nIt looks like you accidently spelled 'commit' with two 't's.\n~~~" - self.send_and_test_stream_message('issue', self.EXPECTED_SUBJECT_ISSUE_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='issues') + self.send_and_test_stream_message('issue', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='issues') def test_issue_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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 accidently spelled 'commit' with two 't's.\n~~~" - self.send_and_test_stream_message('issue', expected_subject, expected_message, HTTP_X_GITHUB_EVENT='issues') + self.send_and_test_stream_message('issue', expected_topic, expected_message, HTTP_X_GITHUB_EVENT='issues') def test_membership_msg(self) -> None: expected_message = u"baxterthehacker added [kdaigle](https://github.com/kdaigle) to Contractors team" - self.send_and_test_stream_message('membership', self.EXPECTED_SUBJECT_ORGANIZATION_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='membership') + self.send_and_test_stream_message('membership', self.EXPECTED_TOPIC_ORGANIZATION_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='membership') def test_member_msg(self) -> None: expected_message = u"baxterthehacker added [octocat](https://github.com/octocat) to [public-repo](https://github.com/baxterthehacker/public-repo)" - self.send_and_test_stream_message('member', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='member') + self.send_and_test_stream_message('member', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='member') def test_pull_request_opened_msg(self) -> None: expected_message = u"baxterthehacker opened [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)\nfrom `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('opened_pull_request', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') + self.send_and_test_stream_message('opened_pull_request', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_opened_with_preassigned_assignee_msg(self) -> None: - expected_subject = u"Scheduler / PR #4 Improve README" + expected_topic = u"Scheduler / PR #4 Improve README" expected_message = u"eeshangarg opened [PR #4](https://github.com/eeshangarg/Scheduler/pull/4)(assigned to eeshangarg)\nfrom `improve-readme-2` to `master`" self.send_and_test_stream_message('opened_pull_request_with_preassigned_assignee', - expected_subject, expected_message, + expected_topic, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_opened_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"baxterthehacker opened [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1)\nfrom `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('opened_pull_request', expected_subject, expected_message, HTTP_X_GITHUB_EVENT='pull_request') + self.send_and_test_stream_message('opened_pull_request', expected_topic, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_synchronized_msg(self) -> None: expected_message = u"baxterthehacker updated [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)\nfrom `changes` to `master`" - self.send_and_test_stream_message('synchronized_pull_request', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') + self.send_and_test_stream_message('synchronized_pull_request', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_closed_msg(self) -> None: expected_message = u"baxterthehacker closed without merge [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)" - self.send_and_test_stream_message('closed_pull_request', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') + self.send_and_test_stream_message('closed_pull_request', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_closed_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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('closed_pull_request', expected_subject, expected_message, HTTP_X_GITHUB_EVENT='pull_request') + self.send_and_test_stream_message('closed_pull_request', expected_topic, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_merged_msg(self) -> None: expected_message = u"baxterthehacker merged [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)" - self.send_and_test_stream_message('merged_pull_request', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') + self.send_and_test_stream_message('merged_pull_request', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_public_msg(self) -> None: expected_message = u"baxterthehacker made [the repository](https://github.com/baxterthehacker/public-repo) public" - self.send_and_test_stream_message('public', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='public') + self.send_and_test_stream_message('public', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='public') def test_wiki_pages_msg(self) -> None: expected_message = u"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('wiki_pages', self.EXPECTED_SUBJECT_WIKI_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='gollum') + self.send_and_test_stream_message('wiki_pages', self.EXPECTED_TOPIC_WIKI_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='gollum') def test_watch_msg(self) -> None: expected_message = u"baxterthehacker starred [the repository](https://github.com/baxterthehacker/public-repo)" - self.send_and_test_stream_message('watch_repository', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='watch') + self.send_and_test_stream_message('watch_repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='watch') def test_repository_msg(self) -> None: expected_message = u"baxterthehacker created [the repository](https://github.com/baxterandthehackers/public-repo)" - self.send_and_test_stream_message('repository', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='repository') + self.send_and_test_stream_message('repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='repository') def test_team_add_msg(self) -> None: expected_message = u"[The repository](https://github.com/baxterandthehackers/public-repo) was added to team github" - self.send_and_test_stream_message('team_add', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='team_add') + self.send_and_test_stream_message('team_add', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='team_add') def test_release_msg(self) -> None: expected_message = u"baxterthehacker published [the release](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1)" - self.send_and_test_stream_message('release', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='release') + self.send_and_test_stream_message('release', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='release') def test_page_build_msg(self) -> None: expected_message = u"Github Pages build, trigerred by baxterthehacker, has finished building" - self.send_and_test_stream_message('page_build', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='page_build') + self.send_and_test_stream_message('page_build', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='page_build') def test_status_msg(self) -> None: expected_message = u"[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to success" - self.send_and_test_stream_message('status', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='status') + self.send_and_test_stream_message('status', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='status') def test_status_with_target_url_msg(self) -> None: expected_message = u"[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', - self.EXPECTED_SUBJECT_REPO_EVENTS, + self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='status' ) def test_pull_request_review_msg(self) -> None: expected_message = u"baxterthehacker submitted [PR Review](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)" - self.send_and_test_stream_message('pull_request_review', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review') + self.send_and_test_stream_message('pull_request_review', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review') def test_pull_request_review_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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_subject, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review') + self.send_and_test_stream_message('pull_request_review', expected_topic, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review') def test_pull_request_review_comment_msg(self) -> None: expected_message = u"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', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review_comment') + self.send_and_test_stream_message('pull_request_review_comment', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review_comment') def test_pull_request_review_comment_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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_subject, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review_comment') + self.send_and_test_stream_message('pull_request_review_comment', expected_topic, expected_message, HTTP_X_GITHUB_EVENT='pull_request_review_comment') def test_push_tag_msg(self) -> None: expected_message = u"baxterthehacker pushed tag abc" - self.send_and_test_stream_message('push_tag', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') + self.send_and_test_stream_message('push_tag', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='push') def test_pull_request_edited_msg(self) -> None: expected_message = u"baxterthehacker edited [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)\nfrom `changes` to `master`" - self.send_and_test_stream_message('edited_pull_request', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, + self.send_and_test_stream_message('edited_pull_request', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_assigned_msg(self) -> None: expected_message = u"baxterthehacker assigned [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker" - self.send_and_test_stream_message('assigned_pull_request', self.EXPECTED_SUBJECT_PR_EVENTS, expected_message, + self.send_and_test_stream_message('assigned_pull_request', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_assigned_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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('assigned_pull_request', expected_subject, expected_message, + self.send_and_test_stream_message('assigned_pull_request', expected_topic, expected_message, HTTP_X_GITHUB_EVENT='pull_request') def test_pull_request_unassigned_msg(self) -> None: @@ -300,10 +300,10 @@ class GithubWebhookTest(WebhookTestCase): def test_pull_request_review_requested_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"**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_subject, + expected_topic, expected_message, HTTP_X_GITHUB_EVENT='pull_request') diff --git a/zerver/webhooks/github_legacy/tests.py b/zerver/webhooks/github_legacy/tests.py index 5fe5b65052..6e73e26aca 100644 --- a/zerver/webhooks/github_legacy/tests.py +++ b/zerver/webhooks/github_legacy/tests.py @@ -53,12 +53,12 @@ class GithubV1HookTests(WebhookTestCase): return data def basic_test(self, fixture_name: str, stream_name: str, - expected_subject: str, expected_content: str, + expected_topic: str, expected_content: str, send_stream: bool=False, branches: Optional[str]=None) -> None: self.STREAM_NAME = stream_name self.SEND_STREAM = send_stream self.BRANCHES = branches - self.send_and_test_stream_message(fixture_name, expected_subject, expected_content, content_type=None) + self.send_and_test_stream_message(fixture_name, expected_topic, expected_content, content_type=None) def test_user_specified_branches(self) -> None: self.basic_test('push', 'my_commits', 'zulip-test / master', self.push_content, @@ -75,11 +75,11 @@ class GithubV1HookTests(WebhookTestCase): def test_push_multiple_commits(self) -> None: commit_info = "* Add baz ([48c329a](https://github.com/zbenjamin/zulip-test/commit/48c329a0b68a9a379ff195ee3f1c1f4ab0b2a89e))\n" - expected_subject = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 50 commits to branch master.\n\n{}[and {} more commit(s)]".format( + expected_topic = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 50 commits to branch master.\n\n{}[and {} more commit(s)]".format( commit_info * COMMITS_LIMIT, 50 - COMMITS_LIMIT, ) - self.basic_test('push_commits_more_than_limit', 'commits', 'zulip-test / master', expected_subject) + self.basic_test('push_commits_more_than_limit', 'commits', 'zulip-test / master', expected_topic) def test_issues_opened(self) -> None: self.basic_test('issues_opened', 'issues', @@ -178,12 +178,12 @@ class GithubV2HookTests(WebhookTestCase): return data def basic_test(self, fixture_name: str, stream_name: str, - expected_subject: str, expected_content: str, + expected_topic: str, expected_content: str, send_stream: bool=False, branches: Optional[str]=None) -> None: self.STREAM_NAME = stream_name self.SEND_STREAM = send_stream self.BRANCHES = branches - self.send_and_test_stream_message(fixture_name, expected_subject, expected_content, content_type=None) + self.send_and_test_stream_message(fixture_name, expected_topic, expected_content, content_type=None) def test_user_specified_branches(self) -> None: self.basic_test('push', 'my_commits', 'zulip-test / master', self.push_content, @@ -197,21 +197,21 @@ class GithubV2HookTests(WebhookTestCase): def test_push_multiple_commits(self) -> None: commit_info = "* Add baz ([48c329a](https://github.com/zbenjamin/zulip-test/commit/48c329a0b68a9a379ff195ee3f1c1f4ab0b2a89e))\n" - expected_subject = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 50 commits to branch master.\n\n{}[and {} more commit(s)]".format( + expected_topic = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 50 commits to branch master.\n\n{}[and {} more commit(s)]".format( commit_info * COMMITS_LIMIT, 50 - COMMITS_LIMIT, ) - self.basic_test('push_commits_more_than_limit', 'commits', 'zulip-test / master', expected_subject) + self.basic_test('push_commits_more_than_limit', 'commits', 'zulip-test / master', expected_topic) def test_push_multiple_committers(self) -> None: commit_info = "* Add baz ([48c329a](https://github.com/zbenjamin/zulip-test/commit/48c329a0b68a9a379ff195ee3f1c1f4ab0b2a89e))\n" - expected_subject = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 6 commits to branch master. Commits by tomasz (3), baxthehacker (2) and zbenjamin (1).\n\n{}* Add baz ([48c329a](https://github.com/zbenjamin/zulip-test/commit/48c329a0b68a9a379ff195ee3f1c1f4ab0b2a89e))".format(commit_info * 5) - self.basic_test('push_multiple_committers', 'commits', 'zulip-test / master', expected_subject) + expected_topic = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 6 commits to branch master. Commits by tomasz (3), baxthehacker (2) and zbenjamin (1).\n\n{}* Add baz ([48c329a](https://github.com/zbenjamin/zulip-test/commit/48c329a0b68a9a379ff195ee3f1c1f4ab0b2a89e))".format(commit_info * 5) + self.basic_test('push_multiple_committers', 'commits', 'zulip-test / master', expected_topic) def test_push_multiple_committers_with_others(self) -> None: commit_info = "* Final edit to baz, I swear ([b954491](https://github.com/zbenjamin/zulip-test/commit/b95449196980507f08209bdfdc4f1d611689b7a8))\n" - expected_subject = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 10 commits to branch master. Commits by baxthehacker (4), James (3), Tomasz (2) and others (1).\n\n{}* Final edit to baz, I swear ([b954491](https://github.com/zbenjamin/zulip-test/commit/b95449196980507f08209bdfdc4f1d611689b7a8))".format(commit_info * 9) - self.basic_test('push_multiple_committers_with_others', 'commits', 'zulip-test / master', expected_subject) + expected_topic = "zbenjamin [pushed](https://github.com/zbenjamin/zulip-test/compare/4f9adc4777d5...b95449196980) 10 commits to branch master. Commits by baxthehacker (4), James (3), Tomasz (2) and others (1).\n\n{}* Final edit to baz, I swear ([b954491](https://github.com/zbenjamin/zulip-test/commit/b95449196980507f08209bdfdc4f1d611689b7a8))".format(commit_info * 9) + self.basic_test('push_multiple_committers_with_others', 'commits', 'zulip-test / master', expected_topic) def test_legacy_hook(self) -> None: self.basic_test('push', 'commits', 'zulip-test / master', self.push_content) diff --git a/zerver/webhooks/gitlab/tests.py b/zerver/webhooks/gitlab/tests.py index ff4cb0f10b..d7e0041860 100644 --- a/zerver/webhooks/gitlab/tests.py +++ b/zerver/webhooks/gitlab/tests.py @@ -18,496 +18,496 @@ class GitlabHookTests(WebhookTestCase): self.send_and_test_stream_message('push', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_push_event_message(self) -> None: - expected_subject = u"my-awesome-project / tomek" + expected_topic = u"my-awesome-project / tomek" expected_message = u"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', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('push', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_push_local_branch_without_commits(self) -> None: - expected_subject = u"my-awesome-project / changes" + expected_topic = u"my-awesome-project / changes" expected_message = u"Eeshan Garg [pushed](https://gitlab.com/eeshangarg/my-awesome-project/compare/0000000000000000000000000000000000000000...68d7a5528cf423dfaac37dd62a56ac9cc8a884e3) the branch changes." - self.send_and_test_stream_message('push_local_branch_without_commits', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('push_local_branch_without_commits', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_push_event_message_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,tomek') - expected_subject = u"my-awesome-project / tomek" + expected_topic = u"my-awesome-project / tomek" expected_message = u"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', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('push', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_push_multiple_committers(self) -> None: - expected_subject = u"my-awesome-project / tomek" + expected_topic = u"my-awesome-project / tomek" expected_message = u"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_multiple_committers', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('push_multiple_committers', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_push_multiple_committers_with_others(self) -> None: - expected_subject = u"my-awesome-project / tomek" + expected_topic = u"my-awesome-project / tomek" commit_info = u"* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))\n" expected_message = u"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{}* b ([eb6ae1e](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9))".format(commit_info * 6) - self.send_and_test_stream_message('push_multiple_committers_with_others', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('push_multiple_committers_with_others', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_push_commits_more_than_limit_event_message(self) -> None: - expected_subject = u"my-awesome-project / tomek" + expected_topic = u"my-awesome-project / tomek" commits_info = u'* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 50 - COMMITS_LIMIT, ) - self.send_and_test_stream_message('push_commits_more_than_limit', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('push_commits_more_than_limit', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_push_commits_more_than_limit_message_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,tomek') - expected_subject = u"my-awesome-project / tomek" + expected_topic = u"my-awesome-project / tomek" commits_info = u'* b ([66abd2d](https://gitlab.com/tomaszkolek0/my-awesome-project/commit/66abd2da28809ffa128ed0447965cf11d7f863a7))\n' expected_message = u"Tomasz Kolek [pushed](https://gitlab.com/tomaszkolek0/my-awesome-project/compare/5fcdd5551fc3085df79bece2c32b1400802ac407...eb6ae1e591e0819dc5bf187c6bfe18ec065a80e9) 50 commits to branch tomek.\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 50 - COMMITS_LIMIT, ) - self.send_and_test_stream_message('push_commits_more_than_limit', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('push_commits_more_than_limit', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_remove_branch_event_message(self) -> None: - expected_subject = u"my-awesome-project / tomek" + expected_topic = u"my-awesome-project / tomek" expected_message = u"Tomasz Kolek deleted branch tomek" - self.send_and_test_stream_message('remove_branch', expected_subject, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") + self.send_and_test_stream_message('remove_branch', expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Push Hook") def test_add_tag_event_message(self) -> None: - expected_subject = u"my-awesome-project" + expected_topic = u"my-awesome-project" expected_message = u"Tomasz Kolek pushed tag xyz" self.send_and_test_stream_message( 'add_tag', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Tag Push Hook", ) def test_remove_tag_event_message(self) -> None: - expected_subject = u"my-awesome-project" + expected_topic = u"my-awesome-project" expected_message = u"Tomasz Kolek removed tag xyz" self.send_and_test_stream_message( 'remove_tag', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Tag Push Hook" ) def test_create_issue_without_assignee_event_message(self) -> None: - expected_subject = u"my-awesome-project / Issue #1 Issue title" + expected_topic = u"my-awesome-project / Issue #1 Issue title" expected_message = u"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( 'issue_created_without_assignee', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_create_issue_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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( 'issue_created_without_assignee', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_create_issue_with_assignee_event_message(self) -> None: - expected_subject = u"my-awesome-project / Issue #1 Issue title" + expected_topic = u"my-awesome-project / Issue #1 Issue title" expected_message = u"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( 'issue_created_with_assignee', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_create_issue_with_hidden_comment_in_description(self) -> None: - expected_subject = u"public-repo / Issue #3 New Issue with hidden comment" + expected_topic = u"public-repo / Issue #3 New Issue with hidden comment" expected_message = u"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( 'issue_created_with_hidden_comment_in_description', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_create_issue_with_null_description(self) -> None: - expected_subject = u"my-awesome-project / Issue #7 Issue without description" + expected_topic = u"my-awesome-project / Issue #7 Issue without description" expected_message = u"Eeshan Garg created [Issue #7](https://gitlab.com/eeshangarg/my-awesome-project/issues/7)" self.send_and_test_stream_message( 'issue_opened_with_null_description', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_update_issue_event_message(self) -> None: - expected_subject = u"my-awesome-project / Issue #1 Issue title_new" + expected_topic = u"my-awesome-project / Issue #1 Issue title_new" expected_message = u"Tomasz Kolek updated [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)" self.send_and_test_stream_message( 'issue_updated', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_update_issue_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"Tomasz Kolek updated [Issue #1 Issue title_new](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)" self.send_and_test_stream_message( 'issue_updated', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_close_issue_event_message(self) -> None: - expected_subject = u"my-awesome-project / Issue #1 Issue title_new" + expected_topic = u"my-awesome-project / Issue #1 Issue title_new" expected_message = u"Tomasz Kolek closed [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)" self.send_and_test_stream_message( 'issue_closed', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_reopen_issue_event_message(self) -> None: - expected_subject = u"my-awesome-project / Issue #1 Issue title_new" + expected_topic = u"my-awesome-project / Issue #1 Issue title_new" expected_message = u"Tomasz Kolek reopened [Issue #1](https://gitlab.com/tomaszkolek0/my-awesome-project/issues/1)" self.send_and_test_stream_message( 'issue_reopened', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Issue Hook" ) def test_note_commit_event_message(self) -> None: - expected_subject = u"my-awesome-project" + expected_topic = u"my-awesome-project" expected_message = u"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( 'commit_note', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Note Hook" ) def test_note_merge_request_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #1 Tomek" + expected_topic = u"my-awesome-project / MR #1 Tomek" expected_message = u"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( 'merge_request_note', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Note Hook" ) def test_note_merge_request_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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( 'merge_request_note', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Note Hook" ) def test_note_issue_event_message(self) -> None: - expected_subject = u"my-awesome-project / Issue #2 abc" + expected_topic = u"my-awesome-project / Issue #2 abc" expected_message = u"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( 'issue_note', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Note Hook" ) def test_note_issue_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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( 'issue_note', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Note Hook" ) def test_note_snippet_event_message(self) -> None: - expected_subject = u"my-awesome-project / Snippet #2 test" + expected_topic = u"my-awesome-project / Snippet #2 test" expected_message = u"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( 'snippet_note', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Note Hook" ) def test_note_snippet_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"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( 'snippet_note', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Note Hook" ) def test_merge_request_created_without_assignee_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #2 NEW MR" + expected_topic = u"my-awesome-project / MR #2 NEW MR" expected_message = u"Tomasz Kolek created [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)\nfrom `tomek` to `master`\n\n~~~ quote\ndescription of merge request\n~~~" self.send_and_test_stream_message( 'merge_request_created_without_assignee', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_created_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"Tomasz Kolek created [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)\nfrom `tomek` to `master`\n\n~~~ quote\ndescription of merge request\n~~~" self.send_and_test_stream_message( 'merge_request_created_without_assignee', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_created_with_assignee_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #3 New Merge Request" + expected_topic = u"my-awesome-project / MR #3 New Merge Request" expected_message = u"Tomasz Kolek created [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)(assigned to Tomasz Kolek)\nfrom `tomek` to `master`\n\n~~~ quote\ndescription of merge request\n~~~" self.send_and_test_stream_message( 'merge_request_created_with_assignee', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_closed_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #2 NEW MR" + expected_topic = u"my-awesome-project / MR #2 NEW MR" expected_message = u"Tomasz Kolek closed [MR #2](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)" self.send_and_test_stream_message( 'merge_request_closed', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_closed_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"Tomasz Kolek closed [MR #2 NEW MR](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/2)" self.send_and_test_stream_message( 'merge_request_closed', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_reopened_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #1 Update the README with author ..." + expected_topic = u"my-awesome-project / MR #1 Update the README with author ..." expected_message = u"Eeshan Garg reopened [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)" self.send_and_test_stream_message( 'merge_request_reopened', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_approved_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #1 Update the README with author ..." + expected_topic = u"my-awesome-project / MR #1 Update the README with author ..." expected_message = u"Eeshan Garg approved [MR #1](https://gitlab.com/eeshangarg/my-awesome-project/merge_requests/1)" self.send_and_test_stream_message( 'merge_request_approved', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_updated_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #3 New Merge Request" + expected_topic = u"my-awesome-project / MR #3 New Merge Request" expected_message = u"Tomasz Kolek updated [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)(assigned to Tomasz Kolek)\nfrom `tomek` to `master`\n\n~~~ quote\nupdated desc\n~~~" self.send_and_test_stream_message( 'merge_request_updated', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_added_commit_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #3 New Merge Request" + expected_topic = u"my-awesome-project / MR #3 New Merge Request" expected_message = u"Tomasz Kolek added commit(s) to [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)" self.send_and_test_stream_message( 'merge_request_added_commit', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_merge_request_merged_event_message(self) -> None: - expected_subject = u"my-awesome-project / MR #3 New Merge Request" + expected_topic = u"my-awesome-project / MR #3 New Merge Request" expected_message = u"Tomasz Kolek merged [MR #3](https://gitlab.com/tomaszkolek0/my-awesome-project/merge_requests/3)" self.send_and_test_stream_message( 'merge_request_merged', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Merge Request Hook" ) def test_wiki_page_opened_event_message(self) -> None: - expected_subject = u"my-awesome-project" + expected_topic = u"my-awesome-project" expected_message = u"Tomasz Kolek created [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." self.send_and_test_stream_message( 'wiki_page_opened', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Wiki Page Hook" ) def test_wiki_page_edited_event_message(self) -> None: - expected_subject = u"my-awesome-project" + expected_topic = u"my-awesome-project" expected_message = u"Tomasz Kolek updated [Wiki Page \"how to\"](https://gitlab.com/tomaszkolek0/my-awesome-project/wikis/how-to)." self.send_and_test_stream_message( 'wiki_page_edited', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Wiki Page Hook" ) def test_build_created_event_message(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Build job_name from test stage was created." self.send_and_test_stream_message( 'build_created', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Job Hook" ) def test_build_started_event_message(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Build job_name from test stage started." self.send_and_test_stream_message( 'build_started', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Job Hook" ) def test_build_succeeded_event_message(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Build job_name from test stage changed status to success." self.send_and_test_stream_message( 'build_succeeded', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Job Hook" ) def test_build_created_event_message_legacy_event_name(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Build job_name from test stage was created." self.send_and_test_stream_message( 'build_created', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Build Hook" ) def test_build_started_event_message_legacy_event_name(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Build job_name from test stage started." self.send_and_test_stream_message( 'build_started', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Build Hook" ) def test_build_succeeded_event_message_legacy_event_name(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Build job_name from test stage changed status to success." self.send_and_test_stream_message( 'build_succeeded', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Build Hook" ) def test_pipeline_succeeded_event_message(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Pipeline changed status to success with build(s):\n* job_name2 - success\n* job_name - success." self.send_and_test_stream_message( 'pipeline_succeeded', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Pipeline Hook" ) def test_pipeline_started_event_message(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Pipeline started with build(s):\n* job_name - running\n* job_name2 - pending." self.send_and_test_stream_message( 'pipeline_started', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Pipeline Hook" ) def test_pipeline_pending_event_message(self) -> None: - expected_subject = u"my-awesome-project / master" + expected_topic = u"my-awesome-project / master" expected_message = u"Pipeline was created with build(s):\n* job_name2 - pending\n* job_name - created." self.send_and_test_stream_message( 'pipeline_pending', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Pipeline Hook" ) def test_issue_type_test_payload(self) -> None: - expected_subject = u'public-repo' + expected_topic = u'public-repo' expected_message = u"Webhook for **public-repo** has been configured successfully! :tada:" self.send_and_test_stream_message( 'issue_test_payload', - expected_subject, + expected_topic, expected_message, HTTP_X_GITLAB_EVENT="Test Hook" ) diff --git a/zerver/webhooks/gogs/tests.py b/zerver/webhooks/gogs/tests.py index 2bf47f2983..f6d3643809 100644 --- a/zerver/webhooks/gogs/tests.py +++ b/zerver/webhooks/gogs/tests.py @@ -12,81 +12,81 @@ class GogsHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'gogs' def test_push(self) -> None: - expected_subject = u"try-git / master" + expected_topic = u"try-git / master" expected_message = u"""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))""" - self.send_and_test_stream_message('push', expected_subject, expected_message, HTTP_X_GOGS_EVENT='push') + self.send_and_test_stream_message('push', expected_topic, expected_message, HTTP_X_GOGS_EVENT='push') def test_push_multiple_committers(self) -> None: commit_info = u'* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' - expected_subject = u"try-git / master" + expected_topic = u"try-git / master" expected_message = u"""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{}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""".format(commit_info) - self.send_and_test_stream_message('push_commits_multiple_committers', expected_subject, expected_message, HTTP_X_GOGS_EVENT='push') + self.send_and_test_stream_message('push_commits_multiple_committers', expected_topic, expected_message, HTTP_X_GOGS_EVENT='push') def test_push_multiple_committers_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') commit_info = u'* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n' - expected_subject = u"try-git / master" + expected_topic = u"try-git / master" expected_message = u"""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{}* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))""".format(commit_info) - self.send_and_test_stream_message('push_commits_multiple_committers', expected_subject, expected_message, HTTP_X_GOGS_EVENT='push') + self.send_and_test_stream_message('push_commits_multiple_committers', expected_topic, expected_message, HTTP_X_GOGS_EVENT='push') def test_push_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_subject = u"try-git / master" + expected_topic = u"try-git / master" expected_message = u"""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))""" - self.send_and_test_stream_message('push', expected_subject, expected_message, HTTP_X_GOGS_EVENT='push') + self.send_and_test_stream_message('push', expected_topic, expected_message, HTTP_X_GOGS_EVENT='push') def test_push_commits_more_than_limits(self) -> None: - expected_subject = u"try-git / master" + expected_topic = u"try-git / master" commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n" expected_message = u"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 30 - COMMITS_LIMIT ) - self.send_and_test_stream_message('push_commits_more_than_limits', expected_subject, expected_message, HTTP_X_GOGS_EVENT='push') + self.send_and_test_stream_message('push_commits_more_than_limits', expected_topic, expected_message, HTTP_X_GOGS_EVENT='push') def test_push_commits_more_than_limits_filtered_by_branches(self) -> None: self.url = self.build_webhook_url(branches='master,development') - expected_subject = u"try-git / master" + expected_topic = u"try-git / master" commits_info = "* Webhook Test ([d8fce16](http://localhost:3000/john/try-git/commit/d8fce16c72a2ff56a5afc8a08645a6ce45491794))\n" expected_message = u"john [pushed](http://localhost:3000/john/try-git/compare/479e6b772b7fba19412457483f50b201286d0103...d8fce16c72a2ff56a5afc8a08645a6ce45491794) 30 commits to branch master. Commits by John (30).\n\n{}[and {} more commit(s)]".format( commits_info * COMMITS_LIMIT, 30 - COMMITS_LIMIT ) - self.send_and_test_stream_message('push_commits_more_than_limits', expected_subject, expected_message, HTTP_X_GOGS_EVENT='push') + self.send_and_test_stream_message('push_commits_more_than_limits', expected_topic, expected_message, HTTP_X_GOGS_EVENT='push') def test_new_branch(self) -> None: - expected_subject = u"try-git / my_feature" + expected_topic = u"try-git / my_feature" expected_message = u"john created [my_feature](http://localhost:3000/john/try-git/src/my_feature) branch" - self.send_and_test_stream_message('branch', expected_subject, expected_message, HTTP_X_GOGS_EVENT='create') + self.send_and_test_stream_message('branch', expected_topic, expected_message, HTTP_X_GOGS_EVENT='create') def test_pull_request_opened(self) -> None: - expected_subject = u"try-git / PR #1 Title Text for Pull Request" + expected_topic = u"try-git / PR #1 Title Text for Pull Request" expected_message = u"""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_subject, expected_message, HTTP_X_GOGS_EVENT='pull_request') + self.send_and_test_stream_message('pull_request_opened', expected_topic, expected_message, HTTP_X_GOGS_EVENT='pull_request') def test_pull_request_opened_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic='notifications') - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = u"""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_subject, expected_message, HTTP_X_GOGS_EVENT='pull_request') + self.send_and_test_stream_message('pull_request_opened', expected_topic, expected_message, HTTP_X_GOGS_EVENT='pull_request') def test_pull_request_closed(self) -> None: - expected_subject = u"try-git / PR #1 Title Text for Pull Request" + expected_topic = u"try-git / PR #1 Title Text for Pull Request" expected_message = u"""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_subject, expected_message, HTTP_X_GOGS_EVENT='pull_request') + self.send_and_test_stream_message('pull_request_closed', expected_topic, expected_message, HTTP_X_GOGS_EVENT='pull_request') def test_pull_request_merged(self) -> None: - expected_subject = u"try-git / PR #2 Title Text for Pull Request" + expected_topic = u"try-git / PR #2 Title Text for Pull Request" expected_message = u"""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_subject, expected_message, HTTP_X_GOGS_EVENT='pull_request') + self.send_and_test_stream_message('pull_request_merged', expected_topic, expected_message, HTTP_X_GOGS_EVENT='pull_request') @patch('zerver.webhooks.gogs.view.check_send_webhook_message') def test_push_filtered_by_branches_ignore(self, check_send_webhook_message_mock: MagicMock) -> None: diff --git a/zerver/webhooks/gosquared/tests.py b/zerver/webhooks/gosquared/tests.py index 342e8e8b58..6974c4b965 100644 --- a/zerver/webhooks/gosquared/tests.py +++ b/zerver/webhooks/gosquared/tests.py @@ -9,10 +9,10 @@ class GoSquaredHookTests(WebhookTestCase): # Note: Include a test function per each distinct message condition your integration supports def test_traffic_message(self) -> None: - expected_subject = "GoSquared - requestb.in" + expected_topic = "GoSquared - requestb.in" expected_message = u"[requestb.in](https://www.gosquared.com/now/GSN-595854-T) has 33 visitors online." - self.send_and_test_stream_message('traffic_spike', expected_subject, expected_message, + self.send_and_test_stream_message('traffic_spike', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/greenhouse/tests.py b/zerver/webhooks/greenhouse/tests.py index bb44c3d0e7..e9a7b77908 100644 --- a/zerver/webhooks/greenhouse/tests.py +++ b/zerver/webhooks/greenhouse/tests.py @@ -11,19 +11,19 @@ class GreenhouseHookTests(WebhookTestCase): CONTENT_TYPE = "application/x-www-form-urlencoded" def test_message_candidate_hired(self) -> None: - expected_subject = "Hire Candidate - 19" + expected_topic = "Hire Candidate - 19" expected_message = ("Hire Candidate\n>Johnny Smith\nID: 19" "\nApplying for role:\nDeveloper\n**Emails:**" "\nPersonal\npersonal@example.com\nWork\nwork@example.com\n\n\n>" "**Attachments:**\n[Resume](https://prod-heroku.s3.amazonaws.com/...)") self.send_and_test_stream_message('candidate_hired', - expected_subject, + expected_topic, expected_message, content_type=self.CONTENT_TYPE) def test_message_candidate_rejected(self) -> None: - expected_subject = "Reject Candidate - 265788" + expected_topic = "Reject Candidate - 265788" expected_message = ("Reject Candidate\n>Hector Porter\nID: " "265788\nApplying for role:\nDesigner" "\n**Emails:**\nPersonal\n" @@ -31,12 +31,12 @@ class GreenhouseHookTests(WebhookTestCase): "**Attachments:**\n[Resume](https://prod-heroku.s3.amazonaws.com/...)") self.send_and_test_stream_message('candidate_rejected', - expected_subject, + expected_topic, expected_message, content_type=self.CONTENT_TYPE) def test_message_candidate_stage_change(self) -> None: - expected_subject = "Candidate Stage Change - 265772" + expected_topic = "Candidate Stage Change - 265772" expected_message = ("Candidate Stage Change\n>Giuseppe Hurley" "\nID: 265772\nApplying for role:\n" "Designer\n**Emails:**\nPersonal" @@ -46,12 +46,12 @@ class GreenhouseHookTests(WebhookTestCase): "\n[Attachment](https://prod-heroku.s3.amazonaws.com/...)") self.send_and_test_stream_message('candidate_stage_change', - expected_subject, + expected_topic, expected_message, content_type=self.CONTENT_TYPE) def test_message_prospect_created(self) -> None: - expected_subject = "New Prospect Application - 968190" + expected_topic = "New Prospect Application - 968190" expected_message = ("New Prospect Application\n>Trisha Troy" "\nID: 968190\nApplying for role:\n" "Designer\n**Emails:**\nPersonal" @@ -59,7 +59,7 @@ class GreenhouseHookTests(WebhookTestCase): "\n[Resume](https://prod-heroku.s3.amazonaws.com/...)") self.send_and_test_stream_message('prospect_created', - expected_subject, + expected_topic, expected_message, content_type=self.CONTENT_TYPE) diff --git a/zerver/webhooks/groove/tests.py b/zerver/webhooks/groove/tests.py index 561144aae5..2c7b2247ca 100644 --- a/zerver/webhooks/groove/tests.py +++ b/zerver/webhooks/groove/tests.py @@ -7,49 +7,49 @@ class GrooveHookTests(WebhookTestCase): # This test simulates the condition when a new ticket comes. def test_groove_ticket_started(self) -> None: - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = (u"New ticket from Test Name\n" u"```quote\n" u"**[Ticket #9: Test Subject](https://ghostfox.groovehq.com/groove_client/tickets/68659446)**\n" u"The content of the body goes here.\n" u"```") - self.send_and_test_stream_message('ticket_started', expected_subject, expected_message, + self.send_and_test_stream_message('ticket_started', expected_topic, expected_message, content_type="application/x-www-form-urlencoded", HTTP_X_GROOVE_EVENT="ticket_started") # This simulates the condition when a ticket # is assigned to an agent. def test_groove_ticket_assigned_agent_only(self) -> None: - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = (u"An open ticket has been assigned to agent@example.com\n" u"```quote\n" u"**[Ticket #9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446)**\n" u"```") - self.send_and_test_stream_message('ticket_assigned_agent_only', expected_subject, expected_message, + self.send_and_test_stream_message('ticket_assigned_agent_only', expected_topic, expected_message, content_type="application/x-www-form-urlencoded", HTTP_X_GROOVE_EVENT="ticket_assigned") # This simulates the condition when a ticket # is assigned to an agent in a group. def test_groove_ticket_assigned_agent_and_group(self) -> None: - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = (u"An open ticket has been assigned to agent@example.com from group2\n" u"```quote\n" u"**[Ticket #9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446)**\n" u"```") - self.send_and_test_stream_message('ticket_assigned_agent_and_group', expected_subject, expected_message, + self.send_and_test_stream_message('ticket_assigned_agent_and_group', expected_topic, expected_message, content_type="application/x-www-form-urlencoded", HTTP_X_GROOVE_EVENT="ticket_assigned") # This simulates the condition when a ticket # is assigned to a group. def test_groove_ticket_assigned_group_only(self) -> None: - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = (u"A pending ticket has been assigned to group2\n" u"```quote\n" u"**[Ticket #9: Test Subject](https://testteam.groovehq.com/groove_client/tickets/68659446)**\n" u"```") - self.send_and_test_stream_message('ticket_assigned_group_only', expected_subject, expected_message, + self.send_and_test_stream_message('ticket_assigned_group_only', expected_topic, expected_message, content_type="application/x-www-form-urlencoded", HTTP_X_GROOVE_EVENT="ticket_assigned") @@ -64,37 +64,37 @@ class GrooveHookTests(WebhookTestCase): # This simulates the notification when an agent replied to a ticket. def test_groove_agent_replied(self) -> None: - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = (u"agent@example.com has just replied to a ticket\n" u"```quote\n" u"**[Ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295)**\n" u"Hello , This is a reply from an agent to a ticket\n" u"```") - self.send_and_test_stream_message('agent_replied', expected_subject, expected_message, + self.send_and_test_stream_message('agent_replied', expected_topic, expected_message, content_type="application/x-www-form-urlencoded", HTTP_X_GROOVE_EVENT="agent_replied") # This simulates the condition when a customer replied to a ticket. def test_groove_customer_replied(self) -> None: - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = (u"rambo@example.com has just replied to a ticket\n" u"```quote\n" u"**[Ticket #440](https://ghostfox.groovehq.com/groove_client/tickets/68666538)**\n" u"Hello agent, thanks for getting back. This is how a reply from customer looks like.\n" u"```") - self.send_and_test_stream_message('customer_replied', expected_subject, expected_message, + self.send_and_test_stream_message('customer_replied', expected_topic, expected_message, content_type="application/x-www-form-urlencoded", HTTP_X_GROOVE_EVENT="customer_replied") # This simulates the condition when an agent left a note. def test_groove_note_added(self) -> None: - expected_subject = u"notifications" + expected_topic = u"notifications" expected_message = (u"anotheragent@example.com has left a note\n" u"```quote\n" u"**[Ticket #776](https://ghostfox.groovehq.com/groove_client/tickets/68667295)**\n" u"This is a note added to a ticket\n" u"```") - self.send_and_test_stream_message('note_added', expected_subject, expected_message, + self.send_and_test_stream_message('note_added', expected_topic, expected_message, content_type="application/x-ww-form-urlencoded", HTTP_X_GROOVE_EVENT="note_added") diff --git a/zerver/webhooks/hellosign/tests.py b/zerver/webhooks/hellosign/tests.py index 8281defc02..d0b6e96324 100644 --- a/zerver/webhooks/hellosign/tests.py +++ b/zerver/webhooks/hellosign/tests.py @@ -8,33 +8,33 @@ class HelloSignHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'hellosign' def test_signatures_message(self) -> None: - expected_subject = "NDA with Acme Co." + expected_topic = "NDA with Acme Co." expected_message = ("The `NDA with Acme Co.` document is awaiting the signature of " "Jack, and was just signed by Jill.") - self.send_and_test_stream_message('signatures', expected_subject, expected_message, + self.send_and_test_stream_message('signatures', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_signatures_message_signed_by_one(self) -> None: - expected_subject = "NDA with Acme Co." + expected_topic = "NDA with Acme Co." expected_message = ("The `NDA with Acme Co.` document was just signed by Jill.") self.send_and_test_stream_message('signatures_signed_by_one_signatory', - expected_subject, expected_message, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_signatures_message_with_four_signatories(self) -> None: - expected_subject = "Signature doc" + expected_topic = "Signature doc" expected_message = ("The `Signature doc` document is awaiting the signature of " "Eeshan Garg, John Smith, Jane Doe, and Stephen Strange.") - self.send_and_test_stream_message('signatures_with_four_signatories', expected_subject, expected_message, + self.send_and_test_stream_message('signatures_with_four_signatories', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_signatures_message_with_own_subject(self) -> None: - expected_subject = "Our own subject." - self.url = self.build_webhook_url(topic=expected_subject) + expected_topic = "Our own subject." + self.url = self.build_webhook_url(topic=expected_topic) expected_message = ("The `NDA with Acme Co.` document is awaiting the signature of " "Jack, and was just signed by Jill.") - self.send_and_test_stream_message('signatures_with_own_subject', expected_subject, expected_message, - content_type="application/x-www-form-urlencoded", topic=expected_subject) + self.send_and_test_stream_message('signatures_with_own_subject', expected_topic, expected_message, + content_type="application/x-www-form-urlencoded", topic=expected_topic) def get_body(self, fixture_name: str) -> str: return self.webhook_fixture_data("hellosign", fixture_name, file_type="json") diff --git a/zerver/webhooks/helloworld/tests.py b/zerver/webhooks/helloworld/tests.py index b460418224..263f7c15cf 100644 --- a/zerver/webhooks/helloworld/tests.py +++ b/zerver/webhooks/helloworld/tests.py @@ -12,19 +12,19 @@ class HelloWorldHookTests(WebhookTestCase): # Note: Include a test function per each distinct message condition your integration supports def test_hello_message(self) -> None: - expected_subject = u"Hello World" + expected_topic = u"Hello World" expected_message = u"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 - self.send_and_test_stream_message('hello', expected_subject, expected_message, + self.send_and_test_stream_message('hello', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_goodbye_message(self) -> None: - expected_subject = u"Hello World" + expected_topic = u"Hello World" expected_message = u"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 - self.send_and_test_stream_message('goodbye', expected_subject, expected_message, + self.send_and_test_stream_message('goodbye', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_pm_to_bot_owner(self) -> None: @@ -48,11 +48,11 @@ class HelloWorldHookTests(WebhookTestCase): def test_custom_topic(self) -> None: # Note that this is really just a test for check_send_webhook_message - expected_subject = u"Custom Topic" - self.url = self.build_webhook_url(topic=expected_subject) + expected_topic = u"Custom Topic" + self.url = self.build_webhook_url(topic=expected_topic) expected_message = u"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_subject, expected_message, + self.send_and_test_stream_message('goodbye', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/heroku/tests.py b/zerver/webhooks/heroku/tests.py index 7c24cffa6f..141ebceb15 100644 --- a/zerver/webhooks/heroku/tests.py +++ b/zerver/webhooks/heroku/tests.py @@ -7,24 +7,24 @@ class HerokuHookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/heroku?stream={stream}&api_key={api_key}" def test_deployment(self) -> None: - expected_subject = "sample-project" + expected_topic = "sample-project" expected_message = u"""user@example.com deployed version 3eb5f44 of \ [sample-project](http://sample-project.herokuapp.com) ``` quote * Example User: Test commit for Deploy Hook 2 ```""" - self.send_and_test_stream_message('deploy', expected_subject, expected_message, + self.send_and_test_stream_message('deploy', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_deployment_multiple_commits(self) -> None: - expected_subject = "sample-project" + expected_topic = "sample-project" expected_message = u"""user@example.com deployed version 3eb5f44 of \ [sample-project](http://sample-project.herokuapp.com) ``` quote * Example User: Test commit for Deploy Hook * Example User: Second test commit for Deploy Hook 2 ```""" - self.send_and_test_stream_message('deploy_multiple_commits', expected_subject, expected_message, + self.send_and_test_stream_message('deploy_multiple_commits', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/homeassistant/tests.py b/zerver/webhooks/homeassistant/tests.py index 18516bad87..0d18ce448d 100644 --- a/zerver/webhooks/homeassistant/tests.py +++ b/zerver/webhooks/homeassistant/tests.py @@ -7,17 +7,17 @@ class HomeAssistantHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'homeassistant' def test_simplereq(self) -> None: - expected_subject = "homeassistant" + expected_topic = "homeassistant" expected_message = "The sun will be shining today!" - self.send_and_test_stream_message('simplereq', expected_subject, expected_message, + self.send_and_test_stream_message('simplereq', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_req_with_title(self) -> None: - expected_subject = "Weather forecast" + expected_topic = "Weather forecast" expected_message = "It will be 30 degrees Celsius out there today!" - self.send_and_test_stream_message('reqwithtitle', expected_subject, expected_message, + self.send_and_test_stream_message('reqwithtitle', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/ifttt/tests.py b/zerver/webhooks/ifttt/tests.py index 4d4491679d..f13615c6ee 100644 --- a/zerver/webhooks/ifttt/tests.py +++ b/zerver/webhooks/ifttt/tests.py @@ -7,14 +7,14 @@ class IFTTTHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'ifttt' def test_ifttt_when_subject_and_body_are_correct(self) -> None: - expected_subject = u"Email sent from email@email.com" + expected_topic = u"Email sent from email@email.com" expected_message = u"Email subject: Subject" - self.send_and_test_stream_message('correct_subject_and_body', expected_subject, expected_message) + self.send_and_test_stream_message('correct_subject_and_body', expected_topic, expected_message) def test_ifttt_when_topic_and_body_are_correct(self) -> None: - expected_subject = u"Email sent from email@email.com" + expected_topic = u"Email sent from email@email.com" expected_message = u"Email subject: Subject" - self.send_and_test_stream_message('correct_topic_and_body', expected_subject, expected_message) + self.send_and_test_stream_message('correct_topic_and_body', expected_topic, expected_message) def test_ifttt_when_topic_is_missing(self) -> None: self.url = self.build_webhook_url() diff --git a/zerver/webhooks/insping/tests.py b/zerver/webhooks/insping/tests.py index ec41957259..c94a639c7f 100644 --- a/zerver/webhooks/insping/tests.py +++ b/zerver/webhooks/insping/tests.py @@ -9,25 +9,25 @@ class InspingHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'insping' def test_website_state_available_message(self) -> None: - expected_subject = u"insping" + expected_topic = u"insping" expected_message = u"State changed: Available\n" \ u"URL: http://privisus.zulipdev.org:9991\n" \ u"Response time: 223 ms\n" \ u"Timestamp: Fri Dec 29 17:23:46 2017" self.send_and_test_stream_message('website_state_available', - expected_subject, expected_message, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_website_state_not_responding_message(self) -> None: - expected_subject = u"insping" + expected_topic = u"insping" expected_message = u"State changed: Not Responding\n" \ u"URL: http://privisus.zulipdev.org:9991\n" \ u"Response time: 942 ms\n" \ u"Timestamp: Fri Dec 29 17:13:46 2017" self.send_and_test_stream_message('website_state_not_responding', - expected_subject, expected_message, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/intercom/tests.py b/zerver/webhooks/intercom/tests.py index 1dd7c9c61c..16e6245523 100644 --- a/zerver/webhooks/intercom/tests.py +++ b/zerver/webhooks/intercom/tests.py @@ -6,13 +6,13 @@ class IntercomWebHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'intercom' def test_user_created_message(self) -> None: - expected_subject = u"user tag created" + expected_topic = u"user tag created" expected_message = ('*10:43:22 2017-12-17* **user tag created**: \n' ' - User Name: John Doe\n' ' - User Email: john.doe@gmail.com\n' ' - User Phone: 9876543211') - self.send_and_test_stream_message('user_created', expected_subject, expected_message, + self.send_and_test_stream_message('user_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/jira/tests.py b/zerver/webhooks/jira/tests.py index b20143e686..428122faca 100644 --- a/zerver/webhooks/jira/tests.py +++ b/zerver/webhooks/jira/tests.py @@ -23,12 +23,12 @@ class JiraHookTests(WebhookTestCase): > New bug with hook""") def test_created(self) -> None: - expected_subject = "BUG-15: New bug with hook" + expected_topic = "BUG-15: New bug with hook" expected_message = """Leo Franchi **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**: > New bug with hook""" - self.send_and_test_stream_message('created_v1', expected_subject, expected_message) - self.send_and_test_stream_message('created_v2', expected_subject, expected_message) + self.send_and_test_stream_message('created_v1', expected_topic, expected_message) + self.send_and_test_stream_message('created_v2', expected_topic, expected_message) def test_created_with_stream_with_spaces_escaped(self) -> None: self.STREAM_NAME = quote('jira alerts') @@ -40,13 +40,13 @@ class JiraHookTests(WebhookTestCase): self.assert_json_success(result) - expected_subject = "BUG-15: New bug with hook" + expected_topic = "BUG-15: New bug with hook" expected_message = """Leo Franchi **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**: > New bug with hook""" msg = self.get_last_message() self.assertEqual(msg.content, expected_message) - self.assertEqual(msg.topic_name(), expected_subject) + self.assertEqual(msg.topic_name(), expected_topic) def test_created_with_stream_with_spaces_double_escaped(self) -> None: self.STREAM_NAME = quote(quote('jira alerts')) @@ -58,87 +58,87 @@ class JiraHookTests(WebhookTestCase): self.assert_json_success(result) - expected_subject = "BUG-15: New bug with hook" + expected_topic = "BUG-15: New bug with hook" expected_message = """Leo Franchi **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**: > New bug with hook""" msg = self.get_last_message() self.assertEqual(msg.content, expected_message) - self.assertEqual(msg.topic_name(), expected_subject) + self.assertEqual(msg.topic_name(), expected_topic) def test_created_with_unicode(self) -> None: - expected_subject = u"BUG-15: New bug with à hook" + expected_topic = u"BUG-15: New bug with à hook" expected_message = u"""Leo Franchià **created** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) priority Major, assigned to **no one**: > New bug with à hook""" - self.send_and_test_stream_message('created_with_unicode_v1', expected_subject, expected_message) - self.send_and_test_stream_message('created_with_unicode_v2', expected_subject, expected_message) + self.send_and_test_stream_message('created_with_unicode_v1', expected_topic, expected_message) + self.send_and_test_stream_message('created_with_unicode_v2', expected_topic, expected_message) def test_created_assignee(self) -> None: - expected_subject = "TEST-4: Test Created Assignee" + expected_topic = "TEST-4: Test Created Assignee" expected_message = """Leonardo Franchi [Administrator] **created** [TEST-4](https://zulipp.atlassian.net/browse/TEST-4) priority Major, assigned to **Leonardo Franchi [Administrator]**: > Test Created Assignee""" - self.send_and_test_stream_message('created_assignee_v1', expected_subject, expected_message) - self.send_and_test_stream_message('created_assignee_v2', expected_subject, expected_message) + self.send_and_test_stream_message('created_assignee_v1', expected_topic, expected_message) + self.send_and_test_stream_message('created_assignee_v2', expected_topic, expected_message) def test_commented(self) -> None: - expected_subject = "BUG-15: New bug with hook" + expected_topic = "BUG-15: New bug with hook" expected_message = """Leo Franchi **added comment to** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**): Adding a comment. Oh, what a comment it is!""" - self.send_and_test_stream_message('commented_v1', expected_subject, expected_message) - self.send_and_test_stream_message('commented_v2', expected_subject, expected_message) + self.send_and_test_stream_message('commented_v1', expected_topic, expected_message) + self.send_and_test_stream_message('commented_v2', expected_topic, expected_message) def test_comment_edited(self) -> None: - expected_subject = "BUG-15: New bug with hook" + expected_topic = "BUG-15: New bug with hook" expected_message = """Leo Franchi **edited comment on** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**): Adding a comment. Oh, what a comment it is!""" - self.send_and_test_stream_message('comment_edited_v2', expected_subject, expected_message) + self.send_and_test_stream_message('comment_edited_v2', expected_topic, expected_message) def test_comment_deleted(self) -> None: - expected_subject = "TOM-1: New Issue" + expected_topic = "TOM-1: New Issue" expected_message = "Tomasz Kolek **deleted comment from** [TOM-1](https://zuliptomek.atlassian.net/browse/TOM-1) (assigned to **kolaszek@go2.pl**)" - self.send_and_test_stream_message('comment_deleted_v2', expected_subject, expected_message) + self.send_and_test_stream_message('comment_deleted_v2', expected_topic, expected_message) def test_commented_markup(self) -> None: - expected_subject = "TEST-7: Testing of rich text" + expected_topic = "TEST-7: Testing of rich text" expected_message = """Leonardo Franchi [Administrator] **added comment to** [TEST-7](https://zulipp.atlassian.net/browse/TEST-7):\n\n\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~~~""" - self.send_and_test_stream_message('commented_markup_v1', expected_subject, expected_message) - self.send_and_test_stream_message('commented_markup_v2', expected_subject, expected_message) + self.send_and_test_stream_message('commented_markup_v1', expected_topic, expected_message) + self.send_and_test_stream_message('commented_markup_v2', expected_topic, expected_message) def test_deleted(self) -> None: - expected_subject = "BUG-15: New bug with hook" + expected_topic = "BUG-15: New bug with hook" expected_message = "Leo Franchi **deleted** [BUG-15](http://lfranchi.com:8080/browse/BUG-15)!" - self.send_and_test_stream_message('deleted_v1', expected_subject, expected_message) - self.send_and_test_stream_message('deleted_v2', expected_subject, expected_message) + self.send_and_test_stream_message('deleted_v1', expected_topic, expected_message) + self.send_and_test_stream_message('deleted_v2', expected_topic, expected_message) def test_reassigned(self) -> None: - expected_subject = "BUG-15: New bug with hook" + expected_topic = "BUG-15: New bug with hook" expected_message = """Leo Franchi **updated** [BUG-15](http://lfranchi.com:8080/browse/BUG-15) (assigned to **Othello, the Moor of Venice**): * Changed assignee to **Othello, the Moor of Venice**""" - self.send_and_test_stream_message('reassigned_v1', expected_subject, expected_message) - self.send_and_test_stream_message('reassigned_v2', expected_subject, expected_message) + self.send_and_test_stream_message('reassigned_v1', expected_topic, expected_message) + self.send_and_test_stream_message('reassigned_v2', expected_topic, expected_message) def test_priority_updated(self) -> None: - expected_subject = "TEST-1: Fix That" + expected_topic = "TEST-1: Fix That" expected_message = """Leonardo Franchi [Administrator] **updated** [TEST-1](https://zulipp.atlassian.net/browse/TEST-1) (assigned to **leo@zulip.com**): * Changed priority from **Critical** to **Major**""" - self.send_and_test_stream_message('updated_priority_v1', expected_subject, expected_message) - self.send_and_test_stream_message('updated_priority_v2', expected_subject, expected_message) + self.send_and_test_stream_message('updated_priority_v1', expected_topic, expected_message) + self.send_and_test_stream_message('updated_priority_v2', expected_topic, expected_message) def test_status_changed(self) -> None: - expected_subject = "TEST-1: Fix That" + expected_topic = "TEST-1: Fix That" expected_message = """Leonardo Franchi [Administrator] **updated** [TEST-1](https://zulipp.atlassian.net/browse/TEST-1): * Changed status from **To Do** to **In Progress**""" - self.send_and_test_stream_message('change_status_v1', expected_subject, expected_message) - self.send_and_test_stream_message('change_status_v2', expected_subject, expected_message) + self.send_and_test_stream_message('change_status_v1', expected_topic, expected_message) + self.send_and_test_stream_message('change_status_v2', expected_topic, expected_message) def get_body(self, fixture_name: str) -> str: return self.webhook_fixture_data('jira', fixture_name) diff --git a/zerver/webhooks/librato/tests.py b/zerver/webhooks/librato/tests.py index f95595fe8f..a0e2a57821 100644 --- a/zerver/webhooks/librato/tests.py +++ b/zerver/webhooks/librato/tests.py @@ -16,9 +16,9 @@ class LibratoHookTests(WebhookTestCase): return urllib.parse.urlencode({'payload': self.webhook_fixture_data("librato", fixture_name, file_type='json')}) def test_alert_message_with_default_topic(self) -> None: - expected_subject = '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" - self.send_and_test_stream_message('alert', expected_subject, expected_message, content_type="application/x-www-form-urlencoded") + self.send_and_test_stream_message('alert', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_alert_message_with_custom_topic(self) -> None: custom_topic = 'custom_name' @@ -28,17 +28,17 @@ class LibratoHookTests(WebhookTestCase): 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_subject = 'Alert ToHighTemeprature' - self.send_and_test_stream_message('three_conditions_alert', expected_subject, expected_message, content_type="application/x-www-form-urlencoded") + expected_topic = 'Alert ToHighTemeprature' + self.send_and_test_stream_message('three_conditions_alert', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_alert_clear(self) -> None: - expected_subject = '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!" - self.send_and_test_stream_message('alert_cleared', expected_subject, expected_message, content_type="application/x-www-form-urlencoded") + self.send_and_test_stream_message('alert_cleared', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_snapshot(self) -> None: self.IS_ATTACHMENT = True - expected_subject = '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)" - self.send_and_test_stream_message('snapshot', expected_subject, expected_message, content_type="application/x-www-form-urlencoded") + self.send_and_test_stream_message('snapshot', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") self.IS_ATTACHMENT = False diff --git a/zerver/webhooks/netlify/tests.py b/zerver/webhooks/netlify/tests.py index 43867afce4..5ba64d5ad1 100644 --- a/zerver/webhooks/netlify/tests.py +++ b/zerver/webhooks/netlify/tests.py @@ -9,44 +9,44 @@ class NetlifyHookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/netlify?stream={stream}&api_key={api_key}" def test_building_message(self) -> None: - expected_subject = u"master" + expected_topic = u"master" expected_message = u'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_subject, expected_message, + self.send_and_test_stream_message('deploy_building', expected_topic, expected_message, content_type="application/json", HTTP_X_NETLIFY_EVENT='deploy_building') def test_created_message(self) -> None: - expected_subject = u"master" + expected_topic = u"master" expected_message = u'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_subject, expected_message, + self.send_and_test_stream_message('deploy_created', expected_topic, expected_message, content_type="application/json", HTTP_X_NETLIFY_EVENT='deploy_created') def test_failed_message(self) -> None: - expected_subject = u"master" + expected_topic = u"master" expected_message = (u"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " u"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_subject, expected_message, + self.send_and_test_stream_message('deploy_failed', expected_topic, expected_message, content_type="application/json", HTTP_X_NETLIFY_EVENT='deploy_failed') def test_locked_message(self) -> None: - expected_subject = u"master" + expected_topic = u"master" expected_message = (u"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " u"on branch master is now locked." ) - self.send_and_test_stream_message('deploy_locked', expected_subject, expected_message, + self.send_and_test_stream_message('deploy_locked', expected_topic, expected_message, content_type="application/json", HTTP_X_NETLIFY_EVENT='deploy_locked') def test_unlocked_message(self) -> None: - expected_subject = u"master" + expected_topic = u"master" expected_message = (u"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) " u"on branch master is now unlocked." ) - self.send_and_test_stream_message('deploy_unlocked', expected_subject, expected_message, + self.send_and_test_stream_message('deploy_unlocked', expected_topic, expected_message, content_type="application/json", HTTP_X_NETLIFY_EVENT='deploy_unlocked') def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/newrelic/tests.py b/zerver/webhooks/newrelic/tests.py index d168460a3b..1a93b69b6c 100644 --- a/zerver/webhooks/newrelic/tests.py +++ b/zerver/webhooks/newrelic/tests.py @@ -7,18 +7,18 @@ class NewRelicHookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/newrelic?stream={stream}&api_key={api_key}" def test_alert(self) -> None: - expected_subject = "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\n\ [View alert](https://rpm.newrelc.com/accounts/[account_id]/applications/[application_id]/incidents/[incident_id])' - self.send_and_test_stream_message('alert', expected_subject, expected_message, + self.send_and_test_stream_message('alert', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_deployment(self) -> None: - expected_subject = 'Test App deploy' + expected_topic = 'Test App deploy' expected_message = '`1242` deployed by **Zulip Test**\n\ Description sent via curl\n\nChangelog string' - self.send_and_test_stream_message('deployment', expected_subject, expected_message, + self.send_and_test_stream_message('deployment', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/opbeat/tests.py b/zerver/webhooks/opbeat/tests.py index 871c8f893f..20cf8715a4 100644 --- a/zerver/webhooks/opbeat/tests.py +++ b/zerver/webhooks/opbeat/tests.py @@ -10,7 +10,7 @@ class OpbeatHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'opbeat' def test_comment(self) -> None: - expected_subject = "foo commented on E#2" + expected_topic = "foo commented on E#2" expected_message = ''' **[foo commented on E#2](https://opbeat.com/foo/test-flask-app/errors/2/#activity-5df00003ea4e42458db48446692f6d37)** test comment @@ -21,11 +21,11 @@ test comment >**Most recent Occurrence** >in app.py >A warning occurred (42 apples)''' - self.send_and_test_stream_message('new_comment', expected_subject, expected_message, + self.send_and_test_stream_message('new_comment', expected_topic, expected_message, content_type="application/json") def test_new_app(self) -> None: - expected_subject = "foo" + expected_topic = "foo" expected_message = ''' **foo** App foo created @@ -33,26 +33,26 @@ App foo created **[foo](https://opbeat.com/bar/foo/)** >language: nodejs >framework: custom''' - self.send_and_test_stream_message('new_app', expected_subject, expected_message, + self.send_and_test_stream_message('new_app', expected_topic, expected_message, content_type="application/json") def test_get_empty_value(self) -> None: self.assertEqual(get_value({'key': 'value'}, 'foo'), '') def test_no_subject_type(self) -> None: - expected_subject = "test title" + expected_topic = "test title" expected_message = ''' **test title** test summary''' self.send_and_test_stream_message( 'unsupported_object', - expected_subject, + expected_topic, expected_message, content_type='application/json' ) def test_error_fixed(self) -> None: - expected_subject = 'foo marked E#2 as fixed' + expected_topic = 'foo marked E#2 as fixed' expected_message = ''' **[foo marked E#2 as fixed](https://opbeat.com/test_org/test-flask-app/errors/2/#activity-bf991a45d9184b0ca6fb3d48d3db4c38)** foo marked the error group as fixed @@ -63,10 +63,10 @@ foo marked the error group as fixed >in app.py >A warning occurred (42 apples)''' self.send_and_test_stream_message( - 'error_fixed', expected_subject, expected_message, content_type='application/json') + 'error_fixed', expected_topic, expected_message, content_type='application/json') def test_error_reopened(self) -> None: - expected_subject = 'foo reopened E#2' + expected_topic = 'foo reopened E#2' expected_message = ''' **[foo reopened E#2](https://opbeat.com/test_org/test-flask-app/errors/2/#activity-38a556dfc0b04a59a586359bbce1463d)** foo reopened the error group @@ -77,10 +77,10 @@ foo reopened the error group >in app.py >A warning occurred (42 apples)''' self.send_and_test_stream_message( - 'error_reopen', expected_subject, expected_message, content_type='application/json') + 'error_reopen', expected_topic, expected_message, content_type='application/json') def test_error_regressed(self) -> None: - expected_subject = 'E#2 regressed' + expected_topic = 'E#2 regressed' expected_message = ''' **[E#2 regressed](https://opbeat.com/test_org/test-flask-app/errors/2/#activity-c0396f38323a4fa7b314f87d5ed9cdd2)** The error group regressed @@ -91,4 +91,4 @@ The error group regressed >in app.py >A warning occurred (42 apples)''' self.send_and_test_stream_message( - 'new_error', expected_subject, expected_message, content_type='application/json') + 'new_error', expected_topic, expected_message, content_type='application/json') diff --git a/zerver/webhooks/opsgenie/tests.py b/zerver/webhooks/opsgenie/tests.py index 030b4720fa..62ce07de87 100644 --- a/zerver/webhooks/opsgenie/tests.py +++ b/zerver/webhooks/opsgenie/tests.py @@ -8,28 +8,28 @@ class OpsGenieHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'opsgenie' def test_acknowledge_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *Acknowledge*\n" u"Message: *test alert*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('acknowledge', expected_subject, expected_message, + self.send_and_test_stream_message('acknowledge', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_addnote_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *AddNote*\n" u"Note: *note to test alert*\n" u"Message: *test alert*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('addnote', expected_subject, expected_message, + self.send_and_test_stream_message('addnote', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_addrecipient_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *AddRecipient*\n" u"Recipient: *team2_escalation*\n" @@ -37,118 +37,118 @@ class OpsGenieHookTests(WebhookTestCase): u"`tag1` `tag2`" ) # use fixture named helloworld_hello - self.send_and_test_stream_message('addrecipient', expected_subject, expected_message, + self.send_and_test_stream_message('addrecipient', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_addtags_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *AddTags*\n" u"Added tags: *tag1,tag2,tag3*\n" u"Message: *test alert*\n" u"`tag1` `tag2` `tag3`" ) - self.send_and_test_stream_message('addtags', expected_subject, expected_message, + self.send_and_test_stream_message('addtags', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_addteam_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *AddTeam*\n" u"Added team: *team2*\n" u"Message: *test alert*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('addteam', expected_subject, expected_message, + self.send_and_test_stream_message('addteam', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_assignownership_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *AssignOwnership*\n" u"Assigned owner: *user2@ifountain.com*\n" u"Message: *test alert*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('assignownership', expected_subject, expected_message, + self.send_and_test_stream_message('assignownership', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_close_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *Close*\n" u"Message: *test alert*" ) - self.send_and_test_stream_message('close', expected_subject, expected_message, + self.send_and_test_stream_message('close', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_create_alert(self) -> None: - expected_subject = u"Webhook" + expected_topic = u"Webhook" expected_message = (u"**OpsGenie: [Alert for Webhook.](https://app.opsgenie.com/alert/V2#/show/ec03dad6-62c8-4c94-b38b-d88f398e900f)**\n" u"Type: *Create*\n" u"Message: *another alert*\n" u"`vip`" ) - self.send_and_test_stream_message('create', expected_subject, expected_message, + self.send_and_test_stream_message('create', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customaction_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *TestAction*\n" u"Message: *test alert*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('customaction', expected_subject, expected_message, + self.send_and_test_stream_message('customaction', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_delete_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *Delete*\n" u"Message: *test alert*" ) - self.send_and_test_stream_message('delete', expected_subject, expected_message, + self.send_and_test_stream_message('delete', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_escalate_alert(self) -> None: - expected_subject = u"Webhook_Test" + expected_topic = u"Webhook_Test" expected_message = (u"**OpsGenie: [Alert for Webhook_Test.](https://app.opsgenie.com/alert/V2#/show/7ba97e3a-d328-4b5e-8f9a-39e945a3869a)**\n" u"Type: *Escalate*\n" u"Escalation: *test_esc*" ) - self.send_and_test_stream_message('escalate', expected_subject, expected_message, + self.send_and_test_stream_message('escalate', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_removetags_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *RemoveTags*\n" u"Removed tags: *tag3*\n" u"Message: *test alert*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('removetags', expected_subject, expected_message, + self.send_and_test_stream_message('removetags', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_takeownership_alert(self) -> None: - expected_subject = u"Webhook" + expected_topic = u"Webhook" expected_message = (u"**OpsGenie: [Alert for Webhook.](https://app.opsgenie.com/alert/V2#/show/8a745a79-3ed3-4044-8427-98e067c0623c)**\n" u"Type: *TakeOwnership*\n" u"Message: *message test*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('takeownership', expected_subject, expected_message, + self.send_and_test_stream_message('takeownership', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_unacknowledge_alert(self) -> None: - expected_subject = u"Integration1" + expected_topic = u"Integration1" expected_message = (u"**OpsGenie: [Alert for Integration1.](https://app.opsgenie.com/alert/V2#/show/052652ac-5d1c-464a-812a-7dd18bbfba8c)**\n" u"Type: *UnAcknowledge*\n" u"Message: *test alert*\n" u"`tag1` `tag2`" ) - self.send_and_test_stream_message('unacknowledge', expected_subject, expected_message, + self.send_and_test_stream_message('unacknowledge', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/papertrail/tests.py b/zerver/webhooks/papertrail/tests.py index a2cfa083b1..f9019b1b6c 100644 --- a/zerver/webhooks/papertrail/tests.py +++ b/zerver/webhooks/papertrail/tests.py @@ -8,7 +8,7 @@ class PapertrailHookTests(WebhookTestCase): # Note: Include a test function per each distinct message condition your integration supports def test_short_message(self) -> None: - expected_subject = u"logs" + expected_topic = u"logs" expected_message = u'''**"Important stuff"** search found **2** matches - https://papertrailapp.com/searches/42 ``` May 18 20:30:02 abc cron OR server1: @@ -18,11 +18,11 @@ May 18 20:30:02 server1 cron OR server1: ```''' # use fixture named papertrail_logs - self.send_and_test_stream_message('short_post', expected_subject, expected_message, + self.send_and_test_stream_message('short_post', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_long_message(self) -> None: - expected_subject = u"logs" + expected_topic = u"logs" expected_message = u'''**"Important stuff"** search found **5** matches - https://papertrailapp.com/searches/42 ``` May 18 20:30:02 abc cron OR server1: @@ -36,7 +36,7 @@ May 18 20:30:02 abc cron OR server1: ``` [See more](https://papertrailapp.com/searches/42)''' # use fixture named papertrail_logs - self.send_and_test_stream_message('long_post', expected_subject, expected_message, + self.send_and_test_stream_message('long_post', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/pivotal/tests.py b/zerver/webhooks/pivotal/tests.py index 858c1c410b..e69a0c3668 100644 --- a/zerver/webhooks/pivotal/tests.py +++ b/zerver/webhooks/pivotal/tests.py @@ -7,66 +7,66 @@ class PivotalV3HookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/pivotal?stream={stream}&api_key={api_key}" def test_accepted(self) -> None: - expected_subject = 'My new Feature story' + expected_topic = 'My new Feature story' expected_message = 'Leo Franchi accepted "My new Feature story" \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)' - self.send_and_test_stream_message('accepted', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('accepted', expected_topic, expected_message, content_type="application/xml") def test_commented(self) -> None: - expected_subject = 'Comment added' + expected_topic = 'Comment added' expected_message = 'Leo Franchi added comment: "FIX THIS NOW" \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)' - self.send_and_test_stream_message('commented', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('commented', expected_topic, expected_message, content_type="application/xml") def test_created(self) -> None: - expected_subject = 'My new Feature story' + expected_topic = '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 \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)' - self.send_and_test_stream_message('created', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('created', expected_topic, expected_message, content_type="application/xml") def test_delivered(self) -> None: - expected_subject = 'Another new story' + expected_topic = 'Another new story' expected_message = 'Leo Franchi delivered "Another new story" \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)' - self.send_and_test_stream_message('delivered', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('delivered', expected_topic, expected_message, content_type="application/xml") def test_finished(self) -> None: - expected_subject = 'Another new story' + expected_topic = 'Another new story' expected_message = 'Leo Franchi finished "Another new story" \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)' - self.send_and_test_stream_message('finished', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('finished', expected_topic, expected_message, content_type="application/xml") def test_moved(self) -> None: - expected_subject = 'My new Feature story' + expected_topic = 'My new Feature story' expected_message = 'Leo Franchi edited "My new Feature story" \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)' - self.send_and_test_stream_message('moved', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('moved', expected_topic, expected_message, content_type="application/xml") def test_rejected(self) -> None: - expected_subject = 'Another new story' + expected_topic = 'Another new story' expected_message = 'Leo Franchi rejected "Another new story" with comments: \ "Not good enough, sorry" [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)' - self.send_and_test_stream_message('rejected', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('rejected', expected_topic, expected_message, content_type="application/xml") def test_started(self) -> None: - expected_subject = 'Another new story' + expected_topic = 'Another new story' expected_message = 'Leo Franchi started "Another new story" \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)' - self.send_and_test_stream_message('started', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('started', expected_topic, expected_message, content_type="application/xml") def test_created_estimate(self) -> None: - expected_subject = 'Another new story' + expected_topic = '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 \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48278289)' - self.send_and_test_stream_message('created_estimate', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('created_estimate', expected_topic, expected_message, content_type="application/xml") def test_type_changed(self) -> None: - expected_subject = 'My new Feature story' + expected_topic = 'My new Feature story' expected_message = 'Leo Franchi edited "My new Feature story" \ [(view)](https://www.pivotaltracker.com/s/projects/807213/stories/48276573)' - self.send_and_test_stream_message('type_changed', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('type_changed', expected_topic, expected_message, content_type="application/xml") def get_body(self, fixture_name: str) -> str: return self.webhook_fixture_data('pivotal', fixture_name, file_type='xml') @@ -76,73 +76,73 @@ class PivotalV5HookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/pivotal?stream={stream}&api_key={api_key}" def test_accepted(self) -> None: - expected_subject = '#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): * state changed from **unstarted** to **accepted**""" - self.send_and_test_stream_message('accepted', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('accepted', expected_topic, expected_message, content_type="application/xml") def test_commented(self) -> None: - expected_subject = '#63486316: Story of the Year' + expected_topic = '#63486316: Story of the Year' expected_message = """Leo Franchi added a comment to [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story of the Year](http://www.pivotaltracker.com/story/show/63486316): ~~~quote A comment on the story ~~~""" - self.send_and_test_stream_message('commented', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('commented', expected_topic, expected_message, content_type="application/xml") def test_created(self) -> None: - expected_subject = '#63495662: Story that I created' + expected_topic = '#63495662: Story that I created' expected_message = """Leo Franchi created bug: [Hard Code](https://www.pivotaltracker.com/s/projects/807213): [Story that I created](http://www.pivotaltracker.com/story/show/63495662) * State is **unscheduled** * Description is > What a description""" - self.send_and_test_stream_message('created', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('created', expected_topic, expected_message, content_type="application/xml") def test_delivered(self) -> None: - expected_subject = '#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): * state changed from **accepted** to **delivered**""" - self.send_and_test_stream_message('delivered', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('delivered', expected_topic, expected_message, content_type="application/xml") def test_finished(self) -> None: - expected_subject = '#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): * state changed from **delivered** to **accepted**""" - self.send_and_test_stream_message('finished', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('finished', expected_topic, expected_message, content_type="application/xml") def test_moved(self) -> None: - expected_subject = '#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**""" - self.send_and_test_stream_message('moved', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('moved', expected_topic, expected_message, content_type="application/xml") def test_rejected(self) -> None: - expected_subject = '#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): * Comment added: ~~~quote Try again next time ~~~ * state changed from **delivered** to **rejected**""" - self.send_and_test_stream_message('rejected', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('rejected', expected_topic, expected_message, content_type="application/xml") def test_started(self) -> None: - expected_subject = '#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): * state changed from **unstarted** to **started**""" - self.send_and_test_stream_message('started', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('started', expected_topic, expected_message, content_type="application/xml") def test_created_estimate(self) -> None: - expected_subject = '#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): * estimate is now **3 points**""" - self.send_and_test_stream_message('created_estimate', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('created_estimate', expected_topic, expected_message, content_type="application/xml") def test_type_changed(self) -> None: - expected_subject = '#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): * estimate changed from 3 to **0 points** * type changed from **feature** to **bug**""" - self.send_and_test_stream_message('type_changed', expected_subject, expected_message, content_type="application/xml") + self.send_and_test_stream_message('type_changed', expected_topic, expected_message, content_type="application/xml") def get_body(self, fixture_name: str) -> str: return self.webhook_fixture_data('pivotal', "v5_{}".format(fixture_name), file_type='json') diff --git a/zerver/webhooks/raygun/tests.py b/zerver/webhooks/raygun/tests.py index 9e5aebea44..75b465d4af 100644 --- a/zerver/webhooks/raygun/tests.py +++ b/zerver/webhooks/raygun/tests.py @@ -9,7 +9,7 @@ class RaygunHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'raygun' def test_status_changed_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"[Error](https://app.raygun.com/error-url) " \ u"status changed to: Ignored by Emma Cat\n" \ u"Timestamp: Wed Jan 28 01:49:36 1970\n" \ @@ -17,13 +17,13 @@ class RaygunHookTests(WebhookTestCase): u"[Best App](http://app.raygun.io/application-url)" self.send_and_test_stream_message('error_status_changed', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_comment_added_to_error_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"Anita Peacock left a comment on " \ u"[Error](https://app.raygun.com/error-url): " \ u"Ignoring these errors\n" \ @@ -33,13 +33,13 @@ class RaygunHookTests(WebhookTestCase): u"(http://app.raygun.io/application-url)" self.send_and_test_stream_message('comment_added_to_error', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_error_assigned_to_user_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"Amy Loondon assigned " \ u"[Error](https://app.raygun.com/error-url) " \ u"to Kyle Kenny\n" \ @@ -49,13 +49,13 @@ class RaygunHookTests(WebhookTestCase): u"(http://app.raygun.io/application-url)" self.send_and_test_stream_message('error_assigned_to_user', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_one_minute_followup_error_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"One minute " \ u"[follow-up error]" \ u"(http://app.raygun.io/error-url)\n" \ @@ -67,13 +67,13 @@ class RaygunHookTests(WebhookTestCase): u"(http://app.raygun.io/application-url)" self.send_and_test_stream_message('one_minute_followup_error', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_hourly_followup_error_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"Hourly " \ u"[follow-up error]" \ u"(http://app.raygun.io/error-url)\n" \ @@ -85,13 +85,13 @@ class RaygunHookTests(WebhookTestCase): u"(http://app.raygun.io/application-url)" self.send_and_test_stream_message('hourly_followup_error', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_new_error_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"**New [Error](http://app.raygun.io/error-url) " \ u"occurred!**\n" \ u"First occurred: Wed Jan 28 01:49:36 1970\n" \ @@ -106,13 +106,13 @@ class RaygunHookTests(WebhookTestCase): u"(http://app.raygun.io/application-url)" self.send_and_test_stream_message('new_error', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_reoccurred_error_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"[Error](http://app.raygun.io/error-url) " \ u"reoccurred.\n" \ u"First occurred: Wed Jan 28 01:49:36 1970\n" \ @@ -127,37 +127,37 @@ class RaygunHookTests(WebhookTestCase): u"(http://app.raygun.io/application-url)" self.send_and_test_stream_message('reoccurred_error', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_no_event_type_message(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"Unsupported event type: new_event_type" self.send_and_test_stream_message('no_event_type', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_unimplemented_notification_feature(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"Unsupported event_type type: UnimplementedFeature" self.send_and_test_stream_message('no_notification_eventType_type', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") def test_unimplemented_activity_feature(self) -> None: - expected_subject = u"test" + expected_topic = u"test" expected_message = u"Unsupported event_type type: UnimplementedFeature" self.send_and_test_stream_message('no_activity_eventType_type', - expected_subject, + expected_topic, expected_message, content_type= "application/x-www-form-urlencoded") diff --git a/zerver/webhooks/semaphore/tests.py b/zerver/webhooks/semaphore/tests.py index b727780520..f52eb00dfc 100644 --- a/zerver/webhooks/semaphore/tests.py +++ b/zerver/webhooks/semaphore/tests.py @@ -11,17 +11,17 @@ class SemaphoreHookTests(WebhookTestCase): # details about the build, deploy, server, author, and commit def test_semaphore_build(self) -> None: - expected_subject = u"knighthood/master" # repo/branch + expected_topic = u"knighthood/master" # repo/branch expected_message = u"""[build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314): passed !avatar(don@lamancha.com) [`a490b8d`](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf): Create user account for Rocinante :horse:.""" - self.send_and_test_stream_message('build', expected_subject, expected_message, + self.send_and_test_stream_message('build', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_semaphore_deploy(self) -> None: - expected_subject = u"knighthood/master" + expected_topic = u"knighthood/master" expected_message = u"""[deploy 17](https://semaphoreci.com/donquixote/knighthood/servers/lamancha-271/deploys/17) of [build 314](https://semaphoreci.com/donquixote/knighthood/branches/master/builds/314) on server lamancha-271: passed !avatar(don@lamancha.com) [`a490b8d`](https://github.com/donquixote/knighthood/commit/a490b8d508ebbdab1d77a5c2aefa35ceb2d62daf): Create user account for Rocinante :horse:.""" - self.send_and_test_stream_message('deploy', expected_subject, expected_message, + self.send_and_test_stream_message('deploy', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/sentry/tests.py b/zerver/webhooks/sentry/tests.py index b32020dd8a..fd9a5092f7 100644 --- a/zerver/webhooks/sentry/tests.py +++ b/zerver/webhooks/sentry/tests.py @@ -7,10 +7,10 @@ class SentryHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'sentry' def test_error_issue_message(self) -> None: - expected_subject = u"zulip" + expected_topic = u"zulip" expected_message = u"New ERROR [issue](https://sentry.io/zulip/zulip/issues/156699934/): This is an example python exception." self.send_and_test_stream_message( 'exception_message', - expected_subject, + expected_topic, expected_message ) diff --git a/zerver/webhooks/slack/tests.py b/zerver/webhooks/slack/tests.py index e581e70821..91f70fe450 100644 --- a/zerver/webhooks/slack/tests.py +++ b/zerver/webhooks/slack/tests.py @@ -8,18 +8,18 @@ class SlackWebhookTests(WebhookTestCase): def test_slack_channel_to_topic(self) -> None: - expected_subject = u"channel: general" + expected_topic = u"channel: general" expected_message = u"**slack_user**: `test\n`" - self.send_and_test_stream_message('message_info', expected_subject, expected_message, + self.send_and_test_stream_message('message_info', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_slack_channel_to_stream(self) -> None: self.STREAM_NAME = 'general' self.url = "{}{}".format(self.url, "&channels_map_to_topics=0") - expected_subject = u"Message from Slack" + expected_topic = u"Message from Slack" expected_message = u"**slack_user**: `test\n`" - self.send_and_test_stream_message('message_info', expected_subject, expected_message, + self.send_and_test_stream_message('message_info', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_missing_data_user_name(self) -> None: diff --git a/zerver/webhooks/splunk/tests.py b/zerver/webhooks/splunk/tests.py index 0a3fd3291d..181deb5141 100644 --- a/zerver/webhooks/splunk/tests.py +++ b/zerver/webhooks/splunk/tests.py @@ -12,34 +12,34 @@ class SplunkHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=u"New Search Alert") # define the expected message contents - expected_subject = u"New Search Alert" + expected_topic = u"New Search Alert" expected_message = u"Splunk alert from saved search\n[sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now)\nhost: myserver\nsource: /var/log/auth.log\n\nraw: Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root" # using fixture named splunk_search_one_result, execute this test self.send_and_test_stream_message('search_one_result', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_splunk_short_search_name(self) -> None: # don't provide a topic so the search name is used instead - expected_subject = u"This search's name isn't that long" + expected_topic = u"This search's name isn't that long" expected_message = u"Splunk alert from saved search\n[This search's name isn't that long](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now)\nhost: myserver\nsource: /var/log/auth.log\n\nraw: Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root" self.send_and_test_stream_message('short_search_name', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_splunk_long_search_name(self) -> None: # don't provide a topic so the search name is used instead - expected_subject = u"this-search's-got-47-words-37-sentences-58-words-we-wanna..." + expected_topic = u"this-search's-got-47-words-37-sentences-58-words-we-wanna..." expected_message = u"Splunk alert from saved search\n[this-search's-got-47-words-37-sentences-58-words-we-wanna-know-details-of-the-search-time-of-the-search-and-any-other-kind-of-thing-you-gotta-say-pertaining-to-and-about-the-search-I-want-to-know-authenticated-user's-name-and-any-other-kind-of-thing-you-gotta-say](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now)\nhost: myserver\nsource: /var/log/auth.log\n\nraw: Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root" self.send_and_test_stream_message('long_search_name', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -47,11 +47,11 @@ class SplunkHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=u"New Search Alert") - expected_subject = u"New Search Alert" + expected_topic = u"New Search Alert" expected_message = u"Splunk alert from saved search\n[sudo](Missing results_link)\nhost: myserver\nsource: /var/log/auth.log\n\nraw: Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root" self.send_and_test_stream_message('missing_results_link', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -59,11 +59,11 @@ class SplunkHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=u"New Search Alert") - expected_subject = u"New Search Alert" + expected_topic = u"New Search Alert" expected_message = u"Splunk alert from saved search\n[Missing search_name](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now)\nhost: myserver\nsource: /var/log/auth.log\n\nraw: Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root" self.send_and_test_stream_message('missing_search_name', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -71,11 +71,11 @@ class SplunkHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=u"New Search Alert") - expected_subject = u"New Search Alert" + expected_topic = u"New Search Alert" expected_message = u"Splunk alert from saved search\n[sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now)\nhost: Missing host\nsource: /var/log/auth.log\n\nraw: Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root" self.send_and_test_stream_message('missing_host', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -83,11 +83,11 @@ class SplunkHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=u"New Search Alert") - expected_subject = u"New Search Alert" + expected_topic = u"New Search Alert" expected_message = u"Splunk alert from saved search\n[sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now)\nhost: myserver\nsource: Missing source\n\nraw: Jan 4 11:14:32 myserver sudo: pam_unix(sudo:session): session closed for user root" self.send_and_test_stream_message('missing_source', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") @@ -95,11 +95,11 @@ class SplunkHookTests(WebhookTestCase): self.url = self.build_webhook_url(topic=u"New Search Alert") - expected_subject = u"New Search Alert" + expected_topic = u"New Search Alert" expected_message = u"Splunk alert from saved search\n[sudo](http://example.com:8000/app/search/search?q=%7Cloadjob%20rt_scheduler__admin__search__sudo_at_1483557185_2.2%20%7C%20head%201%20%7C%20tail%201&earliest=0&latest=now)\nhost: myserver\nsource: /var/log/auth.log\n\nraw: Missing _raw" self.send_and_test_stream_message('missing_raw', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/statuspage/tests.py b/zerver/webhooks/statuspage/tests.py index e0783aae2f..b49147ca35 100644 --- a/zerver/webhooks/statuspage/tests.py +++ b/zerver/webhooks/statuspage/tests.py @@ -6,30 +6,30 @@ class StatuspageHookTests(WebhookTestCase): URL_TEMPLATE = u"/api/v1/external/statuspage?api_key={api_key}&stream={stream}" def test_statuspage_incident(self) -> None: - expected_subject = u"Database query delays: All Systems Operational" + expected_topic = u"Database query delays: All Systems Operational" expected_message = u"**Database query delays** \n * State: **identified** \n \ * Description: We just encountered that database queries are timing out resulting in inconvenience \ to our end users...we'll do quick fix latest by tommorow !!!" self.send_and_test_stream_message('incident_created', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_statuspage_incident_update(self) -> None: - expected_subject = u"Database query delays: All Systems Operational" + expected_topic = u"Database query delays: All Systems Operational" expected_message = u"**Database query delays** \n * State: **resolved** \n \ * Description: The database issue is resolved." self.send_and_test_stream_message('incident_update', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_statuspage_component(self) -> None: - expected_subject = u"Database component: Service Under Maintenance" + expected_topic = u"Database component: Service Under Maintenance" expected_message = u"**Database component** has changed status \ from **operational** to **under_maintenance**" self.send_and_test_stream_message('component_status_update', - expected_subject, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") diff --git a/zerver/webhooks/stripe/tests.py b/zerver/webhooks/stripe/tests.py index d7b5c145ed..0108d42c60 100644 --- a/zerver/webhooks/stripe/tests.py +++ b/zerver/webhooks/stripe/tests.py @@ -10,134 +10,134 @@ class StripeHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'stripe' def test_charge_dispute_closed(self) -> None: - expected_subject = u"Charge ch_00000000000000" + expected_topic = u"Charge ch_00000000000000" expected_message = u"A charge dispute for **10.01aud** has been closed as **won**.\nThe charge in dispute was **[ch_00000000000000](https://dashboard.stripe.com/payments/ch_00000000000000)**." # use fixture named stripe_charge_dispute_closed - self.send_and_test_stream_message('charge_dispute_closed', expected_subject, expected_message, + self.send_and_test_stream_message('charge_dispute_closed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_charge_dispute_created(self) -> None: - expected_subject = u"Charge ch_00000000000000" + expected_topic = u"Charge ch_00000000000000" expected_message = u"A charge dispute for **1000jpy** has been created.\nThe charge in dispute is **[ch_00000000000000](https://dashboard.stripe.com/payments/ch_00000000000000)**." # use fixture named stripe_charge_dispute_created - self.send_and_test_stream_message('charge_dispute_created', expected_subject, expected_message, + self.send_and_test_stream_message('charge_dispute_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_charge_failed(self) -> None: - expected_subject = u"Charge ch_00000000000000" + expected_topic = u"Charge ch_00000000000000" expected_message = u"A charge with id **[ch_00000000000000](https://dashboard.stripe.com/payments/ch_00000000000000)** for **1.00aud** has failed." # use fixture named stripe_charge_failed - self.send_and_test_stream_message('charge_failed', expected_subject, expected_message, + self.send_and_test_stream_message('charge_failed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_charge_succeeded(self) -> None: - expected_subject = u"Charge ch_00000000000000" + expected_topic = u"Charge ch_00000000000000" expected_message = u"A charge with id **[ch_00000000000000](https://dashboard.stripe.com/payments/ch_00000000000000)** for **1.00aud** has succeeded." # use fixture named stripe_charge_succeeded - self.send_and_test_stream_message('charge_succeeded', expected_subject, expected_message, + self.send_and_test_stream_message('charge_succeeded', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_created_email(self) -> None: - expected_subject = u"Customer cus_00000000000000" + expected_topic = u"Customer cus_00000000000000" expected_message = u"A new customer with id **[cus_00000000000000](https://dashboard.stripe.com/customers/cus_00000000000000)** and email **example@abc.com** has been created." # use fixture named stripe_customer_created_email - self.send_and_test_stream_message('customer_created_email', expected_subject, expected_message, + self.send_and_test_stream_message('customer_created_email', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_created(self) -> None: - expected_subject = u"Customer cus_00000000000000" + expected_topic = u"Customer cus_00000000000000" expected_message = u"A new customer with id **[cus_00000000000000](https://dashboard.stripe.com/customers/cus_00000000000000)** has been created." # use fixture named stripe_customer_created - self.send_and_test_stream_message('customer_created', expected_subject, expected_message, + self.send_and_test_stream_message('customer_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_deleted(self) -> None: - expected_subject = u"Customer cus_00000000000000" + expected_topic = u"Customer cus_00000000000000" expected_message = u"A customer with id **[cus_00000000000000](https://dashboard.stripe.com/customers/cus_00000000000000)** has been deleted." # use fixture named stripe_customer_deleted - self.send_and_test_stream_message('customer_deleted', expected_subject, expected_message, + self.send_and_test_stream_message('customer_deleted', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_subscription_created(self) -> None: - expected_subject = u"Customer sub_00000000000000" + expected_topic = u"Customer sub_00000000000000" expected_message = u"A new customer subscription for **20.00aud** every **month** has been created.\nThe subscription has id **[sub_00000000000000](https://dashboard.stripe.com/subscriptions/sub_00000000000000)**." # use fixture named stripe_customer_subscription_created - self.send_and_test_stream_message('customer_subscription_created', expected_subject, expected_message, + self.send_and_test_stream_message('customer_subscription_created', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_subscription_deleted(self) -> None: - expected_subject = u"Customer sub_00000000000000" + expected_topic = u"Customer sub_00000000000000" expected_message = u"The customer subscription with id **[sub_00000000000000](https://dashboard.stripe.com/subscriptions/sub_00000000000000)** was deleted." # use fixture named stripe_customer_subscription_deleted - self.send_and_test_stream_message('customer_subscription_deleted', expected_subject, expected_message, + self.send_and_test_stream_message('customer_subscription_deleted', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_customer_subscription_trial_will_end(self) -> None: - expected_subject = u"Customer sub_00000000000000" + expected_topic = u"Customer sub_00000000000000" expected_message = u"The customer subscription trial with id **[sub_00000000000000](https://dashboard.stripe.com/subscriptions/sub_00000000000000)** will end in 3 days." # 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): # use fixture named stripe_customer_subscription_trial_will_end self.send_and_test_stream_message('customer_subscription_trial_will_end', - expected_subject, expected_message, + expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_invoice_payment_failed(self) -> None: - expected_subject = u"Invoice in_00000000000000" + expected_topic = u"Invoice in_00000000000000" expected_message = u"An invoice payment on invoice with id **[in_00000000000000](https://dashboard.stripe.com/invoices/in_00000000000000)** and with **0.00aud** due has failed." # use fixture named stripe_invoice_payment_failed - self.send_and_test_stream_message('invoice_payment_failed', expected_subject, expected_message, + self.send_and_test_stream_message('invoice_payment_failed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_order_payment_failed(self) -> None: - expected_subject = u"Order or_00000000000000" + expected_topic = u"Order or_00000000000000" expected_message = u"An order payment on order with id **[or_00000000000000](https://dashboard.stripe.com/orders/or_00000000000000)** for **15.00aud** has failed." # use fixture named stripe_order_payment_failed - self.send_and_test_stream_message('order_payment_failed', expected_subject, expected_message, + self.send_and_test_stream_message('order_payment_failed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_order_payment_succeeded(self) -> None: - expected_subject = u"Order or_00000000000000" + expected_topic = u"Order or_00000000000000" expected_message = u"An order payment on order with id **[or_00000000000000](https://dashboard.stripe.com/orders/or_00000000000000)** for **15.00aud** has succeeded." # use fixture named stripe_order_payment_succeeded - self.send_and_test_stream_message('order_payment_succeeded', expected_subject, expected_message, + self.send_and_test_stream_message('order_payment_succeeded', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_order_updated(self) -> None: - expected_subject = u"Order or_00000000000000" + expected_topic = u"Order or_00000000000000" expected_message = u"The order with id **[or_00000000000000](https://dashboard.stripe.com/orders/or_00000000000000)** for **15.00aud** has been updated." # use fixture named stripe_order_updated - self.send_and_test_stream_message('order_updated', expected_subject, expected_message, + self.send_and_test_stream_message('order_updated', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_transfer_failed(self) -> None: - expected_subject = u"Transfer tr_00000000000000" + expected_topic = u"Transfer tr_00000000000000" expected_message = u"The transfer with description **Transfer to test@example.com** and id **[tr_00000000000000](https://dashboard.stripe.com/transfers/tr_00000000000000)** for amount **11.00aud** has failed." # use fixture named stripe_transfer_failed - self.send_and_test_stream_message('transfer_failed', expected_subject, expected_message, + self.send_and_test_stream_message('transfer_failed', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def test_transfer_paid(self) -> None: - expected_subject = u"Transfer tr_00000000000000" + expected_topic = u"Transfer tr_00000000000000" expected_message = u"The transfer with description **Transfer to test@example.com** and id **[tr_00000000000000](https://dashboard.stripe.com/transfers/tr_00000000000000)** for amount **11.00aud** has been paid." # use fixture named stripe_transfer_paid - self.send_and_test_stream_message('transfer_paid', expected_subject, expected_message, + self.send_and_test_stream_message('transfer_paid', expected_topic, expected_message, content_type="application/x-www-form-urlencoded") def get_body(self, fixture_name: str) -> str: diff --git a/zerver/webhooks/teamcity/tests.py b/zerver/webhooks/teamcity/tests.py index 4d4e9a3d34..b28884ebc6 100644 --- a/zerver/webhooks/teamcity/tests.py +++ b/zerver/webhooks/teamcity/tests.py @@ -18,8 +18,8 @@ class TeamcityHookTests(WebhookTestCase): def test_teamcity_success_branch(self) -> None: expected_message = u"Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up:\nDetails: [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv), [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)" - expected_subject = u"Project :: Compile (MyBranch)" - self.send_and_test_stream_message('success_branch', expected_subject, expected_message) + expected_topic = u"Project :: Compile (MyBranch)" + self.send_and_test_stream_message('success_branch', expected_topic, expected_message) def test_teamcity_broken(self) -> None: expected_message = u"Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down:\nDetails: [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv), [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)" diff --git a/zerver/webhooks/transifex/tests.py b/zerver/webhooks/transifex/tests.py index f01466a34c..461f18751e 100644 --- a/zerver/webhooks/transifex/tests.py +++ b/zerver/webhooks/transifex/tests.py @@ -17,7 +17,7 @@ class TransifexHookTests(WebhookTestCase): def test_transifex_reviewed_message(self) -> None: self.REVIEWED = True - expected_subject = "{} in {}".format(self.PROJECT, self.LANGUAGE) + expected_topic = "{} in {}".format(self.PROJECT, self.LANGUAGE) expected_message = "Resource {} fully reviewed.".format(self.RESOURCE) self.url = self.build_webhook_url( self.URL_REVIEWED_METHOD_TEMPLATE, @@ -25,11 +25,11 @@ class TransifexHookTests(WebhookTestCase): language=self.LANGUAGE, resource=self.RESOURCE, ) - self.send_and_test_stream_message("", expected_subject, expected_message) + self.send_and_test_stream_message("", expected_topic, expected_message) def test_transifex_translated_message(self) -> None: self.REVIEWED = False - expected_subject = "{} in {}".format(self.PROJECT, self.LANGUAGE) + expected_topic = "{} in {}".format(self.PROJECT, self.LANGUAGE) expected_message = "Resource {} fully translated.".format(self.RESOURCE) self.url = self.build_webhook_url( self.URL_TRANSLATED_METHOD_TEMPLATE, @@ -37,7 +37,7 @@ class TransifexHookTests(WebhookTestCase): language=self.LANGUAGE, resource=self.RESOURCE, ) - self.send_and_test_stream_message("", expected_subject, expected_message) + self.send_and_test_stream_message("", expected_topic, expected_message) def get_body(self, fixture_name: str) -> Dict[str, Any]: return {} diff --git a/zerver/webhooks/updown/tests.py b/zerver/webhooks/updown/tests.py index 6097d48a2a..7aee6f59ce 100644 --- a/zerver/webhooks/updown/tests.py +++ b/zerver/webhooks/updown/tests.py @@ -7,32 +7,32 @@ class UpdownHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'updown' def test_updown_check_down_event(self) -> None: - expected_subject = u"https://updown.io" + expected_topic = u"https://updown.io" expected_message = u"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_subject, expected_message) + self.send_and_test_stream_message('check_down_one_event', expected_topic, expected_message) def test_updown_check_up_again_event(self) -> None: - expected_subject = u"https://updown.io" + expected_topic = u"https://updown.io" expected_message = u"Service is `up` again after 4 minutes 25 seconds." - self.send_and_test_stream_message('check_up_again_one_event', expected_subject, expected_message) + self.send_and_test_stream_message('check_up_again_one_event', expected_topic, expected_message) def test_updown_check_up_event(self) -> None: - expected_subject = u"https://updown.io" + expected_topic = u"https://updown.io" expected_message = u"Service is `up`." - self.send_and_test_stream_message('check_up_first_time', expected_subject, expected_message) + self.send_and_test_stream_message('check_up_first_time', expected_topic, expected_message) def test_updown_check_up_multiple_events(self) -> None: - first_message_expected_subject = u"https://updown.io" + first_message_expected_topic = u"https://updown.io" first_message_expected_message = u"Service is `up` again after 1 second." - second_message_expected_subject = u"https://updown.io" + second_message_expected_topic = u"https://updown.io" second_message_expected_message = u"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') last_message = self.get_last_message() - self.do_test_topic(last_message, first_message_expected_subject) + self.do_test_topic(last_message, first_message_expected_topic) self.do_test_message(last_message, first_message_expected_message) second_to_last_message = self.get_second_to_last_message() - self.do_test_topic(second_to_last_message, second_message_expected_subject) + self.do_test_topic(second_to_last_message, second_message_expected_topic) self.do_test_message(second_to_last_message, second_message_expected_message) diff --git a/zerver/webhooks/zabbix/tests.py b/zerver/webhooks/zabbix/tests.py index 64b3e3e588..c00dc81542 100644 --- a/zerver/webhooks/zabbix/tests.py +++ b/zerver/webhooks/zabbix/tests.py @@ -10,9 +10,9 @@ class ZabbixHookTests(WebhookTestCase): """ Tests if zabbix alert is handled correctly """ - expected_subject = u"www.example.com" + expected_topic = u"www.example.com" expected_message = u"PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528).\nZabbix agent on www.example.com is unreachable for 5 minutes\nAgent ping is Up (1)" - self.send_and_test_stream_message('zabbix_alert', expected_subject, expected_message) + self.send_and_test_stream_message('zabbix_alert', expected_topic, expected_message) def get_body(self, fixture_name: str) -> str: return self.webhook_fixture_data("zabbix", fixture_name, file_type="json") diff --git a/zerver/webhooks/zapier/tests.py b/zerver/webhooks/zapier/tests.py index 106f3ab578..716d71a791 100644 --- a/zerver/webhooks/zapier/tests.py +++ b/zerver/webhooks/zapier/tests.py @@ -7,16 +7,16 @@ class ZapierHookTests(WebhookTestCase): FIXTURE_DIR_NAME = 'zapier' def test_zapier_when_subject_and_body_are_correct(self) -> None: - expected_subject = u"New email from zulip@zulip.com" + expected_topic = u"New email from zulip@zulip.com" expected_message = u"Your email content is: \nMy Email content." - self.send_and_test_stream_message('correct_subject_and_body', expected_subject, expected_message) + self.send_and_test_stream_message('correct_subject_and_body', expected_topic, expected_message) def test_zapier_when_topic_and_body_are_correct(self) -> None: - expected_subject = u"New email from zulip@zulip.com" + expected_topic = u"New email from zulip@zulip.com" expected_message = u"Your email content is: \nMy Email content." - self.send_and_test_stream_message('correct_topic_and_body', expected_subject, expected_message) + self.send_and_test_stream_message('correct_topic_and_body', expected_topic, expected_message) def test_zapier_weather_update(self) -> None: - expected_subject = u"Here is your weather update for the day:" + expected_topic = u"Here is your weather update for the day:" expected_message = u"Foggy in the morning.\nMaximum temperature to be 24.\nMinimum temperature to be 12" - self.send_and_test_stream_message('weather_update', expected_subject, expected_message) + self.send_and_test_stream_message('weather_update', expected_topic, expected_message) diff --git a/zerver/webhooks/zendesk/tests.py b/zerver/webhooks/zendesk/tests.py index eb02245b08..c81f31ba62 100644 --- a/zerver/webhooks/zendesk/tests.py +++ b/zerver/webhooks/zendesk/tests.py @@ -24,8 +24,8 @@ class ZenDeskHookTests(WebhookTestCase): 'stream': self.STREAM_NAME, } - def do_test(self, expected_subject: Optional[str]=None, expected_message: Optional[str]=None) -> None: - self.api_stream_message(self.TEST_USER_EMAIL, "", expected_subject, expected_message, + def do_test(self, expected_topic: Optional[str]=None, expected_message: Optional[str]=None) -> None: + self.api_stream_message(self.TEST_USER_EMAIL, "", expected_topic, expected_message, content_type=None) self.TICKET_TITLE = self.DEFAULT_TICKET_TITLE self.TICKET_ID = self.DEFAULT_TICKET_ID @@ -34,12 +34,12 @@ class ZenDeskHookTests(WebhookTestCase): def test_subject(self) -> None: self.TICKET_ID = 4 self.TICKET_TITLE = "Test ticket" - self.do_test(expected_subject='#4: Test ticket') + self.do_test(expected_topic='#4: Test ticket') def test_long_subject(self) -> None: self.TICKET_ID = 4 self.TICKET_TITLE = "Test ticket" + '!' * 80 - self.do_test(expected_subject='#4: Test ticket' + '!' * 42 + '...') + self.do_test(expected_topic='#4: Test ticket' + '!' * 42 + '...') def test_content(self) -> None: self.MESSAGE = 'New comment:\n> It is better\n* here'