mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	webhooks: Move github_webhook/ to github/.
This commit is contained in:
		
							
								
								
									
										2
									
								
								mypy.ini
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								mypy.ini
									
									
									
									
									
								
							@@ -43,7 +43,7 @@ strict_optional = False
 | 
			
		||||
strict_optional = False
 | 
			
		||||
[mypy-zerver.webhooks.gitlab.view]
 | 
			
		||||
strict_optional = False
 | 
			
		||||
[mypy-zerver.webhooks.github_webhook.view]
 | 
			
		||||
[mypy-zerver.webhooks.github.view]
 | 
			
		||||
strict_optional = False
 | 
			
		||||
[mypy-zerver.webhooks.bitbucket.view]
 | 
			
		||||
strict_optional = False
 | 
			
		||||
 
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB  | 
@@ -522,7 +522,7 @@
 | 
			
		||||
                    <p class="integration-description">See build results immediately</p>
 | 
			
		||||
                </div>
 | 
			
		||||
            </a>
 | 
			
		||||
            <a href="/integrations/doc/github_webhook">
 | 
			
		||||
            <a href="/integrations/doc/github">
 | 
			
		||||
                <div class="group">
 | 
			
		||||
                    <img class="integration-logo" src="/static/images/integrations/logos/github.svg" alt="{{ _('Github logo') }}">
 | 
			
		||||
                    <h3 class="integration-name">Github</h3>
 | 
			
		||||
 
 | 
			
		||||
@@ -106,7 +106,7 @@ not_yet_fully_covered = {
 | 
			
		||||
    'zerver/webhooks/bitbucket2/view.py',
 | 
			
		||||
    'zerver/webhooks/freshdesk/view.py',
 | 
			
		||||
    'zerver/webhooks/github_legacy/view.py',
 | 
			
		||||
    'zerver/webhooks/github_webhook/view.py',
 | 
			
		||||
    'zerver/webhooks/github/view.py',
 | 
			
		||||
    'zerver/webhooks/gitlab/view.py',
 | 
			
		||||
    'zerver/webhooks/gogs/view.py',
 | 
			
		||||
    'zerver/webhooks/greenhouse/view.py',
 | 
			
		||||
 
 | 
			
		||||
@@ -298,11 +298,11 @@ WEBHOOK_INTEGRATIONS = [
 | 
			
		||||
    WebhookIntegration('freshdesk', ['customer-support']),
 | 
			
		||||
    WebhookIntegration('front', ['customer-support'], display_name='Front'),
 | 
			
		||||
    GithubIntegration(
 | 
			
		||||
        'github_webhook',
 | 
			
		||||
        'github',
 | 
			
		||||
        ['version-control'],
 | 
			
		||||
        display_name='GitHub',
 | 
			
		||||
        logo='static/images/integrations/logos/github.svg',
 | 
			
		||||
        function='zerver.webhooks.github_webhook.view.api_github_webhook',
 | 
			
		||||
        function='zerver.webhooks.github.view.api_github_webhook',
 | 
			
		||||
        stream_name='github'
 | 
			
		||||
    ),
 | 
			
		||||
    WebhookIntegration('gitlab', ['version-control'], display_name='GitLab'),
 | 
			
		||||
 
 | 
			
		||||
@@ -16,4 +16,4 @@ Get GitHub notifications in Zulip!
 | 
			
		||||
 | 
			
		||||
{!congrats.md!}
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||

 | 
			
		||||
@@ -10,7 +10,7 @@ from zerver.models import Message
 | 
			
		||||
class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
    STREAM_NAME = 'github'
 | 
			
		||||
    URL_TEMPLATE = "/api/v1/external/github?stream={stream}&api_key={api_key}"
 | 
			
		||||
    FIXTURE_DIR_NAME = 'github_webhook'
 | 
			
		||||
    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"
 | 
			
		||||
@@ -208,7 +208,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
            HTTP_X_GITHUB_EVENT='pull_request'
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_pull_request_labeled_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        payload = self.get_body('labeled_pull_request')
 | 
			
		||||
@@ -216,7 +216,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_pull_request_unlabeled_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        payload = self.get_body('unlabeled_pull_request')
 | 
			
		||||
@@ -224,7 +224,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_pull_request_request_review_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        payload = self.get_body('request_review_pull_request')
 | 
			
		||||
@@ -232,7 +232,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_pull_request_request_review_remove_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        payload = self.get_body('request_review_removed_pull_request')
 | 
			
		||||
@@ -240,7 +240,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_push_1_commit_filtered_by_branches_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        self.url = self.build_webhook_url(branches='master,development')
 | 
			
		||||
@@ -249,7 +249,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_push_50_commits_filtered_by_branches_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        self.url = self.build_webhook_url(branches='master,development')
 | 
			
		||||
@@ -258,7 +258,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_push_multiple_comitters_filtered_by_branches_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        self.url = self.build_webhook_url(branches='master,development')
 | 
			
		||||
@@ -267,7 +267,7 @@ class GithubWebhookTest(WebhookTestCase):
 | 
			
		||||
        self.assertFalse(check_send_webhook_message_mock.called)
 | 
			
		||||
        self.assert_json_success(result)
 | 
			
		||||
 | 
			
		||||
    @patch('zerver.webhooks.github_webhook.view.check_send_webhook_message')
 | 
			
		||||
    @patch('zerver.webhooks.github.view.check_send_webhook_message')
 | 
			
		||||
    def test_push_multiple_comitters_with_others_filtered_by_branches_ignore(
 | 
			
		||||
            self, check_send_webhook_message_mock: MagicMock) -> None:
 | 
			
		||||
        self.url = self.build_webhook_url(branches='master,development')
 | 
			
		||||
@@ -2,7 +2,7 @@ from django.http import HttpRequest, HttpResponse
 | 
			
		||||
from django.views.decorators.csrf import csrf_exempt
 | 
			
		||||
 | 
			
		||||
from .github_legacy.view import api_github_landing
 | 
			
		||||
from .github_webhook.view import api_github_webhook
 | 
			
		||||
from .github.view import api_github_webhook
 | 
			
		||||
 | 
			
		||||
# Since this dispatcher is an API-style endpoint, it needs to be
 | 
			
		||||
# explicitly marked as CSRF-exempt
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user