当前位置: 首页>>代码示例>>Python>>正文


Python MailProcessor._send_mail方法代码示例

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


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

示例1: test_send_to

# 需要导入模块: from sentry.plugins.sentry_mail.models import MailProcessor [as 别名]
# 或者: from sentry.plugins.sentry_mail.models.MailProcessor import _send_mail [as 别名]
    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,代码行数:54,代码来源:tests.py


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