<commit_before># coding: utf-8
from mock import call, patch

from sentry.plugins import plugins, Notification
from sentry.testutils import PluginTestCase
from sentry.utils.samples import create_sample_event

from sentry_telegram import TelegramNotificationsPlugin


class BaseTest(PluginTestCase):
    plugin = TelegramNotificationsPlugin

    def setUp(self):
        super(BaseTest, self).setUp()
        self.initialized_plugin = self.plugin()

    def test_is_registered(self):
        assert plugins.get('sentry_telegram').slug == self.plugin.slug

    def test_complex_send_notification(self):
        self.initialized_plugin.set_option('receivers', '123', self.project)
        self.initialized_plugin.set_option('api_token', 'api:token', self.project)
        event = create_sample_event(self.project, platform='python')
        notification = Notification(event=event)
        with patch('requests.sessions.Session.request') as request:
            self.initialized_plugin.notify(notification)
            assert request.call_args_list == [
                call(
                    allow_redirects=False,
                    method='POST',
                    headers={'Content-Type': 'application/json'},
                    url=u'https://api.telegram.org/botapi:token/sendMessage',
                    json={'text': '*[Sentry]* Bar error\nhttp://testserver/baz/bar/issues/1/', 'parse_mode': 'Markdown', 'chat_id': '123'},
                    timeout=30,
                    verify=True,
                ),
            ]

    def test_get_empty_receivers_list(self):
        self.initialized_plugin.set_option('receivers', '', self.project)
        assert self.initialized_plugin.get_receivers(self.project) == []
<commit_msg>fix test<commit_after># coding: utf-8
from mock import call, patch

from sentry.plugins import plugins, Notification
from sentry.testutils import PluginTestCase
from sentry.utils.samples import create_sample_event

from sentry_telegram import TelegramNotificationsPlugin


class BaseTest(PluginTestCase):
    plugin = TelegramNotificationsPlugin

    def setUp(self):
        super(BaseTest, self).setUp()
        self.initialized_plugin = self.plugin()

    def test_is_registered(self):
        assert plugins.get('sentry_telegram').slug == self.plugin.slug

    def test_complex_send_notification(self):
        self.initialized_plugin.set_option('receivers', '123', self.project)
        self.initialized_plugin.set_option('api_token', 'api:token', self.project)
        self.initialized_plugin.set_option('message_template', '*[Sentry]* {project_name} {tag[level]}: {title}\n{message}\n{url}', self.project)
        event = create_sample_event(self.project, platform='python')
        notification = Notification(event=event)
        with patch('requests.sessions.Session.request') as request:
            self.initialized_plugin.notify(notification)
            assert request.call_args_list == [
                call(
                    allow_redirects=False,
                    method='POST',
                    headers={'Content-Type': 'application/json'},
                    url=u'https://api.telegram.org/botapi:token/sendMessage',
                    json={'text': '*[Sentry]* Bar error: This is an example python exception\nThis is an example python exception\nhttp://testserver/baz/bar/issues/1/', 'parse_mode': 'Markdown', 'chat_id': '123'},
                    timeout=30,
                    verify=True,
                ),
            ]

    def test_get_empty_receivers_list(self):
        self.initialized_plugin.set_option('receivers', '', self.project)
        assert self.initialized_plugin.get_receivers(self.project) == []

{'fraction_non_alphanumeric': 0.1122255353754405, 'fraction_numerical': 0.005421523448088913, 'mean_word_length': 2.8965153115100315, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1157943', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1005, 'n_words': 182}