2023-10-12 19:43:45 +02:00
|
|
|
from typing_extensions import override
|
|
|
|
|
2016-11-10 19:30:09 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2016-09-20 22:51:11 +02:00
|
|
|
class TransifexHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "transifex"
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/transifex?stream={stream}&api_key={api_key}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "transifex"
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2021-02-12 08:20:45 +01:00
|
|
|
PROJECT = "project-title"
|
|
|
|
LANGUAGE = "en"
|
|
|
|
RESOURCE = "file"
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_transifex_reviewed_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = f"{self.PROJECT} in {self.LANGUAGE}"
|
2020-06-09 00:25:09 +02:00
|
|
|
expected_message = f"Resource {self.RESOURCE} fully reviewed."
|
2017-04-21 23:35:40 +02:00
|
|
|
self.url = self.build_webhook_url(
|
2023-10-06 00:18:50 +02:00
|
|
|
event="review_completed",
|
|
|
|
reviewed="100",
|
2017-04-21 23:35:40 +02:00
|
|
|
project=self.PROJECT,
|
|
|
|
language=self.LANGUAGE,
|
|
|
|
resource=self.RESOURCE,
|
|
|
|
)
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("", expected_topic_name, expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_transifex_translated_message(self) -> None:
|
2024-01-17 15:53:30 +01:00
|
|
|
expected_topic_name = f"{self.PROJECT} in {self.LANGUAGE}"
|
2020-06-09 00:25:09 +02:00
|
|
|
expected_message = f"Resource {self.RESOURCE} fully translated."
|
2017-04-21 23:35:40 +02:00
|
|
|
self.url = self.build_webhook_url(
|
2023-10-06 00:18:50 +02:00
|
|
|
event="translation_completed",
|
|
|
|
translated="100",
|
2016-09-20 22:51:11 +02:00
|
|
|
project=self.PROJECT,
|
|
|
|
language=self.LANGUAGE,
|
|
|
|
resource=self.RESOURCE,
|
|
|
|
)
|
2024-01-17 15:53:30 +01:00
|
|
|
self.check_webhook("", expected_topic_name, expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2023-10-12 19:43:45 +02:00
|
|
|
@override
|
2024-07-12 02:30:17 +02:00
|
|
|
def get_payload(self, fixture_name: str) -> dict[str, str]:
|
2016-09-20 22:51:11 +02:00
|
|
|
return {}
|