mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	webhooks: Rename assert_stream_message to assert_channel_message.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							4e968869a2
						
					
				
				
					commit
					fef299510f
				
			@@ -2232,14 +2232,14 @@ one or more new messages.
 | 
			
		||||
            )
 | 
			
		||||
        assert expected_message is not None and expected_topic_name is not None
 | 
			
		||||
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=expected_topic_name,
 | 
			
		||||
            content=expected_message,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def assert_stream_message(
 | 
			
		||||
    def assert_channel_message(
 | 
			
		||||
        self,
 | 
			
		||||
        message: Message,
 | 
			
		||||
        stream_name: str,
 | 
			
		||||
 
 | 
			
		||||
@@ -173,7 +173,7 @@ class WebhookURLConfigurationTestCase(WebhookTestCase):
 | 
			
		||||
        expected_message = "Hello! I am happy to be here! :smile:\nThe Wikipedia featured article for today is **[Marilyn Monroe](https://en.wikipedia.org/wiki/Marilyn_Monroe)**"
 | 
			
		||||
 | 
			
		||||
        msg = self.get_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name="helloworld_renamed",
 | 
			
		||||
            topic_name=expected_topic_name,
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,9 @@ 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_channel_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 +27,9 @@ class BitbucketHookTests(WebhookTestCase):
 | 
			
		||||
        expected_message = (
 | 
			
		||||
            f"Someone pushed 1 commit to branch master. Commits by eeshangarg (1).\n\n{commit_info}"
 | 
			
		||||
        )
 | 
			
		||||
        self.api_channel_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 +38,18 @@ 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_channel_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_channel_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 +58,9 @@ 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_channel_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"
 | 
			
		||||
 
 | 
			
		||||
@@ -290,7 +290,7 @@ class Bitbucket2HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_second_to_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC,
 | 
			
		||||
@@ -298,7 +298,7 @@ class Bitbucket2HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC,
 | 
			
		||||
@@ -318,7 +318,7 @@ class Bitbucket2HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_second_to_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC_BRANCH_EVENTS,
 | 
			
		||||
@@ -326,7 +326,7 @@ class Bitbucket2HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC,
 | 
			
		||||
@@ -348,7 +348,7 @@ class Bitbucket2HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_second_to_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC_BRANCH_EVENTS,
 | 
			
		||||
@@ -356,7 +356,7 @@ class Bitbucket2HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC,
 | 
			
		||||
 
 | 
			
		||||
@@ -92,7 +92,7 @@ class Bitbucket3HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_second_to_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC_BRANCH_EVENTS.format(branch="branch1"),
 | 
			
		||||
@@ -100,7 +100,7 @@ class Bitbucket3HookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=TOPIC_BRANCH_EVENTS.format(branch="master"),
 | 
			
		||||
 
 | 
			
		||||
@@ -558,7 +558,7 @@ A temporary team so that I can get some webhook fixtures!
 | 
			
		||||
                content_type="application/json",
 | 
			
		||||
            )
 | 
			
		||||
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=stream_message,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name="team My Team",
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ Leo Franchi created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/
 | 
			
		||||
* **Priority**: Major
 | 
			
		||||
* **Assignee**: no one
 | 
			
		||||
""".strip()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name="jira_custom",
 | 
			
		||||
            topic_name="BUG-15: New bug with hook",
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ Hello, world.
 | 
			
		||||
                payload,
 | 
			
		||||
                content_type="application/json",
 | 
			
		||||
            )
 | 
			
		||||
            self.assert_stream_message(
 | 
			
		||||
            self.assert_channel_message(
 | 
			
		||||
                message=msg,
 | 
			
		||||
                stream_name=self.CHANNEL_NAME,
 | 
			
		||||
                topic_name="(no topic)",
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ class UpdownHookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_second_to_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=topic_name,
 | 
			
		||||
@@ -46,7 +46,7 @@ class UpdownHookTests(WebhookTestCase):
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        msg = self.get_last_message()
 | 
			
		||||
        self.assert_stream_message(
 | 
			
		||||
        self.assert_channel_message(
 | 
			
		||||
            message=msg,
 | 
			
		||||
            stream_name=self.CHANNEL_NAME,
 | 
			
		||||
            topic_name=topic_name,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user