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):
|
2021-02-12 08:20:45 +01:00
|
|
|
STREAM_NAME = "netlify"
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/netlify?stream={stream}&api_key={api_key}"
|
2019-07-04 21:00:56 +02:00
|
|
|
FIXTURE_DIR_NAME = "netlify"
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_building_message(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "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(
|
|
|
|
"deploy_building", expected_topic, expected_message, content_type="application/json"
|
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_created_message(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "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(
|
|
|
|
"deploy_created", expected_topic, expected_message, content_type="application/json"
|
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_failed_message(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "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(
|
|
|
|
"deploy_failed", expected_topic, expected_message, content_type="application/json"
|
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_locked_message(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "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(
|
|
|
|
"deploy_locked", expected_topic, expected_message, content_type="application/json"
|
|
|
|
)
|
2018-08-18 18:46:01 +02:00
|
|
|
|
|
|
|
def test_unlocked_message(self) -> None:
|
2020-04-09 21:51:58 +02:00
|
|
|
expected_topic = "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(
|
|
|
|
"deploy_unlocked", expected_topic, expected_message, content_type="application/json"
|
|
|
|
)
|