Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

1.5 KB
Raw Blame
from typing_extensions import override

from zerver.lib.test_classes import WebhookTestCase


class ZenDeskHookTests(WebhookTestCase):
    @override
    def get_payload(self, fixture_name: str) -> dict[str, str]:
        return {
            "ticket_title": self.TICKET_TITLE,
            "ticket_id": str(self.TICKET_ID),
            "message": self.MESSAGE,
            "stream": self.channel_name,
        }

    def do_test(self, expected_topic: str, expected_message: str) -> None:
        self.api_channel_message(
            self.test_user,
            "",
            expected_topic,
            expected_message,
            content_type=None,
        )

    def test_short_topic(self) -> None:
        self.TICKET_ID = 4
        self.TICKET_TITLE = "Test ticket"
        self.MESSAGE = "some message"
        self.do_test(
            expected_topic="#4: Test ticket",
            expected_message="some message",
        )

    def test_long_subject(self) -> None:
        self.TICKET_ID = 4
        self.TICKET_TITLE = "Test ticket" + "!" * 80
        self.MESSAGE = "some message"
        self.do_test(
            expected_topic="#4: Test ticket" + "!" * 42 + "...",
            expected_message="some message",
        )

    def test_long_content(self) -> None:
        self.TICKET_ID = 5
        self.TICKET_TITLE = "Some ticket"
        self.MESSAGE = "New comment:\n> It is better\n* here"
        self.do_test(
            expected_topic="#5: Some ticket",
            expected_message="New comment:\n> It is better\n* here",
        )