2016-09-20 22:51:11 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-05-10 19:34:01 +02:00
|
|
|
from typing import Any, 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):
|
|
|
|
STREAM_NAME = 'transifex'
|
2017-04-21 23:35:40 +02:00
|
|
|
URL_TEMPLATE = u"/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"
|
|
|
|
FIXTURE_DIR_NAME = 'transifex'
|
|
|
|
|
|
|
|
PROJECT = 'project-title'
|
|
|
|
LANGUAGE = 'en'
|
|
|
|
RESOURCE = 'file'
|
|
|
|
REVIEWED = True
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_transifex_reviewed_message(self) -> None:
|
2016-09-20 22:51:11 +02:00
|
|
|
self.REVIEWED = True
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "{} in {}".format(self.PROJECT, self.LANGUAGE)
|
2016-09-20 22:51:11 +02:00
|
|
|
expected_message = "Resource {} fully reviewed.".format(self.RESOURCE)
|
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,
|
|
|
|
)
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message("", 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:
|
2016-09-20 22:51:11 +02:00
|
|
|
self.REVIEWED = False
|
2018-11-09 20:33:58 +01:00
|
|
|
expected_topic = "{} in {}".format(self.PROJECT, self.LANGUAGE)
|
2016-09-20 22:51:11 +02:00
|
|
|
expected_message = "Resource {} fully translated.".format(self.RESOURCE)
|
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,
|
|
|
|
)
|
2018-11-09 20:33:58 +01:00
|
|
|
self.send_and_test_stream_message("", expected_topic, expected_message)
|
2016-09-20 22:51:11 +02:00
|
|
|
|
2018-05-10 19:34:01 +02:00
|
|
|
def get_body(self, fixture_name: str) -> Dict[str, Any]:
|
2016-09-20 22:51:11 +02:00
|
|
|
return {}
|