2016-12-04 02:50:29 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Text
|
2017-11-16 00:43:10 +01:00
|
|
|
|
2016-12-04 02:50:29 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
|
|
|
class MentionHookTests(WebhookTestCase):
|
|
|
|
STREAM_NAME = 'test'
|
|
|
|
URL_TEMPLATE = "/api/v1/external/mention?api_key={api_key}&stream={stream}"
|
|
|
|
FIXTURE_DIR_NAME = 'mention'
|
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def test_mention_webfeed(self) -> None:
|
2016-12-04 02:50:29 +01:00
|
|
|
expected_topic = u"news"
|
|
|
|
expected_message = (u"**[Historical Sexual Abuse (Football): 29 Nov 2016: House of Commons debates - TheyWorkForYou]"
|
|
|
|
u"(https://www.theyworkforyou.com/debates/?id=2016-11-29b.1398.7&p=24887)**:\n"
|
|
|
|
u"\u2026 Culture, Media and Sport\nNothing is more important than keeping children safe."
|
|
|
|
u" Child sex abuse is an exceptionally vile crime, and all of Government take it very seriously indeed,"
|
|
|
|
u" as I know this House does.\nChildren up and down the country are \u2026"
|
|
|
|
)
|
|
|
|
|
|
|
|
# use fixture named mention_webfeeds
|
|
|
|
self.send_and_test_stream_message('webfeeds', expected_topic, expected_message,
|
2016-12-11 14:30:45 +01:00
|
|
|
content_type="application/x-www-form-urlencoded")
|
2016-12-04 02:50:29 +01:00
|
|
|
|
2017-11-04 07:47:46 +01:00
|
|
|
def get_body(self, fixture_name: Text) -> Text:
|
2018-04-20 03:57:21 +02:00
|
|
|
return self.webhook_fixture_data("mention", fixture_name, file_type="json")
|