本文整理汇总了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)))
示例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)))