2018-11-01 20:56:22 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class ReviewBoardHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "reviewboard"
|
2021-02-12 08:20:45 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/reviewboard?&api_key={api_key}&stream={stream}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "reviewboard"
|
2018-11-01 20:56:22 +01:00
|
|
|
|
|
|
|
def test_review_request_published(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Scheduler"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```"
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("review_request_published", expected_topic_name, expected_message)
|
2018-11-01 20:56:22 +01:00
|
|
|
|
|
|
|
def test_review_request_published_with_multiple_target_people(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Scheduler"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "**eeshangarg** opened [#2: Initial commit](https://rbcommons.com/s/zulip/r/2/):\n\n``` quote\n**Description**: Initial commit\n**Status**: pending\n**Target people**: **drsbgarg**, **johndoe**, and **janedoe**\n**Branch**: master\n```"
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
|
|
|
"review_request_published__with_multiple_target_people",
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name,
|
2020-08-23 15:49:24 +02:00
|
|
|
expected_message,
|
|
|
|
)
|
2018-11-01 20:56:22 +01:00
|
|
|
|
|
|
|
def test_review_request_reopened(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Scheduler"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "**eeshangarg** reopened [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: pending\n**Target people**: **drsbgarg**\n**Branch**: master\n```"
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("review_request_reopened", expected_topic_name, expected_message)
|
2018-11-01 20:56:22 +01:00
|
|
|
|
|
|
|
def test_review_request_closed(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Scheduler"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "**eeshangarg** closed [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n``` quote\n**Description**: Initial commit (first iteration)\n**Status**: submitted\n**Target people**: **drsbgarg**\n**Close type**: submitted\n**Branch**: master\n```"
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("review_request_closed", expected_topic_name, expected_message)
|
2018-11-01 20:56:22 +01:00
|
|
|
|
|
|
|
def test_review_published(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Scheduler"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "**eeshangarg** [reviewed](https://rbcommons.com/s/zulip/r/1/#review651728) [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/r/1/):\n\n**Review**:\n``` quote\nLeft some minor comments, thanks!\n```"
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("review_published", expected_topic_name, expected_message)
|
2018-11-01 20:56:22 +01:00
|
|
|
|
|
|
|
def test_reply_published(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = "Scheduler"
|
2021-02-12 08:20:45 +01:00
|
|
|
expected_message = "**drsbgarg** [replied](https://rbcommons.com/s/zulip/api/review-requests/1/reviews/651728/replies/651732/) to [#1: Initial commit (first iteration)](https://rbcommons.com/s/zulip/api/review-requests/1/):\n\n**Reply**:\n``` quote\n\n```"
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("reply_published", expected_topic_name, expected_message)
|