mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
webhooks: Rename api_stream_message to api_channel_message in tests.
This commit is contained in:
committed by
Tim Abbott
parent
dc31347ac4
commit
4e968869a2
@@ -2148,7 +2148,7 @@ You can fix this by adding "{complete_event_type}" to ALL_EVENT_TYPES for this w
|
||||
self.patch.start()
|
||||
self.addCleanup(self.patch.stop)
|
||||
|
||||
def api_stream_message(
|
||||
def api_channel_message(
|
||||
self,
|
||||
user: UserProfile,
|
||||
fixture_name: str,
|
||||
|
||||
@@ -16,7 +16,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 1 commit to branch master.
|
||||
|
||||
* add some stuff ([e50508df24c](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df))"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"git_singlecommit",
|
||||
expected_topic_name,
|
||||
@@ -30,7 +30,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 1 commit to branch master.
|
||||
|
||||
* add some stuff ([e50508df24c](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df))"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"git_singlecommit",
|
||||
expected_topic_name,
|
||||
@@ -45,7 +45,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
* Added new file ([edf529c7a64](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7))
|
||||
* Filled in new file with some stuff ([c2a191b9e79](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9))
|
||||
* More work to fix some bugs ([20098158e20](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"git_multiple_committers",
|
||||
expected_topic_name,
|
||||
@@ -61,7 +61,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
* Added new file ([edf529c7a64](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7))
|
||||
* Filled in new file with some stuff ([c2a191b9e79](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9))
|
||||
* More work to fix some bugs ([20098158e20](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"git_multiple_committers",
|
||||
expected_topic_name,
|
||||
@@ -76,7 +76,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
* Added new file ([edf529c7a64](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7))
|
||||
* Filled in new file with some stuff ([c2a191b9e79](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9))
|
||||
* More work to fix some bugs ([20098158e20](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user, "git_multiple", expected_topic_name, expected_message, content_type=None
|
||||
)
|
||||
|
||||
@@ -88,7 +88,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
* Added new file ([edf529c7a64](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7))
|
||||
* Filled in new file with some stuff ([c2a191b9e79](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/c2a191b9))
|
||||
* More work to fix some bugs ([20098158e20](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/20098158))"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user, "git_multiple", expected_topic_name, expected_message, content_type=None
|
||||
)
|
||||
|
||||
@@ -98,7 +98,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
expected_message = f"""Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 50 commits to branch master.
|
||||
|
||||
{(commits_info * COMMITS_LIMIT)}[and {50 - COMMITS_LIMIT} more commit(s)]"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"git_morethanlimitcommits",
|
||||
expected_topic_name,
|
||||
@@ -113,7 +113,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
expected_message = f"""Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) 50 commits to branch master.
|
||||
|
||||
{(commits_info * COMMITS_LIMIT)}[and {50 - COMMITS_LIMIT} more commit(s)]"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"git_morethanlimitcommits",
|
||||
expected_topic_name,
|
||||
@@ -166,7 +166,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
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.api_channel_message(
|
||||
self.test_user,
|
||||
"svn_addremove",
|
||||
expected_topic_name,
|
||||
@@ -179,7 +179,7 @@ class BeanstalkHookTests(WebhookTestCase):
|
||||
expected_message = """Leo Franchi pushed [revision 2](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/2):
|
||||
|
||||
> Added some code"""
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"svn_changefile",
|
||||
expected_topic_name,
|
||||
|
||||
@@ -16,7 +16,7 @@ class BitbucketHookTests(WebhookTestCase):
|
||||
self.url = self.build_webhook_url(payload=self.get_body(fixture_name))
|
||||
commit_info = "* c ([25f93d22b71](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, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
self.api_channel_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
|
||||
def test_bitbucket_on_push_event_without_user_info(self) -> None:
|
||||
fixture_name = "push_without_user_info"
|
||||
@@ -25,7 +25,7 @@ class BitbucketHookTests(WebhookTestCase):
|
||||
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, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
self.api_channel_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
|
||||
def test_bitbucket_on_push_event_filtered_by_branches(self) -> None:
|
||||
fixture_name = "push"
|
||||
@@ -34,14 +34,14 @@ class BitbucketHookTests(WebhookTestCase):
|
||||
)
|
||||
commit_info = "* c ([25f93d22b71](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, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
self.api_channel_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
|
||||
def test_bitbucket_on_push_commits_above_limit_event(self) -> None:
|
||||
fixture_name = "push_commits_above_limit"
|
||||
self.url = self.build_webhook_url(payload=self.get_body(fixture_name))
|
||||
commit_info = "* c ([25f93d22b71](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, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
self.api_channel_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:
|
||||
fixture_name = "push_commits_above_limit"
|
||||
@@ -50,7 +50,7 @@ class BitbucketHookTests(WebhookTestCase):
|
||||
)
|
||||
commit_info = "* c ([25f93d22b71](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, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
self.api_channel_message(self.test_user, fixture_name, TOPIC_BRANCH_EVENTS, expected_message)
|
||||
|
||||
def test_bitbucket_on_force_push_event(self) -> None:
|
||||
fixture_name = "force_push"
|
||||
@@ -58,7 +58,7 @@ class BitbucketHookTests(WebhookTestCase):
|
||||
expected_message = (
|
||||
"kolaszek [force pushed](https://bitbucket.org/kolaszek/repository-name)."
|
||||
)
|
||||
self.api_stream_message(self.test_user, fixture_name, TOPIC, expected_message)
|
||||
self.api_channel_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"
|
||||
@@ -66,7 +66,7 @@ class BitbucketHookTests(WebhookTestCase):
|
||||
expected_message = (
|
||||
"Someone [force pushed](https://bitbucket.org/kolaszek/repository-name/)."
|
||||
)
|
||||
self.api_stream_message(self.test_user, fixture_name, TOPIC, expected_message)
|
||||
self.api_channel_message(self.test_user, fixture_name, TOPIC, expected_message)
|
||||
|
||||
@patch("zerver.webhooks.bitbucket.view.check_send_webhook_message")
|
||||
def test_bitbucket_on_push_event_filtered_by_branches_ignore(
|
||||
|
||||
@@ -22,7 +22,7 @@ class DeskDotComHookTests(WebhookTestCase):
|
||||
expected_topic_name = "static text notification"
|
||||
expected_message = "This is a custom action."
|
||||
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"static_text",
|
||||
expected_topic_name,
|
||||
@@ -38,7 +38,7 @@ class DeskDotComHookTests(WebhookTestCase):
|
||||
"I have a question</a>"
|
||||
)
|
||||
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"case_updated",
|
||||
expected_topic_name,
|
||||
@@ -54,7 +54,7 @@ class DeskDotComHookTests(WebhookTestCase):
|
||||
"Il mio hovercraft è pieno di anguille.</a>"
|
||||
)
|
||||
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"unicode_text_italian",
|
||||
expected_topic_name,
|
||||
@@ -70,7 +70,7 @@ class DeskDotComHookTests(WebhookTestCase):
|
||||
"私のホバークラフトは鰻でいっぱいです</a>"
|
||||
)
|
||||
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"unicode_text_japanese",
|
||||
expected_topic_name,
|
||||
|
||||
@@ -26,7 +26,7 @@ Test ticket description ☃.
|
||||
* **Status**: Pending
|
||||
""".strip()
|
||||
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"ticket_created",
|
||||
expected_topic_name,
|
||||
@@ -46,7 +46,7 @@ Requester Bob <requester-bob@example.com> updated [ticket #11](http://test1234zz
|
||||
* **Status**: Resolved -> Waiting on Customer
|
||||
""".strip()
|
||||
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"status_changed",
|
||||
expected_topic_name,
|
||||
@@ -65,7 +65,7 @@ Requester Bob <requester-bob@example.com> updated [ticket #11](http://test1234zz
|
||||
|
||||
* **Priority**: High -> Low
|
||||
""".strip()
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"priority_changed",
|
||||
expected_topic_name,
|
||||
@@ -99,7 +99,7 @@ Requester Bob <requester-bob@example.com> updated [ticket #11](http://test1234zz
|
||||
Requester Bob <requester-bob@example.com> added a {} note to \
|
||||
[ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11).
|
||||
""".strip().format(note_type)
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
fixture,
|
||||
expected_topic_name,
|
||||
@@ -123,7 +123,7 @@ Requester Bob <requester-bob@example.com> added a {} note to \
|
||||
expected_message = """
|
||||
Requester \u2603 Bob <requester-bob@example.com> 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.\nExhibit 1:\n\n \n\n[guinea_pig.png](http://cdn.freshdesk.com/data/helpdesk/attachments/production/12744808/original/guinea_pig.png)\n```\n\n* **Type**: Problem\n* **Priority**: Urgent\n* **Status**: Open
|
||||
""".strip()
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"inline_images",
|
||||
expected_topic_name,
|
||||
|
||||
@@ -19,7 +19,7 @@ class ZenDeskHookTests(WebhookTestCase):
|
||||
}
|
||||
|
||||
def do_test(self, expected_topic: str, expected_message: str) -> None:
|
||||
self.api_stream_message(
|
||||
self.api_channel_message(
|
||||
self.test_user,
|
||||
"",
|
||||
expected_topic,
|
||||
|
||||
Reference in New Issue
Block a user