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


Python MailProcessor.get_send_to方法代码示例

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


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

示例1: test_send_to

# 需要导入模块: from sentry.plugins.sentry_mail.models import MailProcessor [as 别名]
# 或者: from sentry.plugins.sentry_mail.models.MailProcessor import get_send_to [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

示例2: test_send_to

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


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