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.

integrations: Rename bitbucket2 integration to bitbucket.

Niloth Pe2ee479afd6f
diff --git a/static/images/integrations/bitbucket/003.png b/static/images/integrations/bitbucket/001.png
similarity index 100%
rename from static/images/integrations/bitbucket/003.png
rename to static/images/integrations/bitbucket/001.png
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 0a4a19f0fca..89c3fcdf137 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -550,20 +550,11 @@ INCOMING_WEBHOOK_INTEGRATIONS: list[IncomingWebhookIntegration] = [
display_name="Beeminder",
),
IncomingWebhookIntegration(
- "bitbucket2",
+ "bitbucket",
["version-control"],
- [
- WebhookScreenshotConfig(
- "push.json",
- "003.png",
- "bitbucket",
- bot_name="Bitbucket Bot",
- channel="commits",
- )
- ],
- logo="images/integrations/logos/bitbucket.svg",
- display_name="Bitbucket",
+ [WebhookScreenshotConfig("issue_created.json", channel="commits")],
url_options=[WebhookUrlOption.build_preset_config(PresetUrlOption.BRANCHES)],
+ legacy_names=["bitbucket2"],
),
IncomingWebhookIntegration(
"buildbot", ["continuous-integration"], [WebhookScreenshotConfig("started.json")]
diff --git a/zerver/webhooks/bitbucket2/__init__.py b/zerver/webhooks/bitbucket/__init__.py
similarity index 100%
rename from zerver/webhooks/bitbucket2/__init__.py
rename to zerver/webhooks/bitbucket/__init__.py
diff --git a/zerver/webhooks/bitbucket2/doc.md b/zerver/webhooks/bitbucket/doc.md
similarity index 74%
rename from zerver/webhooks/bitbucket2/doc.md
rename to zerver/webhooks/bitbucket/doc.md
index db039b063f7..17eeed99d54 100644
--- a/zerver/webhooks/bitbucket2/doc.md
+++ b/zerver/webhooks/bitbucket/doc.md
@@ -1,8 +1,6 @@
# Zulip Bitbucket integration
-Zulip supports both Git and Mercurial notifications from
-Bitbucket. This integration is for the new-style Bitbucket
-webhooks used by the Bitbucket SAAS service.
+Zulip supports both Git and Mercurial notifications from Bitbucket.
{start_tabs}
@@ -22,7 +20,7 @@ webhooks used by the Bitbucket SAAS service.
{!congrats.md!}
-![](/static/images/integrations/bitbucket/003.png)
+![](/static/images/integrations/bitbucket/001.png)
{!event-filtering-additional-feature.md!}
diff --git a/zerver/webhooks/bitbucket2/fixtures/commit_comment_created.json b/zerver/webhooks/bitbucket/fixtures/commit_comment_created.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/commit_comment_created.json
rename to zerver/webhooks/bitbucket/fixtures/commit_comment_created.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/commit_status_changed.json b/zerver/webhooks/bitbucket/fixtures/commit_status_changed.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/commit_status_changed.json
rename to zerver/webhooks/bitbucket/fixtures/commit_status_changed.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/force_push.json b/zerver/webhooks/bitbucket/fixtures/force_push.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/force_push.json
rename to zerver/webhooks/bitbucket/fixtures/force_push.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/fork.json b/zerver/webhooks/bitbucket/fixtures/fork.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/fork.json
rename to zerver/webhooks/bitbucket/fixtures/fork.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/issue_commented.json b/zerver/webhooks/bitbucket/fixtures/issue_commented.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/issue_commented.json
rename to zerver/webhooks/bitbucket/fixtures/issue_commented.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/issue_created.json b/zerver/webhooks/bitbucket/fixtures/issue_created.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/issue_created.json
rename to zerver/webhooks/bitbucket/fixtures/issue_created.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/issue_updated.json b/zerver/webhooks/bitbucket/fixtures/issue_updated.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/issue_updated.json
rename to zerver/webhooks/bitbucket/fixtures/issue_updated.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/more_than_one_push_event.json b/zerver/webhooks/bitbucket/fixtures/more_than_one_push_event.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/more_than_one_push_event.json
rename to zerver/webhooks/bitbucket/fixtures/more_than_one_push_event.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/pull_request_approved_or_unapproved.json b/zerver/webhooks/bitbucket/fixtures/pull_request_approved_or_unapproved.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/pull_request_approved_or_unapproved.json
rename to zerver/webhooks/bitbucket/fixtures/pull_request_approved_or_unapproved.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/pull_request_comment_action.json b/zerver/webhooks/bitbucket/fixtures/pull_request_comment_action.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/pull_request_comment_action.json
rename to zerver/webhooks/bitbucket/fixtures/pull_request_comment_action.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/pull_request_created_or_updated.json b/zerver/webhooks/bitbucket/fixtures/pull_request_created_or_updated.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/pull_request_created_or_updated.json
rename to zerver/webhooks/bitbucket/fixtures/pull_request_created_or_updated.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/pull_request_created_or_updated_without_username.json b/zerver/webhooks/bitbucket/fixtures/pull_request_created_or_updated_without_username.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/pull_request_created_or_updated_without_username.json
rename to zerver/webhooks/bitbucket/fixtures/pull_request_created_or_updated_without_username.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/pull_request_fulfilled_or_rejected.json b/zerver/webhooks/bitbucket/fixtures/pull_request_fulfilled_or_rejected.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/pull_request_fulfilled_or_rejected.json
rename to zerver/webhooks/bitbucket/fixtures/pull_request_fulfilled_or_rejected.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push.json b/zerver/webhooks/bitbucket/fixtures/push.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push.json
rename to zerver/webhooks/bitbucket/fixtures/push.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push_commits_above_limit.json b/zerver/webhooks/bitbucket/fixtures/push_commits_above_limit.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push_commits_above_limit.json
rename to zerver/webhooks/bitbucket/fixtures/push_commits_above_limit.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push_more_than_one_tag.json b/zerver/webhooks/bitbucket/fixtures/push_more_than_one_tag.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push_more_than_one_tag.json
rename to zerver/webhooks/bitbucket/fixtures/push_more_than_one_tag.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push_multiple_committers.json b/zerver/webhooks/bitbucket/fixtures/push_multiple_committers.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push_multiple_committers.json
rename to zerver/webhooks/bitbucket/fixtures/push_multiple_committers.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push_multiple_committers_with_others.json b/zerver/webhooks/bitbucket/fixtures/push_multiple_committers_with_others.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push_multiple_committers_with_others.json
rename to zerver/webhooks/bitbucket/fixtures/push_multiple_committers_with_others.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push_one_tag.json b/zerver/webhooks/bitbucket/fixtures/push_one_tag.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push_one_tag.json
rename to zerver/webhooks/bitbucket/fixtures/push_one_tag.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push_remove_tag.json b/zerver/webhooks/bitbucket/fixtures/push_remove_tag.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push_remove_tag.json
rename to zerver/webhooks/bitbucket/fixtures/push_remove_tag.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/push_without_changes.json b/zerver/webhooks/bitbucket/fixtures/push_without_changes.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/push_without_changes.json
rename to zerver/webhooks/bitbucket/fixtures/push_without_changes.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/remove_branch.json b/zerver/webhooks/bitbucket/fixtures/remove_branch.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/remove_branch.json
rename to zerver/webhooks/bitbucket/fixtures/remove_branch.json
diff --git a/zerver/webhooks/bitbucket2/fixtures/repo_updated.json b/zerver/webhooks/bitbucket/fixtures/repo_updated.json
similarity index 100%
rename from zerver/webhooks/bitbucket2/fixtures/repo_updated.json
rename to zerver/webhooks/bitbucket/fixtures/repo_updated.json
diff --git a/zerver/webhooks/bitbucket2/tests.py b/zerver/webhooks/bitbucket/tests.py
similarity index 84%
rename from zerver/webhooks/bitbucket2/tests.py
rename to zerver/webhooks/bitbucket/tests.py
index 05c518ac559..6b3a61b61db 100644
--- a/zerver/webhooks/bitbucket2/tests.py
+++ b/zerver/webhooks/bitbucket/tests.py
@@ -5,7 +5,7 @@ from zerver.lib.test_classes import WebhookTestCase
from zerver.lib.test_helpers import HostRequestMock
from zerver.lib.validator import wrap_wild_value
from zerver.models.clients import get_client
-from zerver.webhooks.bitbucket2.view import get_user_info
+from zerver.webhooks.bitbucket.view import get_user_info
TOPIC = "Repository name"
TOPIC_PR_EVENTS = "Repository name / PR #1 new commit"
@@ -13,31 +13,40 @@ TOPIC_ISSUE_EVENTS = "Repository name / issue #1 Bug"
TOPIC_BRANCH_EVENTS = "Repository name / master"
-class Bitbucket2HookTests(WebhookTestCase):
- def test_bitbucket2_on_push_event(self) -> None:
+class BitbucketHookTests(WebhookTestCase):
+ def test_legacy_urls(self) -> None:
+ commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"
+ expected_message = f"Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}"
+
+ legacy_names = ["bitbucket2"]
+ for legacy_name in legacy_names:
+ self.url = self.build_webhook_url(legacy_name=legacy_name)
+ self.check_webhook("push", TOPIC_BRANCH_EVENTS, expected_message)
+
+ def test_push_event(self) -> None:
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"
expected_message = f"Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}"
self.check_webhook("push", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_push_commits_multiple_committers(self) -> None:
+ def test_push_commits_multiple_committers(self) -> None:
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n"
expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by Ben (2) and Tomasz (1).\n\n{commit_info * 2}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_push_commits_multiple_committers_with_others(self) -> None:
+ def test_push_commits_multiple_committers_with_others(self) -> None:
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n"
expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 10 commits to branch master. Commits by Tomasz (4), James (3), Brendon (2) and others (1).\n\n{commit_info * 9}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
self.check_webhook(
"push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message
)
- def test_bitbucket2_on_push_commits_multiple_committers_filtered_by_branches(self) -> None:
+ def test_push_commits_multiple_committers_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches="master,development")
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))\n"
expected_message = f"""Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 3 commits to branch master. Commits by Ben (2) and Tomasz (1).\n\n{commit_info * 2}* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"""
self.check_webhook("push_multiple_committers", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_push_commits_multiple_committers_with_others_filtered_by_branches(
+ def test_push_commits_multiple_committers_with_others_filtered_by_branches(
self,
) -> None:
self.url = self.build_webhook_url(branches="master,development")
@@ -47,74 +56,74 @@ class Bitbucket2HookTests(WebhookTestCase):
"push_multiple_committers_with_others", TOPIC_BRANCH_EVENTS, expected_message
)
- def test_bitbucket2_on_push_event_filtered_by_branches(self) -> None:
+ def test_push_event_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches="master,development")
commit_info = "* first commit ([84b96adc644](https://bitbucket.org/kolaszek/repository-name/commits/84b96adc644a30fd6465b3d196369d880762afed))"
expected_message = f"Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) 1 commit to branch master.\n\n{commit_info}"
self.check_webhook("push", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_push_commits_above_limit_event(self) -> None:
+ def test_push_commits_above_limit_event(self) -> None:
commit_info = "* a ([6f161a7bced](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n"
expected_message = f"Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master.\n\n{(commit_info * 5)}[and more commit(s)]"
self.check_webhook("push_commits_above_limit", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_push_commits_above_limit_filtered_by_branches(self) -> None:
+ def test_push_commits_above_limit_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches="master,development")
commit_info = "* a ([6f161a7bced](https://bitbucket.org/kolaszek/repository-name/commits/6f161a7bced94430ac8947d87dbf45c6deee3fb0))\n"
expected_message = f"Tomasz [pushed](https://bitbucket.org/kolaszek/repository-name/branches/compare/6f161a7bced94430ac8947d87dbf45c6deee3fb0..1221f2fda6f1e3654b09f1f3a08390e4cb25bb48) 5 commits to branch master.\n\n{(commit_info * 5)}[and more commit(s)]"
self.check_webhook("push_commits_above_limit", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_force_push_event(self) -> None:
+ def test_force_push_event(self) -> None:
expected_message = "Tomasz [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12."
self.check_webhook("force_push", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_force_push_event_filtered_by_branches(self) -> None:
+ def test_force_push_event_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches="master,development")
expected_message = "Tomasz [force pushed](https://bitbucket.org/kolaszek/repository-name/branch/master) to branch master. Head is now 25f93d22b719e2d678a7ad5ee0ef0d1fcdf39c12."
self.check_webhook("force_push", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_remove_branch_event(self) -> None:
+ def test_remove_branch_event(self) -> None:
expected_message = "Tomasz deleted branch master."
self.check_webhook("remove_branch", TOPIC_BRANCH_EVENTS, expected_message)
- def test_bitbucket2_on_fork_event(self) -> None:
+ def test_fork_event(self) -> None:
expected_message = "Tomasz forked the repository into [kolaszek/repository-name2](https://bitbucket.org/kolaszek/repository-name2)."
self.check_webhook("fork", TOPIC, expected_message)
- def test_bitbucket2_on_commit_comment_created_event(self) -> None:
+ def test_commit_comment_created_event(self) -> None:
expected_message = "Tomasz [commented](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74#comment-3354963) on [32c4ea19aa3](https://bitbucket.org/kolaszek/repository-name/commits/32c4ea19aa3af10acd08e419e2c354941a365d74):\n~~~ quote\nNice fix!\n~~~"
self.check_webhook("commit_comment_created", TOPIC, expected_message)
- def test_bitbucket2_on_commit_status_changed_event(self) -> None:
+ def test_commit_status_changed_event(self) -> None:
expected_message = "[System mybuildtool](https://my-build-tool.com/builds/MY-PROJECT/BUILD-777) changed status of [9fec847784a](https://bitbucket.org/kolaszek/repository-name/commits/9fec847784abb10b2fa567ee63b85bd238955d0e) to SUCCESSFUL."
self.check_webhook("commit_status_changed", TOPIC, expected_message)
- def test_bitbucket2_on_issue_created_event(self) -> None:
+ def test_issue_created_event(self) -> None:
expected_message = "Tomasz created [issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to Tomasz):\n\n~~~ quote\nSuch a bug\n~~~"
self.check_webhook("issue_created", TOPIC_ISSUE_EVENTS, expected_message)
- def test_bitbucket2_on_issue_created_with_custom_topic_in_url(self) -> None:
+ def test_issue_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
expected_topic_name = "notifications"
expected_message = "Tomasz created [issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug) (assigned to Tomasz):\n\n~~~ quote\nSuch a bug\n~~~"
self.check_webhook("issue_created", expected_topic_name, expected_message)
- def test_bitbucket2_on_issue_updated_event(self) -> None:
+ def test_issue_updated_event(self) -> None:
expected_message = "Tomasz updated [issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
self.check_webhook("issue_updated", TOPIC_ISSUE_EVENTS, expected_message)
- def test_bitbucket2_on_issue_commented_event(self) -> None:
+ def test_issue_commented_event(self) -> None:
expected_message = "Tomasz [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [issue #1](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
self.check_webhook("issue_commented", TOPIC_ISSUE_EVENTS, expected_message)
- def test_bitbucket2_on_issue_commented_with_custom_topic_in_url(self) -> None:
+ def test_issue_commented_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
expected_topic_name = "notifications"
expected_message = "Tomasz [commented](https://bitbucket.org/kolaszek/repository-name/issues/2#comment-28973596) on [issue #1 Bug](https://bitbucket.org/kolaszek/repository-name/issues/2/bug)."
self.check_webhook("issue_commented", expected_topic_name, expected_message)
- def test_bitbucket2_on_pull_request_created_event(self) -> None:
+ def test_pull_request_created_event(self) -> None:
expected_message = "Tomasz created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) from `new-branch` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription\n~~~"
self.check_webhook(
"pull_request_created_or_updated",
@@ -123,7 +132,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:created",
)
- def test_bitbucket2_on_pull_request_created_without_reviewer_username_event(self) -> None:
+ def test_pull_request_created_without_reviewer_username_event(self) -> None:
expected_message = "Tomasz created [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) from `new-branch` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription\n~~~"
self.check_webhook(
"pull_request_created_or_updated_without_username",
@@ -132,7 +141,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:created",
)
- def test_bitbucket2_on_pull_request_created_with_custom_topic_in_url(self) -> None:
+ def test_pull_request_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
expected_topic_name = "notifications"
expected_message = "Tomasz created [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) from `new-branch` to `master` (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription\n~~~"
@@ -143,7 +152,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:created",
)
- def test_bitbucket2_on_pull_request_updated_event(self) -> None:
+ def test_pull_request_updated_event(self) -> None:
expected_message = "Tomasz updated [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) (assigned to Tomasz Kolek):\n\n~~~ quote\ndescription\n~~~"
self.check_webhook(
"pull_request_created_or_updated",
@@ -152,7 +161,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:updated",
)
- def test_bitbucket2_on_pull_request_approved_event(self) -> None:
+ def test_pull_request_approved_event(self) -> None:
expected_message = "Tomasz approved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
self.check_webhook(
"pull_request_approved_or_unapproved",
@@ -161,7 +170,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:approved",
)
- def test_bitbucket2_on_pull_request_approved_with_custom_topic_in_url(self) -> None:
+ def test_pull_request_approved_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
expected_topic_name = "notifications"
expected_message = "Tomasz approved [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
@@ -172,7 +181,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:approved",
)
- def test_bitbucket2_on_pull_request_unapproved_event(self) -> None:
+ def test_pull_request_unapproved_event(self) -> None:
expected_message = "Tomasz unapproved [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
self.check_webhook(
"pull_request_approved_or_unapproved",
@@ -181,7 +190,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:unapproved",
)
- def test_bitbucket2_on_pull_request_declined_event(self) -> None:
+ def test_pull_request_declined_event(self) -> None:
expected_message = "Tomasz rejected [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1)."
self.check_webhook(
"pull_request_fulfilled_or_rejected",
@@ -190,7 +199,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:rejected",
)
- def test_bitbucket2_on_pull_request_fulfilled_event(self) -> None:
+ def test_pull_request_fulfilled_event(self) -> None:
expected_message = "Tomasz merged [PR #1](https://bitbucket.org/kolaszek/repository-name/pull-requests/1) from `new-branch` to `master`."
self.check_webhook(
"pull_request_fulfilled_or_rejected",
@@ -199,7 +208,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:fulfilled",
)
- def test_bitbucket2_on_pull_request_comment_created_event(self) -> None:
+ def test_pull_request_comment_created_event(self) -> None:
expected_message = "Tomasz [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~~~"
self.check_webhook(
"pull_request_comment_action",
@@ -208,7 +217,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:comment_created",
)
- def test_bitbucket2_on_pull_request_comment_created_with_custom_topic_in_url(self) -> None:
+ def test_pull_request_comment_created_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
expected_topic_name = "notifications"
expected_message = "Tomasz [commented](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~"
@@ -219,7 +228,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:comment_created",
)
- def test_bitbucket2_on_pull_request_comment_updated_event(self) -> None:
+ def test_pull_request_comment_updated_event(self) -> None:
expected_message = "Tomasz updated a [comment](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~~~"
self.check_webhook(
"pull_request_comment_action",
@@ -228,7 +237,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:comment_updated",
)
- def test_bitbucket2_on_pull_request_comment_updated_with_custom_topic_in_url(self) -> None:
+ def test_pull_request_comment_updated_with_custom_topic_in_url(self) -> None:
self.url = self.build_webhook_url(topic="notifications")
expected_topic_name = "notifications"
expected_message = "Tomasz updated a [comment](https://bitbucket.org/kolaszek/repository-name/pull-requests/3/_/diff#comment-20576503) on [PR #1 new commit](https://bitbucket.org/kolaszek/repository-name/pull-requests/3):\n\n~~~ quote\nComment1\n~~~"
@@ -239,7 +248,7 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:comment_updated",
)
- def test_bitbucket2_on_pull_request_comment_deleted_event(self) -> None:
+ def test_pull_request_comment_deleted_event(self) -> None:
expected_message = "Tomasz deleted a [comment](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~~~"
self.check_webhook(
"pull_request_comment_action",
@@ -248,14 +257,14 @@ class Bitbucket2HookTests(WebhookTestCase):
HTTP_X_EVENT_KEY="pullrequest:comment_deleted",
)
- def test_bitbucket2_on_repo_updated_event(self) -> None:
+ def test_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.**"
expected_topic_name = "new-name"
self.check_webhook(
"repo_updated", expected_topic_name, expected_message, HTTP_X_EVENT_KEY="repo:updated"
)
- def test_bitbucket2_on_push_one_tag_event(self) -> None:
+ def test_push_one_tag_event(self) -> None:
expected_message = (
"Tomasz pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
)
@@ -263,7 +272,7 @@ class Bitbucket2HookTests(WebhookTestCase):
"push_one_tag", TOPIC, expected_message, HTTP_X_EVENT_KEY="pullrequest:push"
)
- def test_bitbucket2_on_push_remove_tag_event(self) -> None:
+ def test_push_remove_tag_event(self) -> None:
expected_message = (
"Tomasz removed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
)
@@ -271,7 +280,7 @@ class Bitbucket2HookTests(WebhookTestCase):
"push_remove_tag", TOPIC, expected_message, HTTP_X_EVENT_KEY="pullrequest:push"
)
- def test_bitbucket2_on_push_more_than_one_tag_event(self) -> None:
+ def test_push_more_than_one_tag_event(self) -> None:
expected_message = "Tomasz pushed tag [{name}](https://bitbucket.org/kolaszek/repository-name/commits/tag/{name})."
self.subscribe(self.test_user, self.channel_name)
@@ -301,7 +310,7 @@ class Bitbucket2HookTests(WebhookTestCase):
content=expected_message.format(name="b"),
)
- def test_bitbucket2_on_more_than_one_push_event(self) -> None:
+ def test_more_than_one_push_event(self) -> None:
self.subscribe(self.test_user, self.channel_name)
payload = self.get_body("more_than_one_push_event")
@@ -329,7 +338,7 @@ class Bitbucket2HookTests(WebhookTestCase):
content="Tomasz pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a).",
)
- def test_bitbucket2_on_more_than_one_push_event_filtered_by_branches(self) -> None:
+ def test_more_than_one_push_event_filtered_by_branches(self) -> None:
self.url = self.build_webhook_url(branches="master,development")
self.subscribe(self.test_user, self.channel_name)
@@ -359,7 +368,7 @@ class Bitbucket2HookTests(WebhookTestCase):
content="Tomasz pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a).",
)
- def test_bitbucket2_on_more_than_one_push_event_filtered_by_branches_ignore(self) -> None:
+ def test_more_than_one_push_event_filtered_by_branches_ignore(self) -> None:
self.url = self.build_webhook_url(branches="changes,development")
expected_message = (
"Tomasz pushed tag [a](https://bitbucket.org/kolaszek/repository-name/commits/tag/a)."
@@ -368,8 +377,8 @@ class Bitbucket2HookTests(WebhookTestCase):
"more_than_one_push_event", TOPIC, expected_message, HTTP_X_EVENT_KEY="pullrequest:push"
)
- @patch("zerver.webhooks.bitbucket2.view.check_send_webhook_message")
- def test_bitbucket2_on_push_event_filtered_by_branches_ignore(
+ @patch("zerver.webhooks.bitbucket.view.check_send_webhook_message")
+ def test_push_event_filtered_by_branches_ignore(
self, check_send_webhook_message_mock: MagicMock
) -> None:
self.url = self.build_webhook_url(branches="changes,development")
@@ -378,8 +387,8 @@ class Bitbucket2HookTests(WebhookTestCase):
self.assertFalse(check_send_webhook_message_mock.called)
self.assert_json_success(result)
- @patch("zerver.webhooks.bitbucket2.view.check_send_webhook_message")
- def test_bitbucket2_on_push_commits_above_limit_filtered_by_branches_ignore(
+ @patch("zerver.webhooks.bitbucket.view.check_send_webhook_message")
+ def test_push_commits_above_limit_filtered_by_branches_ignore(
self, check_send_webhook_message_mock: MagicMock
) -> None:
self.url = self.build_webhook_url(branches="changes,development")
@@ -388,8 +397,8 @@ class Bitbucket2HookTests(WebhookTestCase):
self.assertFalse(check_send_webhook_message_mock.called)
self.assert_json_success(result)
- @patch("zerver.webhooks.bitbucket2.view.check_send_webhook_message")
- def test_bitbucket2_on_force_push_event_filtered_by_branches_ignore(
+ @patch("zerver.webhooks.bitbucket.view.check_send_webhook_message")
+ def test_force_push_event_filtered_by_branches_ignore(
self, check_send_webhook_message_mock: MagicMock
) -> None:
self.url = self.build_webhook_url(branches="changes,development")
@@ -398,8 +407,8 @@ class Bitbucket2HookTests(WebhookTestCase):
self.assertFalse(check_send_webhook_message_mock.called)
self.assert_json_success(result)
- @patch("zerver.webhooks.bitbucket2.view.check_send_webhook_message")
- def test_bitbucket2_on_push_multiple_committers_filtered_by_branches_ignore(
+ @patch("zerver.webhooks.bitbucket.view.check_send_webhook_message")
+ def test_push_multiple_committers_filtered_by_branches_ignore(
self, check_send_webhook_message_mock: MagicMock
) -> None:
self.url = self.build_webhook_url(branches="changes,development")
@@ -408,8 +417,8 @@ class Bitbucket2HookTests(WebhookTestCase):
self.assertFalse(check_send_webhook_message_mock.called)
self.assert_json_success(result)
- @patch("zerver.webhooks.bitbucket2.view.check_send_webhook_message")
- def test_bitbucket2_on_push_multiple_committers_with_others_filtered_by_branches_ignore(
+ @patch("zerver.webhooks.bitbucket.view.check_send_webhook_message")
+ def test_push_multiple_committers_with_others_filtered_by_branches_ignore(
self, check_send_webhook_message_mock: MagicMock
) -> None:
self.url = self.build_webhook_url(branches="changes,development")
@@ -418,10 +427,8 @@ class Bitbucket2HookTests(WebhookTestCase):
self.assertFalse(check_send_webhook_message_mock.called)
self.assert_json_success(result)
- @patch("zerver.webhooks.bitbucket2.view.check_send_webhook_message")
- def test_bitbucket2_on_push_without_changes_ignore(
- self, check_send_webhook_message_mock: MagicMock
- ) -> None:
+ @patch("zerver.webhooks.bitbucket.view.check_send_webhook_message")
+ def test_push_without_changes_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:
payload = self.get_body("push_without_changes")
result = self.client_post(self.url, payload, content_type="application/json")
self.assertFalse(check_send_webhook_message_mock.called)
diff --git a/zerver/webhooks/bitbucket2/view.py b/zerver/webhooks/bitbucket/view.py
similarity index 99%
rename from zerver/webhooks/bitbucket2/view.py
rename to zerver/webhooks/bitbucket/view.py
index ba96ba7ddb9..30fd56298db 100644
--- a/zerver/webhooks/bitbucket2/view.py
+++ b/zerver/webhooks/bitbucket/view.py
@@ -79,7 +79,7 @@ ALL_EVENT_TYPES = [
@webhook_view("Bitbucket2", all_event_types=ALL_EVENT_TYPES)
@typed_endpoint
-def api_bitbucket2_webhook(
+def api_bitbucket_webhook(
request: HttpRequest,
user_profile: UserProfile,
*,