2020-08-20 17:03:43 +02:00
|
|
|
from typing import Dict
|
2017-11-16 00:43:10 +01:00
|
|
|
|
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):
|
2021-02-12 08:20:45 +01:00
|
|
|
STREAM_NAME = "transifex"
|
2020-04-09 21:51:58 +02:00
|
|
|
URL_TEMPLATE = "/api/v1/external/transifex?stream={stream}&api_key={api_key}"
|
2016-09-20 22:51:11 +02:00
|
|
|
URL_REVIEWED_METHOD_TEMPLATE = "reviewed=100"
|
|
|
|
URL_TRANSLATED_METHOD_TEMPLATE = "translated=100"
|
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:
|
2020-06-09 00:25:09 +02:00
|
|
|
expected_topic = f"{self.PROJECT} in {self.LANGUAGE}"
|
|
|
|
expected_message = f"Resource {self.RESOURCE} fully reviewed."
|
2017-04-21 23:35:40 +02:00
|
|
|
self.url = self.build_webhook_url(
|
|
|
|
self.URL_REVIEWED_METHOD_TEMPLATE,
|
|
|
|
project=self.PROJECT,
|
|
|
|
language=self.LANGUAGE,
|
|
|
|
resource=self.RESOURCE,
|
|
|
|
)
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook("", expected_topic, 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:
|
2020-06-09 00:25:09 +02:00
|
|
|
expected_topic = f"{self.PROJECT} in {self.LANGUAGE}"
|
|
|
|
expected_message = f"Resource {self.RESOURCE} fully translated."
|
2017-04-21 23:35:40 +02:00
|
|
|
self.url = self.build_webhook_url(
|
|
|
|
self.URL_TRANSLATED_METHOD_TEMPLATE,
|
2016-09-20 22:51:11 +02:00
|
|
|
project=self.PROJECT,
|
|
|
|
language=self.LANGUAGE,
|
|
|
|
resource=self.RESOURCE,
|
|
|
|
)
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook("", expected_topic, expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2020-08-20 17:03:43 +02:00
|
|
|
def get_payload(self, fixture_name: str) -> Dict[str, str]:
|
2016-09-20 22:51:11 +02:00
|
|
|
return {}
|