Files
upstream-zulip/zerver/webhooks/pagerduty/tests.py
upstream-mirror 64898b2c79
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
snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
2026-09-15 15:05:30 +05:00

56 lines
3.9 KiB
Python

from zerver.lib.test_classes import WebhookTestCase
class PagerDutyHookTests(WebhookTestCase):
V2_TOPIC = "Incident My new incident (#33)"
def test_trigger_v2(self) -> None:
expected_message = "Incident [My new incident (#33)](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV))."
self.check_webhook("trigger_v2", self.V2_TOPIC, expected_message)
def test_triggerer_v3(self) -> None:
expected_message = "Incident [Test Incident 3 (#9)](https://pig208.pagerduty.com/incidents/PFQZPSY) triggered by [pig208](https://pig208.pagerduty.com/services/PA2P440) (assigned to [PIG 208](https://pig208.pagerduty.com/users/PJ0LVEB))."
self.check_webhook("triggered_v3", "Incident Test Incident 3 (#9)", expected_message)
def test_trigger_without_assignee_v2(self) -> None:
expected_message = "Incident [My new incident (#33)](https://webdemo.pagerduty.com/incidents/PRORDTY) triggered by [Production XDB Cluster](https://webdemo.pagerduty.com/services/PN49J75) (assigned to nobody)."
self.check_webhook("trigger_without_assignee_v2", self.V2_TOPIC, expected_message)
def test_unacknowledged_v3(self) -> None:
expected_message = "Incident [Test Incident (#10)](https://pig208.pagerduty.com/incidents/PQ1K5C8) unacknowledged by [pig208](https://pig208.pagerduty.com/services/PA2P440) (assigned to [PIG 208](https://pig208.pagerduty.com/users/PJ0LVEB))."
self.check_webhook("unacknowledged_v3", "Incident Test Incident (#10)", expected_message)
def test_resolved_v2(self) -> None:
expected_message = "Incident [My new incident (#33)](https://webdemo.pagerduty.com/incidents/PRORDTY) resolved by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV)."
self.check_webhook("resolve_v2", self.V2_TOPIC, expected_message)
def test_resolved_v3(self) -> None:
expected_message = "Incident [Test Incident (#6)](https://pig208.pagerduty.com/incidents/PCPZE64) resolved by [PIG 208](https://pig208.pagerduty.com/users/PJ0LVEB)."
self.check_webhook("resolved_v3", "Incident Test Incident (#6)", expected_message)
def test_acknowledged_v3(self) -> None:
expected_message = "Incident [Test Incident (#10)](https://pig208.pagerduty.com/incidents/PQ1K5C8) acknowledged by [PIG 208](https://pig208.pagerduty.com/users/PJ0LVEB)."
self.check_webhook("acknowledged_v3", "Incident Test Incident (#10)", expected_message)
def test_acknowledge_v2(self) -> None:
expected_message = "Incident [My new incident (#33)](https://webdemo.pagerduty.com/incidents/PRORDTY) acknowledged by [Laura Haley](https://webdemo.pagerduty.com/users/P553OPV)."
self.check_webhook("acknowledge_v2", self.V2_TOPIC, expected_message)
def test_incident_assigned_v2(self) -> None:
expected_message = "Incident [My new incident (#33)](https://webdemo.pagerduty.com/incidents/PRORDTY) assigned to [Wiley Jacobson](https://webdemo.pagerduty.com/users/PFBSJ2Z)."
self.check_webhook("assign_v2", self.V2_TOPIC, expected_message)
def test_reassigned_v3(self) -> None:
expected_message = "Incident [Test Incident (#3)](https://pig208.pagerduty.com/incidents/PIQUG8X) reassigned to [Test User](https://pig208.pagerduty.com/users/PI9DT01)."
self.check_webhook("reassigned_v3", "Incident Test Incident (#3)", expected_message)
def test_unsupported_webhook_event(self) -> None:
for version in range(2, 4):
payload = self.get_body(f"unsupported_v{version}")
result = self.client_post(self.url, payload, content_type="application/json")
self.assert_json_success(result)
self.assert_in_response(
"The 'incident.unsupported' event isn't currently supported by the PagerDuty webhook; ignoring",
result,
)