• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.MailProcessor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.plugins.sentry_mail.models.MailProcessor的典型用法代码示例。如果您正苦于以下问题:Python MailProcessor类的具体用法?Python MailProcessor怎么用?Python MailProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MailProcessor类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_notify_users_does_email

    def test_notify_users_does_email(self, _send_mail):
        group = Group(
            id=2,
            first_seen=timezone.now(),
            last_seen=timezone.now(),
            project=self.project,
        )

        event = Event(
            group=group,
            message='hello world',
            logger='root',
            project=self.project,
            datetime=group.last_seen,
        )

        with self.Settings(SENTRY_URL_PREFIX='http://example.com'):
            p = MailProcessor(send_to=['[email protected]'])
            p.notify_users(group, event)

        _send_mail.assert_called_once()
        args, kwargs = _send_mail.call_args
        self.assertEquals(kwargs.get('fail_silently'), False)
        self.assertEquals(kwargs.get('project'), self.project)
        self.assertEquals(kwargs.get('subject'), u"[Project Name] ERROR: hello world")
开发者ID:DamianZaremba,项目名称:sentry,代码行数:25,代码来源:tests.py


示例2: test_notify_users_does_email

    def test_notify_users_does_email(self, _send_mail):
        project = Project(id=1, name='Project Name')

        group = Group()
        group.first_seen = timezone.now()
        group.last_seen = group.first_seen
        group.project = project
        group.id = 2

        event = Event()
        event.group = group
        event.message = 'hello world'
        event.logger = 'root'
        event.project = project
        event.date = group.last_seen

        with self.Settings(SENTRY_URL_PREFIX='http://example.com'):
            p = MailProcessor(send_to=['[email protected]'])
            p.notify_users(group, event)

        _send_mail.assert_called_once()
        args, kwargs = _send_mail.call_args
        self.assertEquals(kwargs.get('fail_silently'), False)
        self.assertEquals(kwargs.get('project'), project)
        self.assertEquals(kwargs.get('subject'), u"[Project Name] ERROR: hello world")
开发者ID:Crowdbooster,项目名称:sentry,代码行数:25,代码来源:tests.py


示例3: test_notify_users_renders_interfaces_with_utf8

    def test_notify_users_renders_interfaces_with_utf8(self, _send_mail):
        group = Group(
            id=2,
            first_seen=timezone.now(),
            last_seen=timezone.now(),
            project=self.project,
        )

        stacktrace = Mock(spec=Stacktrace)
        stacktrace.to_string.return_value = u'רונית מגן'
        stacktrace.get_title.return_value = 'Stacktrace'

        event = Event()
        event.group = group
        event.message = 'hello world'
        event.logger = 'root'
        event.site = None
        event.interfaces = {'sentry.interfaces.Stacktrace': stacktrace}

        with self.Settings(SENTRY_URL_PREFIX='http://example.com'):
            p = MailProcessor(send_to=['[email protected]'])
            p.notify_users(group, event)

        stacktrace.get_title.assert_called_once_with()
        stacktrace.to_string.assert_called_once_with(event)
开发者ID:DamianZaremba,项目名称:sentry,代码行数:25,代码来源:tests.py


示例4: test_notify_users_does_email

    def test_notify_users_does_email(self, _send_mail):
        project = Project(id=1, name="Project Name")

        group = Group()
        group.first_seen = datetime.datetime.now()
        group.last_seen = group.first_seen
        group.project = project
        group.id = 2

        event = Event()
        event.group = group
        event.message = "hello world"
        event.logger = "root"
        event.project = project
        event.date = group.last_seen

        with self.Settings(SENTRY_URL_PREFIX="http://example.com"):
            p = MailProcessor(send_to=["[email protected]"])
            p.notify_users(group, event)

        _send_mail.assert_called_once()
        args, kwargs = _send_mail.call_args
        self.assertEquals(kwargs.get("fail_silently"), False)
        self.assertEquals(kwargs.get("project"), project)
        self.assertEquals(kwargs.get("subject"), u"[Project Name] ERROR: hello world")
开发者ID:urbaniak,项目名称:sentry,代码行数:25,代码来源:tests.py


示例5: test_should_notify_excluded

 def test_should_notify_excluded(self):
     p = MailProcessor(min_level=None, exclude_loggers=['root'])
     group = Mock(spec=Group)
     group.project = Project()
     group.level = 5
     group.logger = 'root'
     self.assertFalse(p.should_notify(group=group, event=Mock()))
开发者ID:DamianZaremba,项目名称:sentry,代码行数:7,代码来源:tests.py


示例6: test_should_notify_match

    def test_should_notify_match(self):
        p = MailProcessor(min_level=None)
        group = Mock(spec=Group)
        group.level = 5
        group.project = Project()
        group.logger = 'root'
        event = Mock()
        event.data = {}
        self.assertTrue

        (p.should_notify(group=group, event=event))
开发者ID:DamianZaremba,项目名称:sentry,代码行数:11,代码来源:tests.py


示例7: test_get_emails_for_users

    def test_get_emails_for_users(self):
        from django.contrib.auth.models import User
        from sentry.models import UserOption

        user = User.objects.create(username='foo', email='[email protected]')
        user2 = User.objects.create(username='baz', email='[email protected]')

        p = MailProcessor()

        self.assertEquals(sorted(p.get_emails_for_users([user.pk, user2.pk])),
                          sorted([user.email, user2.email]))
        UserOption.objects.create(key='alert_email', value='[email protected]', user=user2)

        self.assertEquals(sorted(p.get_emails_for_users([user.pk, user2.pk])),
                          sorted([user.email, '[email protected]']))
开发者ID:Crowdbooster,项目名称:sentry,代码行数:15,代码来源:tests.py


示例8: test_get_sendable_users

    def test_get_sendable_users(self):
        from django.contrib.auth.models import User
        from sentry.models import Project, UserOption

        user = User.objects.create(username="foo", email="[email protected]", is_active=True)
        user2 = User.objects.create(username="baz", email="[email protected]", is_active=True)
        user3 = User.objects.create(username="bar", email="[email protected]", is_active=False)
        project = Project.objects.create(name="Test", slug="test", owner=user)
        project.team.member_set.get_or_create(user=user)
        project.team.member_set.get_or_create(user=user2)
        project.team.member_set.get_or_create(user=user3)

        p = MailProcessor()

        # all members
        self.assertEqual(sorted(set([user.pk, user2.pk])), sorted(p.get_sendable_users(project)))

        # disabled user2
        UserOption.objects.create(key="mail:alert", value=0, project=project, user=user2)
        self.assertEqual(sorted(set([user.pk])), sorted(p.get_sendable_users(project)))
开发者ID:urbaniak,项目名称:sentry,代码行数:20,代码来源:tests.py


示例9: test_get_sendable_users

    def test_get_sendable_users(self):
        from django.contrib.auth.models import User
        from sentry.models import Project, UserOption

        user = User.objects.create(username='foo', email='[email protected]')
        user2 = User.objects.create(username='baz', email='[email protected]')
        project = Project.objects.create(name='Test', slug='test', owner=user)
        project.team.member_set.get_or_create(user=user)
        project.team.member_set.get_or_create(user=user2)

        p = MailProcessor()

        # all members
        self.assertEqual(sorted(set([user.pk, user2.pk])),
                         sorted(p.get_sendable_users(project)))

        # disabled user2
        UserOption.objects.create(key='mail:alert', value=0, project=project, user=user2)
        self.assertEqual(sorted(set([user.pk])),
                         sorted(p.get_sendable_users(project)))
开发者ID:NewAgeDev,项目名称:sentry,代码行数:20,代码来源:tests.py


示例10: test_send_to

    def test_send_to(self, get_emails_for_users, get_sendable_users, get_value):
        opts = {}

        admins = ["1"]
        member_emails = ["2", "3"]
        project_emails = ["2", "4"]

        get_value.side_effect = lambda p, k, d: opts.get(k, d)
        get_emails_for_users.side_effect = lambda x: x
        get_sendable_users.return_value = member_emails

        project = mock.Mock()
        project.id = 1
        project.pk = project.id

        with self.Settings(SENTRY_ADMINS=admins):
            p = MailProcessor()
            # member emails without admins
            self.assertEqual(sorted(set(member_emails)), sorted(p.get_send_to(project)))

            # member emails with members
            opts = {"mail:send_to_admins": True}
            self.assertEqual(sorted(set(member_emails + admins)), sorted(p.get_send_to(project)))

            # project emails without members
            opts = {"mail:send_to": ",".join(project_emails), "mail:send_to_members": False}
            self.assertEqual(sorted(set(project_emails)), sorted(p.get_send_to(project)))

            # project emails with members
            opts = {
                "mail:send_to": ",".join(project_emails),
                "mail:send_to_members": False,
                "mail:send_to_admins": True,
            }
            self.assertEqual(sorted(set(project_emails + admins)), sorted(p.get_send_to(project)))

            # project emails with members and admins
            opts = {"mail:send_to": ",".join(project_emails), "mail:send_to_members": True, "mail:send_to_admins": True}
            self.assertEqual(sorted(set(project_emails + admins + member_emails)), sorted(p.get_send_to(project)))
开发者ID:urbaniak,项目名称:sentry,代码行数:39,代码来源:tests.py


示例11: test_multiline_error

    def test_multiline_error(self, _send_mail):
        group = Group(
            id=2,
            first_seen=timezone.now(),
            last_seen=timezone.now(),
            project=self.project,
        )

        event = Event(
            group=group,
            message='hello world\nfoo bar',
            logger='root',
            project=self.project,
            datetime=group.last_seen,
        )

        with self.Settings(SENTRY_URL_PREFIX='http://example.com'):
            p = MailProcessor(send_to=['[email protected]'])
            p.notify_users(group, event)

        _send_mail.assert_called_once()
        args, kwargs = _send_mail.call_args
        assert kwargs.get('subject') == u"[{0}] ERROR: hello world".format(self.project.name)
开发者ID:duncm,项目名称:sentry,代码行数:23,代码来源:tests.py


示例12: test_notify_users_renders_interfaces_with_utf8_fix_issue_422

    def test_notify_users_renders_interfaces_with_utf8_fix_issue_422(self, _send_mail):
        group = Group()
        group.first_seen = timezone.now()
        group.last_seen = group.first_seen
        group.id = 2
        group.project_id = 1

        stacktrace = Mock(spec=Stacktrace)
        stacktrace.to_string.return_value = u'רונית מגן'
        stacktrace.get_title.return_value = 'Stacktrace'

        event = Event()
        event.group = group
        event.message = 'Soubor ji\xc5\xbe existuje'
        event.logger = 'root'
        event.site = None
        event.interfaces = {'sentry.interfaces.Stacktrace': stacktrace}

        with self.Settings(SENTRY_URL_PREFIX='http://example.com'):
            p = MailProcessor(send_to=['[email protected]'])
            p.notify_users(group, event)

        stacktrace.get_title.assert_called_once_with()
        stacktrace.to_string.assert_called_once_with(event)
开发者ID:Crowdbooster,项目名称:sentry,代码行数:24,代码来源:tests.py


示例13: test_notify_users_renders_interfaces_with_utf8

    def test_notify_users_renders_interfaces_with_utf8(self, _send_mail):
        group = Group()
        group.first_seen = datetime.datetime.now()
        group.last_seen = group.first_seen
        group.id = 2
        group.project_id = 1

        stacktrace = Mock(spec=Stacktrace)
        stacktrace.to_string.return_value = u"רונית מגן"
        stacktrace.get_title.return_value = "Stacktrace"

        event = Event()
        event.group = group
        event.message = "hello world"
        event.logger = "root"
        event.site = None
        event.interfaces = {"sentry.interfaces.Stacktrace": stacktrace}

        with self.Settings(SENTRY_URL_PREFIX="http://example.com"):
            p = MailProcessor(send_to=["[email protected]"])
            p.notify_users(group, event)

        stacktrace.get_title.assert_called_once_with()
        stacktrace.to_string.assert_called_once_with(event)
开发者ID:urbaniak,项目名称:sentry,代码行数:24,代码来源:tests.py


示例14: test_send_to

    def test_send_to(self, get_emails_for_users, get_sendable_users, get_value):
        opts = {}

        member_emails = ['2', '3']
        project_emails = ['2', '4']

        get_value.side_effect = lambda p, k, d: opts.get(k, d)
        get_emails_for_users.side_effect = lambda x: x
        get_sendable_users.return_value = member_emails

        project = mock.Mock()
        project.id = 1
        project.pk = project.id

        p = MailProcessor()
        # member emails without admins
        self.assertEqual(sorted(set(member_emails)),
                         sorted(p.get_send_to(project)))

        # project emails without members
        opts = {'mail:send_to': ','.join(project_emails),
                'mail:send_to_members': False}
        self.assertEqual(sorted(set(project_emails)),
                         sorted(p.get_send_to(project)))
开发者ID:DamianZaremba,项目名称:sentry,代码行数:24,代码来源:tests.py


示例15: test_should_notify_match

 def test_should_notify_match(self):
     p = MailProcessor(min_level=None)
     group = Mock(spec=Group)
     group.level = 5
     group.logger = 'root'
     self.assertTrue(p.should_notify(group=group, event=Mock()))
开发者ID:Crowdbooster,项目名称:sentry,代码行数:6,代码来源:tests.py


示例16: test_should_notify_not_min_level

 def test_should_notify_not_min_level(self):
     p = MailProcessor(min_level=2)
     group = Mock(spec=Group)
     group.level = 1
     self.assertFalse(p.should_notify(group=group, event=Mock()))
开发者ID:Crowdbooster,项目名称:sentry,代码行数:5,代码来源:tests.py


示例17: test_should_notify_no_send_to

 def test_should_notify_no_send_to(self):
     p = MailProcessor()
     self.assertFalse(p.should_notify(group=Mock(), event=Mock()))
开发者ID:Crowdbooster,项目名称:sentry,代码行数:3,代码来源:tests.py


示例18: test_should_notify_not_included

 def test_should_notify_not_included(self):
     p = MailProcessor(min_level=None, include_loggers=["foo"])
     group = Mock(spec=Group)
     group.level = 5
     group.logger = "root"
     self.assertFalse(p.should_notify(group=group, event=Mock()))
开发者ID:urbaniak,项目名称:sentry,代码行数:6,代码来源:tests.py


示例19: test_send_to

    def test_send_to(self):
        Mock = mock.Mock
        with mock.patch('sentry.models.ProjectOption.objects.get_value') as get_value:
            opts = {}
            get_value.side_effect = lambda p, k, d: opts.get(k, d)

            admins = ['[email protected]']
            member_emails = ['[email protected]', '[email protected]']
            project_emails = ['[email protected]', '[email protected]']

            project = Mock()
            project.team.member_set = Mock()
            project.team.member_set.values_list.return_value = member_emails

            with self.Settings(SENTRY_ADMINS=admins):
                # member emails without admins
                p = MailProcessor()
                self.assertEqual(sorted(set(member_emails)),
                                 sorted(p.get_send_to(project)))

                # member emails with members
                p = MailProcessor()
                opts = {'mail:send_to_admins': True}
                p._send_mail('', '', project=project)
                self.assertEqual(sorted(set(member_emails + admins)),
                                 sorted(p.get_send_to(project)))

                # project emails without members
                p = MailProcessor()
                opts = {'mail:send_to': ','.join(project_emails),
                        'mail:send_to_members': False}
                p._send_mail('', '', project=project)
                self.assertEqual(sorted(set(project_emails)),
                                 sorted(p.get_send_to(project)))

                # project emails with members
                p = MailProcessor()
                opts = {'mail:send_to': ','.join(project_emails),
                        'mail:send_to_members': False,
                        'mail:send_to_admins': True}
                p._send_mail('', '', project=project)
                self.assertEqual(sorted(set(project_emails + admins)),
                                 sorted(p.get_send_to(project)))

                # project emails with members and admins
                p = MailProcessor()
                opts = {'mail:send_to': ','.join(project_emails),
                        'mail:send_to_members': True,
                        'mail:send_to_admins': True}
                p._send_mail('', '', project=project)
                self.assertEqual(sorted(set(project_emails + admins + member_emails)),
                                 sorted(p.get_send_to(project)))
开发者ID:SimpleTax,项目名称:sentry,代码行数:52,代码来源:tests.py



注:本文中的sentry.plugins.sentry_mail.models.MailProcessor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.send_group_processors函数代码示例发布时间:2022-05-27
下一篇:
Python plugins.get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap