2018-08-18 18:46:01 +02:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2018-08-18 18:46:01 +02:00
|
|
|
class NetlifyHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "netlify"
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/netlify?stream={stream}&api_key={api_key}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "netlify"
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_building_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "master"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now building."
|
2018-08-18 18:46:01 +02:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"deploy_building",
|
|
|
|
expected_topic_name,
|
|
|
|
expected_message,
|
|
|
|
content_type="application/json",
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_created_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "master"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) on branch master is now ready."
|
2018-08-18 18:46:01 +02:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"deploy_created", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_failed_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "master"
|
2021-02-12 08:19:30 +01:00
|
|
|
expected_message = (
|
|
|
|
"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) "
|
|
|
|
"on branch master failed during stage 'building site': Build script returned non-zero exit code: 127"
|
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"deploy_failed", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_locked_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "master"
|
2021-02-12 08:19:30 +01:00
|
|
|
expected_message = (
|
|
|
|
"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) "
|
|
|
|
"on branch master is now locked."
|
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"deploy_locked", expected_topic_name, expected_message, content_type="application/json"
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_unlocked_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "master"
|
2021-02-12 08:19:30 +01:00
|
|
|
expected_message = (
|
|
|
|
"The build [objective-jepsen-35fbb2](http://objective-jepsen-35fbb2.netlify.com) "
|
|
|
|
"on branch master is now unlocked."
|
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-17 15:53:30 +01:00
|
|
|
"deploy_unlocked",
|
|
|
|
expected_topic_name,
|
|
|
|
expected_message,
|
|
|
|
content_type="application/json",
|
2020-08-23 15:49:24 +02:00
|
|
|
)
|