mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	webhooks: Rename stream->channel in some remaining random places.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							2099afe79b
						
					
				
				
					commit
					2b927e355a
				
			@@ -4,7 +4,7 @@ from zerver.lib.test_classes import WebhookTestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Tests for the Desk.com webhook integration.
 | 
					# Tests for the Desk.com webhook integration.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# The stream name must be provided in the URL-encoded test fixture data,
 | 
					# The channel name must be provided in the URL-encoded test fixture data,
 | 
				
			||||||
# and must match CHANNEL_NAME set here.
 | 
					# and must match CHANNEL_NAME set here.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Example:
 | 
					# Example:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -550,7 +550,7 @@ A temporary team so that I can get some webhook fixtures!
 | 
				
			|||||||
        log_mock = patch("zerver.decorator.webhook_unsupported_events_logger.exception")
 | 
					        log_mock = patch("zerver.decorator.webhook_unsupported_events_logger.exception")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with log_mock as m:
 | 
					        with log_mock as m:
 | 
				
			||||||
            stream_message = self.send_webhook_payload(
 | 
					            channel_message = self.send_webhook_payload(
 | 
				
			||||||
                self.test_user,
 | 
					                self.test_user,
 | 
				
			||||||
                self.url,
 | 
					                self.url,
 | 
				
			||||||
                payload,
 | 
					                payload,
 | 
				
			||||||
@@ -559,7 +559,7 @@ A temporary team so that I can get some webhook fixtures!
 | 
				
			|||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.assert_channel_message(
 | 
					        self.assert_channel_message(
 | 
				
			||||||
            message=stream_message,
 | 
					            message=channel_message,
 | 
				
			||||||
            channel_name=self.CHANNEL_NAME,
 | 
					            channel_name=self.CHANNEL_NAME,
 | 
				
			||||||
            topic_name="team My Team",
 | 
					            topic_name="team My Team",
 | 
				
			||||||
            content="Team has changes to `bogus_key1/bogus_key2` data.",
 | 
					            content="Team has changes to `bogus_key1/bogus_key2` data.",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ class JiraHookTests(WebhookTestCase):
 | 
				
			|||||||
    URL_TEMPLATE = "/api/v1/external/jira?api_key={api_key}&stream={stream}"
 | 
					    URL_TEMPLATE = "/api/v1/external/jira?api_key={api_key}&stream={stream}"
 | 
				
			||||||
    WEBHOOK_DIR_NAME = "jira"
 | 
					    WEBHOOK_DIR_NAME = "jira"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_custom_stream(self) -> None:
 | 
					    def test_custom_channel(self) -> None:
 | 
				
			||||||
        api_key = get_api_key(self.test_user)
 | 
					        api_key = get_api_key(self.test_user)
 | 
				
			||||||
        self.subscribe(self.test_user, "jira_custom")
 | 
					        self.subscribe(self.test_user, "jira_custom")
 | 
				
			||||||
        url = f"/api/v1/external/jira?api_key={api_key}&stream=jira_custom"
 | 
					        url = f"/api/v1/external/jira?api_key={api_key}&stream=jira_custom"
 | 
				
			||||||
@@ -64,7 +64,7 @@ Leo Franchi created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/
 | 
				
			|||||||
            self.assertFalse(m.called)
 | 
					            self.assertFalse(m.called)
 | 
				
			||||||
            self.assert_json_success(result)
 | 
					            self.assert_json_success(result)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_created_with_stream_with_spaces_escaped(self) -> None:
 | 
					    def test_created_with_channel_with_spaces_escaped(self) -> None:
 | 
				
			||||||
        self.CHANNEL_NAME = quote("jira alerts")
 | 
					        self.CHANNEL_NAME = quote("jira alerts")
 | 
				
			||||||
        self.url = self.build_webhook_url()
 | 
					        self.url = self.build_webhook_url()
 | 
				
			||||||
        self.subscribe(self.test_user, unquote(self.CHANNEL_NAME))
 | 
					        self.subscribe(self.test_user, unquote(self.CHANNEL_NAME))
 | 
				
			||||||
@@ -85,7 +85,7 @@ Leo Franchi created [BUG-15: New bug with hook](http://lfranchi.com:8080/browse/
 | 
				
			|||||||
        self.assertEqual(msg.content, expected_message)
 | 
					        self.assertEqual(msg.content, expected_message)
 | 
				
			||||||
        self.assertEqual(msg.topic_name(), expected_topic_name)
 | 
					        self.assertEqual(msg.topic_name(), expected_topic_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_created_with_stream_with_spaces_double_escaped(self) -> None:
 | 
					    def test_created_with_channel_with_spaces_double_escaped(self) -> None:
 | 
				
			||||||
        self.CHANNEL_NAME = quote(quote("jira alerts"))
 | 
					        self.CHANNEL_NAME = quote(quote("jira alerts"))
 | 
				
			||||||
        self.url = self.build_webhook_url()
 | 
					        self.url = self.build_webhook_url()
 | 
				
			||||||
        self.subscribe(self.test_user, unquote(unquote(self.CHANNEL_NAME)))
 | 
					        self.subscribe(self.test_user, unquote(unquote(self.CHANNEL_NAME)))
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,8 +47,8 @@ def api_slack_webhook(
 | 
				
			|||||||
            content,
 | 
					            content,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    elif channels_map_to_topics == VALID_OPTIONS["SHOULD_NOT_BE_MAPPED"]:
 | 
					    elif channels_map_to_topics == VALID_OPTIONS["SHOULD_NOT_BE_MAPPED"]:
 | 
				
			||||||
        # This stream-channel mapping will be used even if
 | 
					        # This channel-channel mapping will be used even if
 | 
				
			||||||
        # there is a stream specified in the webhook URL.
 | 
					        # there is a channel specified in the webhook URL.
 | 
				
			||||||
        check_send_webhook_message(
 | 
					        check_send_webhook_message(
 | 
				
			||||||
            request,
 | 
					            request,
 | 
				
			||||||
            user_profile,
 | 
					            user_profile,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,7 +83,7 @@ class WordPressHookTests(WebhookTestCase):
 | 
				
			|||||||
        # we are testing. The value of result is the error message the webhook should
 | 
					        # we are testing. The value of result is the error message the webhook should
 | 
				
			||||||
        # return if no params are sent. The fixture for this test is an empty file.
 | 
					        # return if no params are sent. The fixture for this test is an empty file.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # subscribe to the target stream
 | 
					        # subscribe to the target channel
 | 
				
			||||||
        self.subscribe(self.test_user, self.CHANNEL_NAME)
 | 
					        self.subscribe(self.test_user, self.CHANNEL_NAME)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # post to the webhook url
 | 
					        # post to the webhook url
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user