Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

webhook tests: Shorten topic constants.

Steve Howell00001a396b9c
diff --git a/zerver/webhooks/basecamp/tests.py b/zerver/webhooks/basecamp/tests.py
index c86285cbeb0..4217a5784a2 100644
--- a/zerver/webhooks/basecamp/tests.py
+++ b/zerver/webhooks/basecamp/tests.py
@@ -1,11 +1,11 @@
from zerver.lib.test_classes import WebhookTestCase
+TOPIC = "Zulip HQ"
class BasecampHookTests(WebhookTestCase):
STREAM_NAME = 'basecamp'
URL_TEMPLATE = "/api/v1/external/basecamp?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = 'basecamp'
- EXPECTED_TOPIC = "Zulip HQ"
def test_basecamp_makes_doc_active(self) -> None:
expected_message = "Tomasz activated the document [New doc](https://3.basecamp.com/3688623/buckets/2957043/documents/432522214)."
@@ -136,4 +136,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_TOPIC, expected_message)
+ self.send_and_test_stream_message(fixture_name, TOPIC, expected_message)
diff --git a/zerver/webhooks/bitbucket/tests.py b/zerver/webhooks/bitbucket/tests.py
index 61fe6cf6aca..0d7c9a50f8c 100644
--- a/zerver/webhooks/bitbucket/tests.py
+++ b/zerver/webhooks/bitbucket/tests.py
@@ -3,20 +3,20 @@ from unittest.mock import MagicMock, patch
from zerver.lib.test_classes import WebhookTestCase
+TOPIC = "Repository name"
+TOPIC_BRANCH_EVENTS = "Repository name / master"
class BitbucketHookTests(WebhookTestCase):
STREAM_NAME = 'bitbucket'
URL_TEMPLATE = "/api/v1/external/bitbucket?stream={stream}"
FIXTURE_DIR_NAME = 'bitbucket'
- EXPECTED_TOPIC = "Repository name"
- EXPECTED_TOPIC_BRANCH_EVENTS = "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 = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))'
expected_message = f"kolaszek pushed 1 commit to branch master.\n\n{commit_info}"
- self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS,
+ self.api_stream_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS,
expected_message)
def test_bitbucket_on_push_event_without_user_info(self) -> None:
@@ -24,7 +24,7 @@ class BitbucketHookTests(WebhookTestCase):
self.url = self.build_webhook_url(payload=self.get_body(fixture_name))
commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))'
expected_message = f"Someone pushed 1 commit to branch master. Commits by eeshangarg (1).\n\n{commit_info}"
- self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS,
+ self.api_stream_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS,
expected_message)
def test_bitbucket_on_push_event_filtered_by_branches(self) -> None:
@@ -33,7 +33,7 @@ class BitbucketHookTests(WebhookTestCase):
branches='master,development')
commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))'
expected_message = f"kolaszek pushed 1 commit to branch master.\n\n{commit_info}"
- self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS,
+ self.api_stream_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS,
expected_message)
def test_bitbucket_on_push_commits_above_limit_event(self) -> None:
@@ -41,7 +41,7 @@ class BitbucketHookTests(WebhookTestCase):
self.url = self.build_webhook_url(payload=self.get_body(fixture_name))
commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n'
expected_message = f"kolaszek pushed 50 commits to branch master.\n\n{commit_info * 20}[and 30 more commit(s)]"
- self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS,
+ self.api_stream_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS,
expected_message)
def test_bitbucket_on_push_commits_above_limit_event_filtered_by_branches(self) -> None:
@@ -50,21 +50,21 @@ class BitbucketHookTests(WebhookTestCase):
branches='master,development')
commit_info = '* c ([25f93d2](https://bitbucket.org/kolaszek/repository-name/commits/25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12))\n'
expected_message = f"kolaszek pushed 50 commits to branch master.\n\n{commit_info * 20}[and 30 more commit(s)]"
- self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC_BRANCH_EVENTS,
+ self.api_stream_message(self.test_user, fixture_name, 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 = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name)."
- self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC,
+ self.api_stream_message(self.test_user, fixture_name, TOPIC,
expected_message)
def test_bitbucket_on_force_push_event_without_user_info(self) -> None:
fixture_name = 'force_push_without_user_info'
self.url = self.build_webhook_url(payload=self.get_body(fixture_name))
expected_message = "Someone [force pushed](https://bitbucket.org/kolaszek/repository-name/)."
- self.api_stream_message(self.test_user, fixture_name, self.EXPECTED_TOPIC,
+ self.api_stream_message(self.test_user, fixture_name, 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 0f2ab83d240..d04f5164f0b 100644
--- a/zerver/webhooks/bitbucket2/tests.py
+++ b/zerver/webhooks/bitbucket2/tests.py
@@ -2,89 +2,89 @@ from unittest.mock import MagicMock, patch
from zerver.lib.test_classes import WebhookTestCase
+TOPIC = "Repository name"
+TOPIC_PR_EVENTS = "Repository name / PR #1 new commit"
+TOPIC_ISSUE_EVENTS = "Repository name / Issue #1 Bug"
+TOPIC_BRANCH_EVENTS = "Repository name / master"
class Bitbucket2HookTests(WebhookTestCase):
STREAM_NAME = 'bitbucket2'
URL_TEMPLATE = "/api/v1/external/bitbucket2?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = 'bitbucket2'
- EXPECTED_TOPIC = "Repository name"
- EXPECTED_TOPIC_PR_EVENTS = "Repository name / PR #1 new commit"
- EXPECTED_TOPIC_ISSUE_EVENTS = "Repository name / Issue #1 Bug"
- EXPECTED_TOPIC_BRANCH_EVENTS = "Repository name / master"
def test_bitbucket2_on_push_event(self) -> None:
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))'
expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}"
- self.send_and_test_stream_message('push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push', TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_multiple_committers(self) -> None:
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{commit_info*2}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
- self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push_multiple_committers', TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None:
commit_info = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{commit_info*9}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
- self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push_multiple_committers_with_others', 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 = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by zbenjamin (2) and kolaszek (1).\n\n{commit_info*2}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
- self.send_and_test_stream_message('push_multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push_multiple_committers', 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 = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n'
expected_message = f"""kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by james (3), Brendon (2), Tomasz (2) and others (3).\n\n{commit_info*9}* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
- self.send_and_test_stream_message('push_multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push_multiple_committers_with_others', 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 = '* first commit ([84b96ad](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))'
expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}"
- self.send_and_test_stream_message('push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push', 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 = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{(commit_info * 5)}[and more commit(s)]"
- self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push_commits_above_limit', 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')
commit_info = '* a ([6f161a7](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n'
expected_message = f"kolaszek [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master. Commits by Tomasz (5).\n\n{(commit_info * 5)}[and more commit(s)]"
- self.send_and_test_stream_message('push_commits_above_limit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push_commits_above_limit', TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_force_push_event(self) -> None:
expected_message = "kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12."
- self.send_and_test_stream_message('force_push', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('force_push', 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 = "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_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('force_push', TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_remove_branch_event(self) -> None:
expected_message = "kolaszek deleted branch master."
- self.send_and_test_stream_message('remove_branch', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('remove_branch', TOPIC_BRANCH_EVENTS, expected_message)
def test_bitbucket2_on_fork_event(self) -> None:
expected_message = "User Tomasz(login: kolaszek) forked the repository into [kolaszek/repository-name2](https://bitbucket.org/kolaszek/repository-name2)."
- self.send_and_test_stream_message('fork', self.EXPECTED_TOPIC, expected_message)
+ self.send_and_test_stream_message('fork', TOPIC, expected_message)
def test_bitbucket2_on_commit_comment_created_event(self) -> None:
expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74#comment-3354963) on [32c4ea1](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74):\n~~~ quote\nNice fix!\n~~~"
- self.send_and_test_stream_message('commit_comment_created', self.EXPECTED_TOPIC, expected_message)
+ self.send_and_test_stream_message('commit_comment_created', TOPIC, expected_message)
def test_bitbucket2_on_commit_status_changed_event(self) -> None:
expected_message = "[System mybuildtool](https://my-build-tool.com/builds/MY-PROJECT/BUILD-777) changed status of [9fec847](https://bitbucket.org/kolaszek/repository-name/commits/9fec847784abb10b2fa567ee63b85bd238955d0e) to SUCCESSFUL."
- self.send_and_test_stream_message('commit_status_changed', self.EXPECTED_TOPIC, expected_message)
+ self.send_and_test_stream_message('commit_status_changed', TOPIC, expected_message)
def test_bitbucket2_on_issue_created_event(self) -> None:
expected_message = "kolaszek created [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to kolaszek):\n\n~~~ quote\nSuch a bug\n~~~"
- self.send_and_test_stream_message('issue_created', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message)
+ self.send_and_test_stream_message('issue_created', 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")
@@ -94,11 +94,11 @@ class Bitbucket2HookTests(WebhookTestCase):
def test_bitbucket2_on_issue_updated_event(self) -> None:
expected_message = "kolaszek updated [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
- self.send_and_test_stream_message('issue_updated', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message)
+ self.send_and_test_stream_message('issue_updated', TOPIC_ISSUE_EVENTS, expected_message)
def test_bitbucket2_on_issue_commented_event(self) -> None:
expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [Issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
- self.send_and_test_stream_message('issue_commented', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message)
+ self.send_and_test_stream_message('issue_commented', 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")
@@ -111,7 +111,7 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:created',
}
- self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_created_or_updated', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_created_without_reviewer_username_event(self) -> None:
expected_message = "kolaszek created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek) from `new-branch` to `master`:\n\n~~~ quote\ndescription\n~~~"
@@ -119,7 +119,7 @@ class Bitbucket2HookTests(WebhookTestCase):
"HTTP_X_EVENT_KEY": 'pullrequest:created',
}
self.send_and_test_stream_message('pull_request_created_or_updated_without_username',
- self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ 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")
@@ -135,14 +135,14 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:updated',
}
- self.send_and_test_stream_message('pull_request_created_or_updated', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_created_or_updated', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_approved_event(self) -> None:
expected_message = "kolaszek approved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:approved',
}
- self.send_and_test_stream_message('pull_request_approved_or_unapproved', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_approved_or_unapproved', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_approved_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
@@ -158,28 +158,28 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:unapproved',
}
- self.send_and_test_stream_message('pull_request_approved_or_unapproved', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_approved_or_unapproved', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_declined_event(self) -> None:
expected_message = "kolaszek rejected [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:rejected',
}
- self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_fulfilled_event(self) -> None:
expected_message = "kolaszek merged [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:fulfilled',
}
- self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_fulfilled_or_rejected', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_comment_created_event(self) -> None:
expected_message = "kolaszek [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~"
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_created',
}
- self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_comment_action', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_comment_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
@@ -195,7 +195,7 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_updated',
}
- self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_comment_action', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_pull_request_comment_updated_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
@@ -211,7 +211,7 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:comment_deleted',
}
- self.send_and_test_stream_message('pull_request_comment_action', self.EXPECTED_TOPIC_PR_EVENTS, expected_message, **kwargs)
+ self.send_and_test_stream_message('pull_request_comment_action', TOPIC_PR_EVENTS, expected_message, **kwargs)
def test_bitbucket2_on_repo_updated_event(self) -> None:
expected_message = "eeshangarg changed the website of the **new-name** repo to **http://zulipchat.com**.\neeshangarg changed the name of the **new-name** repo from **test-repo** to **new-name**.\neeshangarg changed the language of the **new-name** repo to **python**.\neeshangarg changed the full name of the **new-name** repo from **webhooktest/test-repo** to **webhooktest/new-name**.\neeshangarg changed the description of the **new-name** repo to **Random description.**"
@@ -225,14 +225,14 @@ class Bitbucket2HookTests(WebhookTestCase):
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push',
}
- self.send_and_test_stream_message('push_one_tag', self.EXPECTED_TOPIC, expected_message, **kwargs)
+ self.send_and_test_stream_message('push_one_tag', TOPIC, expected_message, **kwargs)
def test_bitbucket2_on_push_remove_tag_event(self) -> None:
expected_message = "kolaszek removed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
kwargs = {
"HTTP_X_EVENT_KEY": 'pullrequest:push',
}
- self.send_and_test_stream_message('push_remove_tag', self.EXPECTED_TOPIC, expected_message, **kwargs)
+ self.send_and_test_stream_message('push_remove_tag', TOPIC, expected_message, **kwargs)
def test_bitbucket2_on_push_more_than_one_tag_event(self) -> None:
expected_message = "kolaszek pushed tag [{name}](https://bitbucket.org/kolaszek/repository-name/commits/tag/{name})."
@@ -241,10 +241,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_TOPIC)
+ self.do_test_topic(msg, 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_TOPIC)
+ self.do_test_topic(msg, TOPIC)
self.do_test_message(msg, expected_message.format(name='a'))
def test_bitbucket2_on_more_than_one_push_event(self) -> None:
@@ -254,10 +254,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_TOPIC_BRANCH_EVENTS)
+ self.do_test_topic(msg, 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_TOPIC)
+ self.do_test_topic(msg, TOPIC)
def test_bitbucket2_on_more_than_one_push_event_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,development')
@@ -267,10 +267,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_TOPIC_BRANCH_EVENTS)
+ self.do_test_topic(msg, 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_TOPIC)
+ self.do_test_topic(msg, 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')
@@ -279,7 +279,7 @@ class Bitbucket2HookTests(WebhookTestCase):
}
expected_message = "kolaszek pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
self.send_and_test_stream_message('more_than_one_push_event',
- self.EXPECTED_TOPIC,
+ TOPIC,
expected_message, **kwargs)
@patch('zerver.webhooks.bitbucket2.view.check_send_webhook_message')
diff --git a/zerver/webhooks/bitbucket3/tests.py b/zerver/webhooks/bitbucket3/tests.py
index ee48fb7c258..097f18e3c5a 100644
--- a/zerver/webhooks/bitbucket3/tests.py
+++ b/zerver/webhooks/bitbucket3/tests.py
@@ -1,12 +1,12 @@
from zerver.lib.test_classes import WebhookTestCase
+TOPIC = "sandbox"
+TOPIC_BRANCH_EVENTS = "sandbox / {branch}"
class Bitbucket3HookTests(WebhookTestCase):
STREAM_NAME = "bitbucket3"
URL_TEMPLATE = "/api/v1/external/bitbucket3?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = "bitbucket3"
- EXPECTED_TOPIC = "sandbox"
- EXPECTED_TOPIC_BRANCH_EVENTS = "sandbox / {branch}"
# Diagnostics Events:
def test_ping(self) -> None:
@@ -26,24 +26,24 @@ class Bitbucket3HookTests(WebhookTestCase):
def test_commit_comment_added(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) commented on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\nJust an arbitrary comment on a commit.\n~~~"""
self.send_and_test_stream_message("commit_comment_added",
- self.EXPECTED_TOPIC,
+ TOPIC,
expected_message)
def test_commit_comment_edited(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) edited their comment on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\nJust an arbitrary comment on a commit. Nothing to see here...\n~~~"""
self.send_and_test_stream_message("commit_comment_edited",
- self.EXPECTED_TOPIC,
+ TOPIC,
expected_message)
def test_commit_comment_deleted(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted their comment on [508d1b6](http://139.59.64.214:7990/projects/SBOX/repos/sandbox/commits/508d1b67f1f8f3a25f543a030a7a178894aa9907):\n~~~ quote\n~~Just an arbitrary comment on a commit. Nothing to see here...~~\n~~~"""
self.send_and_test_stream_message("commit_comment_deleted",
- self.EXPECTED_TOPIC,
+ TOPIC,
expected_message)
def test_bitbucket3_repo_forked(self) -> None:
expected_message = """User Hemanth V. Alluri(login: [hypro999](http://139.59.64.214:7990/users/hypro999)) forked the repository into [sandbox fork](http://139.59.64.214:7990/users/hypro999/repos/sandbox-fork/browse)."""
- self.send_and_test_stream_message("repo_forked", self.EXPECTED_TOPIC, expected_message)
+ self.send_and_test_stream_message("repo_forked", TOPIC, expected_message)
def test_bitbucket3_repo_modified(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) changed the name of the **sandbox** repo from **sandbox** to **sandbox v2**."""
@@ -53,7 +53,7 @@ class Bitbucket3HookTests(WebhookTestCase):
# Repo Push Events:
def test_push_add_branch(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) created branch2 branch."""
- expected_topic = self.EXPECTED_TOPIC_BRANCH_EVENTS.format(branch="branch2")
+ expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch2")
self.send_and_test_stream_message("repo_push_add_branch",
expected_topic,
expected_message)
@@ -61,12 +61,12 @@ class Bitbucket3HookTests(WebhookTestCase):
def test_push_add_tag(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed tag newtag."""
self.send_and_test_stream_message("repo_push_add_tag",
- self.EXPECTED_TOPIC,
+ TOPIC,
expected_message)
def test_push_delete_branch(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) deleted branch branch2."""
- expected_topic = self.EXPECTED_TOPIC_BRANCH_EVENTS.format(branch="branch2")
+ expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch2")
self.send_and_test_stream_message("repo_push_delete_branch",
expected_topic,
expected_message)
@@ -74,12 +74,12 @@ class Bitbucket3HookTests(WebhookTestCase):
def test_push_delete_tag(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) removed tag test-tag."""
self.send_and_test_stream_message("repo_push_delete_tag",
- self.EXPECTED_TOPIC,
+ TOPIC,
expected_message)
def test_push_update_single_branch(self) -> None:
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now e68c981ef53dbab0a5ca320a2d8d80e216c70528."""
- expected_topic = self.EXPECTED_TOPIC_BRANCH_EVENTS.format(branch="master")
+ expected_topic = TOPIC_BRANCH_EVENTS.format(branch="master")
self.send_and_test_stream_message("repo_push_update_single_branch",
expected_topic,
expected_message)
@@ -90,24 +90,24 @@ class Bitbucket3HookTests(WebhookTestCase):
self.send_and_test_stream_message("repo_push_update_multiple_branches")
msg = self.get_last_message()
- self.do_test_topic(msg, self.EXPECTED_TOPIC_BRANCH_EVENTS.format(branch="master"))
+ self.do_test_topic(msg, TOPIC_BRANCH_EVENTS.format(branch="master"))
self.do_test_message(msg, expected_message_second)
msg = self.get_second_to_last_message()
- self.do_test_topic(msg, self.EXPECTED_TOPIC_BRANCH_EVENTS.format(branch="branch1"))
+ self.do_test_topic(msg, TOPIC_BRANCH_EVENTS.format(branch="branch1"))
self.do_test_message(msg, expected_message_first)
def test_push_update_multiple_branches_with_branch_filter(self) -> None:
self.url = self.build_webhook_url(branches='master')
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch master. Head is now fc43d13cff1abb28631196944ba4fc4ad06a2cf2."""
- expected_topic = self.EXPECTED_TOPIC_BRANCH_EVENTS.format(branch="master")
+ expected_topic = TOPIC_BRANCH_EVENTS.format(branch="master")
self.send_and_test_stream_message("repo_push_update_multiple_branches",
expected_topic,
expected_message)
self.url = self.build_webhook_url(branches='branch1')
expected_message = """[hypro999](http://139.59.64.214:7990/users/hypro999) pushed to branch branch1. Head is now 3980c2be32a7e23c795741d5dc1a2eecb9b85d6d."""
- expected_topic = self.EXPECTED_TOPIC_BRANCH_EVENTS.format(branch="branch1")
+ expected_topic = TOPIC_BRANCH_EVENTS.format(branch="branch1")
self.send_and_test_stream_message("repo_push_update_multiple_branches",
expected_topic,
expected_message)
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py
index cc80b8bfe0a..6ec111b5bd6 100644
--- a/zerver/webhooks/github/tests.py
+++ b/zerver/webhooks/github/tests.py
@@ -3,22 +3,22 @@ from unittest.mock import MagicMock, patch
from zerver.lib.test_classes import WebhookTestCase
from zerver.lib.webhooks.git import COMMITS_LIMIT
+TOPIC_REPO = "public-repo"
+TOPIC_ISSUE = "public-repo / Issue #2 Spelling error in the README file"
+TOPIC_PR = "public-repo / PR #1 Update the README with new information"
+TOPIC_DEPLOYMENT = "public-repo / Deployment on production"
+TOPIC_ORGANIZATION = "baxterandthehackers organization"
+TOPIC_BRANCH = "public-repo / changes"
+TOPIC_WIKI = "public-repo / Wiki Pages"
class GithubWebhookTest(WebhookTestCase):
STREAM_NAME = 'github'
URL_TEMPLATE = "/api/v1/external/github?stream={stream}&api_key={api_key}"
FIXTURE_DIR_NAME = 'github'
- EXPECTED_TOPIC_REPO_EVENTS = "public-repo"
- EXPECTED_TOPIC_ISSUE_EVENTS = "public-repo / Issue #2 Spelling error in the README file"
- EXPECTED_TOPIC_PR_EVENTS = "public-repo / PR #1 Update the README with new information"
- EXPECTED_TOPIC_DEPLOYMENT_EVENTS = "public-repo / Deployment on production"
- EXPECTED_TOPIC_ORGANIZATION_EVENTS = "baxterandthehackers organization"
- EXPECTED_TOPIC_BRANCH_EVENTS = "public-repo / changes"
- EXPECTED_TOPIC_WIKI_EVENTS = "public-repo / Wiki Pages"
def test_ping_event(self) -> None:
expected_message = "GitHub webhook has been successfully configured by TomaszKolek."
- self.send_and_test_stream_message('ping', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('ping', TOPIC_REPO, expected_message)
def test_star_event(self) -> None:
expected_message = "Codertocat starred the repository [Codertocat/Hello-World](https://github.com/Codertocat/Hello-World)."
@@ -39,81 +39,81 @@ class GithubWebhookTest(WebhookTestCase):
def test_push_1_commit(self) -> None:
expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"
- self.send_and_test_stream_message('push__1_commit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__1_commit', TOPIC_BRANCH, expected_message)
def test_push_1_commit_without_username(self) -> None:
expected_message = "eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/0383613da871...2e8cf535fb38) 1 commit to branch changes. Commits by John Snow (1).\n\n* Update the README ([2e8cf53](https://github.com/eeshangarg/public-repo/commit/2e8cf535fb38a3dab2476cdf856efda904ad4c94))"
- self.send_and_test_stream_message('push__1_commit_without_username', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__1_commit_without_username', TOPIC_BRANCH, expected_message)
def test_push_1_commit_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url('master,changes')
expected_message = "baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"
- self.send_and_test_stream_message('push__1_commit', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__1_commit', TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters(self) -> None:
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{commits_info * 5}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
- self.send_and_test_stream_message('push__multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__multiple_committers', TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters_with_others(self) -> None:
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{commits_info * 9}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
- self.send_and_test_stream_message('push__multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__multiple_committers_with_others', TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url('master,changes')
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 6 commits to branch changes. Commits by Tomasz (3), Ben (2) and baxterthehacker (1).\n\n{commits_info * 5}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
- self.send_and_test_stream_message('push__multiple_committers', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__multiple_committers', TOPIC_BRANCH, expected_message)
def test_push_multiple_comitters_with_others_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url('master,changes')
commits_info = '* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n'
expected_message = f"""baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 10 commits to branch changes. Commits by Tomasz (4), Ben (3), James (2) and others (1).\n\n{commits_info * 9}* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"""
- self.send_and_test_stream_message('push__multiple_committers_with_others', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__multiple_committers_with_others', TOPIC_BRANCH, expected_message)
def test_push_50_commits(self) -> None:
commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n"
expected_message = f"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{commit_info * COMMITS_LIMIT}[and 30 more commit(s)]"
- self.send_and_test_stream_message('push__50_commits', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__50_commits', TOPIC_BRANCH, expected_message)
def test_push_50_commits_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches='master,changes')
commit_info = "* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))\n"
expected_message = f"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 50 commits to branch changes.\n\n{commit_info * COMMITS_LIMIT}[and 30 more commit(s)]"
- self.send_and_test_stream_message('push__50_commits', self.EXPECTED_TOPIC_BRANCH_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__50_commits', TOPIC_BRANCH, expected_message)
def test_commit_comment_msg(self) -> None:
expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b#commitcomment-11056394) on [9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b):\n~~~ quote\nThis is a really good change! :+1:\n~~~"
- self.send_and_test_stream_message('commit_comment', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('commit_comment', TOPIC_REPO, expected_message)
def test_create_msg(self) -> None:
expected_message = "baxterthehacker created tag 0.0.1."
- self.send_and_test_stream_message('create', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('create', TOPIC_REPO, expected_message)
def test_delete_msg(self) -> None:
expected_message = "baxterthehacker deleted tag simple-tag."
- self.send_and_test_stream_message('delete', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('delete', TOPIC_REPO, expected_message)
def test_deployment_msg(self) -> None:
expected_message = "baxterthehacker created new deployment."
- self.send_and_test_stream_message('deployment', self.EXPECTED_TOPIC_DEPLOYMENT_EVENTS, expected_message)
+ self.send_and_test_stream_message('deployment', TOPIC_DEPLOYMENT, expected_message)
def test_deployment_status_msg(self) -> None:
expected_message = "Deployment changed status to success."
- self.send_and_test_stream_message('deployment_status', self.EXPECTED_TOPIC_DEPLOYMENT_EVENTS, expected_message)
+ self.send_and_test_stream_message('deployment_status', TOPIC_DEPLOYMENT, expected_message)
def test_fork_msg(self) -> None:
expected_message = "baxterandthehackers forked [public-repo](https://github.com/baxterandthehackers/public-repo)."
- self.send_and_test_stream_message('fork', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('fork', TOPIC_REPO, expected_message)
def test_issue_comment_msg(self) -> None:
expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~"
- self.send_and_test_stream_message('issue_comment', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message)
+ self.send_and_test_stream_message('issue_comment', TOPIC_ISSUE, expected_message)
def test_issue_comment_deleted_msg(self) -> None:
expected_topic = "Scheduler / Issue #5 This is a new issue"
@@ -128,7 +128,7 @@ class GithubWebhookTest(WebhookTestCase):
def test_issue_msg(self) -> None:
expected_message = "baxterthehacker opened [Issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nIt looks like you accidentally spelled 'commit' with two 't's.\n~~~"
- self.send_and_test_stream_message('issues', self.EXPECTED_TOPIC_ISSUE_EVENTS, expected_message)
+ self.send_and_test_stream_message('issues', TOPIC_ISSUE, expected_message)
def test_issue_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications')
@@ -138,19 +138,19 @@ class GithubWebhookTest(WebhookTestCase):
def test_membership_msg(self) -> None:
expected_message = "baxterthehacker added [kdaigle](https://github.com/kdaigle) to the Contractors team."
- self.send_and_test_stream_message('membership', self.EXPECTED_TOPIC_ORGANIZATION_EVENTS, expected_message)
+ self.send_and_test_stream_message('membership', TOPIC_ORGANIZATION, expected_message)
def test_membership_removal_msg(self) -> None:
expected_message = "baxterthehacker removed [kdaigle](https://github.com/kdaigle) from the Contractors team."
- self.send_and_test_stream_message('membership__removal', self.EXPECTED_TOPIC_ORGANIZATION_EVENTS, expected_message)
+ self.send_and_test_stream_message('membership__removal', TOPIC_ORGANIZATION, expected_message)
def test_member_msg(self) -> None:
expected_message = "baxterthehacker added [octocat](https://github.com/octocat) to [public-repo](https://github.com/baxterthehacker/public-repo)."
- self.send_and_test_stream_message('member', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('member', TOPIC_REPO, expected_message)
def test_pull_request_opened_msg(self) -> None:
expected_message = "baxterthehacker opened [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`:\n\n~~~ quote\nThis is a pretty simple change that we need to pull into master.\n~~~"
- self.send_and_test_stream_message('pull_request__opened', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request__opened', TOPIC_PR, expected_message)
def test_pull_request_opened_with_preassigned_assignee_msg(self) -> None:
expected_topic = "Scheduler / PR #4 Improve README"
@@ -165,11 +165,11 @@ class GithubWebhookTest(WebhookTestCase):
def test_pull_request_synchronized_msg(self) -> None:
expected_message = "baxterthehacker updated [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`."
- self.send_and_test_stream_message('pull_request__synchronized', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request__synchronized', TOPIC_PR, expected_message)
def test_pull_request_closed_msg(self) -> None:
expected_message = "baxterthehacker closed without merge [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)."
- self.send_and_test_stream_message('pull_request__closed', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request__closed', TOPIC_PR, expected_message)
def test_pull_request_closed_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications')
@@ -179,47 +179,47 @@ class GithubWebhookTest(WebhookTestCase):
def test_pull_request_merged_msg(self) -> None:
expected_message = "baxterthehacker merged [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)."
- self.send_and_test_stream_message('pull_request__merged', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request__merged', TOPIC_PR, expected_message)
def test_public_msg(self) -> None:
expected_message = "baxterthehacker made the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo) public."
- self.send_and_test_stream_message('public', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('public', TOPIC_REPO, expected_message)
def test_wiki_pages_msg(self) -> None:
expected_message = "jasonrudolph:\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)\n* created [Home](https://github.com/baxterthehacker/public-repo/wiki/Home)"
- self.send_and_test_stream_message('gollum__wiki_pages', self.EXPECTED_TOPIC_WIKI_EVENTS, expected_message)
+ self.send_and_test_stream_message('gollum__wiki_pages', TOPIC_WIKI, expected_message)
def test_watch_msg(self) -> None:
expected_message = "baxterthehacker starred the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo)."
- self.send_and_test_stream_message('watch__repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('watch__repository', TOPIC_REPO, expected_message)
def test_repository_msg(self) -> None:
expected_message = "baxterthehacker created the repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo)."
- self.send_and_test_stream_message('repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('repository', TOPIC_REPO, expected_message)
def test_team_add_msg(self) -> None:
expected_message = "The repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo) was added to team github."
- self.send_and_test_stream_message('team_add', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('team_add', TOPIC_REPO, expected_message)
def test_release_msg(self) -> None:
expected_message = "baxterthehacker published release [0.0.1](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1) for tag 0.0.1."
- self.send_and_test_stream_message('release', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('release', TOPIC_REPO, expected_message)
def test_page_build_msg(self) -> None:
expected_message = "Github Pages build, triggered by baxterthehacker, has finished building."
- self.send_and_test_stream_message('page_build', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('page_build', TOPIC_REPO, expected_message)
def test_status_msg(self) -> None:
expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to success."
- self.send_and_test_stream_message('status', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('status', TOPIC_REPO, expected_message)
def test_status_with_target_url_msg(self) -> None:
expected_message = "[9049f12](https://github.com/baxterthehacker/public-repo/commit/9049f1265b7d61be4a8904a9a27120d2064dab3b) changed its status to [success](https://example.com/build/status)."
- self.send_and_test_stream_message('status__with_target_url', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('status__with_target_url', TOPIC_REPO, expected_message)
def test_pull_request_review_msg(self) -> None:
expected_message = "baxterthehacker submitted [PR Review](https://github.com/baxterthehacker/public-repo/pull/1#pullrequestreview-2626884)."
- self.send_and_test_stream_message('pull_request_review', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request_review', TOPIC_PR, expected_message)
def test_pull_request_review_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications')
@@ -229,7 +229,7 @@ class GithubWebhookTest(WebhookTestCase):
def test_pull_request_review_comment_msg(self) -> None:
expected_message = "baxterthehacker created [PR Review Comment](https://github.com/baxterthehacker/public-repo/pull/1#discussion_r29724692):\n\n~~~ quote\nMaybe you should use more emojji on this line.\n~~~"
- self.send_and_test_stream_message('pull_request_review_comment', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request_review_comment', TOPIC_PR, expected_message)
def test_pull_request_review_comment_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications')
@@ -239,15 +239,15 @@ class GithubWebhookTest(WebhookTestCase):
def test_push_tag_msg(self) -> None:
expected_message = "baxterthehacker pushed tag abc."
- self.send_and_test_stream_message('push__tag', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
+ self.send_and_test_stream_message('push__tag', TOPIC_REPO, expected_message)
def test_pull_request_edited_msg(self) -> None:
expected_message = "baxterthehacker edited [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`."
- self.send_and_test_stream_message('pull_request__edited', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request__edited', TOPIC_PR, expected_message)
def test_pull_request_assigned_msg(self) -> None:
expected_message = "baxterthehacker assigned [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker."
- self.send_and_test_stream_message('pull_request__assigned', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)
+ self.send_and_test_stream_message('pull_request__assigned', TOPIC_PR, expected_message)
def test_pull_request_assigned_msg_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic='notifications')