snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
This commit is contained in:
58
zerver/webhooks/teamcity/tests.py
Normal file
58
zerver/webhooks/teamcity/tests.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import orjson
|
||||
|
||||
from zerver.lib.send_email import FromAddress
|
||||
from zerver.lib.test_classes import WebhookTestCase
|
||||
from zerver.models import Recipient
|
||||
from zerver.models.realms import get_realm
|
||||
from zerver.models.users import get_user_by_delivery_email
|
||||
from zerver.webhooks.teamcity.view import MISCONFIGURED_PAYLOAD_TYPE_ERROR_MESSAGE
|
||||
|
||||
|
||||
class TeamCityHookTests(WebhookTestCase):
|
||||
TOPIC_NAME = "Project :: Compile"
|
||||
|
||||
def test_teamcity_success(self) -> None:
|
||||
expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
|
||||
self.check_webhook("success", self.TOPIC_NAME, expected_message)
|
||||
|
||||
def test_teamcity_success_branch(self) -> None:
|
||||
expected_message = "Project :: Compile build 5535 - CL 123456 was successful! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
|
||||
expected_topic_name = "Project :: Compile (MyBranch)"
|
||||
self.check_webhook("success_branch", expected_topic_name, expected_message)
|
||||
|
||||
def test_teamcity_broken(self) -> None:
|
||||
expected_message = "Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
|
||||
self.check_webhook("broken", self.TOPIC_NAME, expected_message)
|
||||
|
||||
def test_teamcity_failure(self) -> None:
|
||||
expected_message = "Project :: Compile build 5535 - CL 123456 is still broken with status Exit code 1! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
|
||||
self.check_webhook("failure", self.TOPIC_NAME, expected_message)
|
||||
|
||||
def test_teamcity_fixed(self) -> None:
|
||||
expected_message = "Project :: Compile build 5535 - CL 123456 has been fixed! :thumbs_up: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
|
||||
self.check_webhook("fixed", self.TOPIC_NAME, expected_message)
|
||||
|
||||
def test_teamcity_personal(self) -> None:
|
||||
expected_message = "Your personal build for Project :: Compile build 5535 - CL 123456 is broken with status Exit code 1 (new)! :thumbs_down: See [changes](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952&tab=buildChangesDiv) and [build log](http://teamcity/viewLog.html?buildTypeId=Project_Compile&buildId=19952)."
|
||||
payload = orjson.dumps(
|
||||
orjson.loads(self.webhook_fixture_data(self.webhook_dir_name, "personal"))
|
||||
)
|
||||
self.client_post(self.url, payload, content_type="application/json")
|
||||
msg = self.get_last_message()
|
||||
|
||||
self.assertEqual(msg.content, expected_message)
|
||||
self.assertEqual(msg.recipient.type, Recipient.DIRECT_MESSAGE_GROUP)
|
||||
|
||||
def test_non_generic_payload_ignore_pm_notification(self) -> None:
|
||||
expected_message = MISCONFIGURED_PAYLOAD_TYPE_ERROR_MESSAGE.format(
|
||||
bot_name=get_user_by_delivery_email(
|
||||
"webhook-bot@zulip.com", get_realm("zulip")
|
||||
).full_name,
|
||||
support_email=FromAddress.SUPPORT,
|
||||
).strip()
|
||||
payload = self.get_body("slack_non_generic_payload")
|
||||
self.client_post(self.url, payload, content_type="application/json")
|
||||
msg = self.get_last_message()
|
||||
|
||||
self.assertEqual(msg.content, expected_message)
|
||||
self.assertEqual(msg.recipient.type, Recipient.DIRECT_MESSAGE_GROUP)
|
||||
Reference in New Issue
Block a user