本文整理汇总了Python中mock.Mock.email方法的典型用法代码示例。如果您正苦于以下问题:Python Mock.email方法的具体用法?Python Mock.email怎么用?Python Mock.email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.Mock
的用法示例。
在下文中一共展示了Mock.email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_filter(self):
user = Mock()
user.email = '[email protected]'
record = Mock()
record.request.user = user
record.request.META = {}
self.assertTrue(AddCurrentUser().filter(record))
示例2: test_that_helper_adds_email_to_BSD_if_permission_was_given
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_that_helper_adds_email_to_BSD_if_permission_was_given(self, mock_task_func):
mock_user = Mock()
mock_user.email = '[email protected]'
mock_privacy_form = Mock()
mock_privacy_form.cleaned_data = {'add_me_to_email_list': True}
views._add_email_to_bsd(mock_user, mock_privacy_form)
mock_task_func.delay.assert_called_with('[email protected]', '111')
示例3: test_that_helper_does_not_add_email_to_BSD_if_permission_refused
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_that_helper_does_not_add_email_to_BSD_if_permission_refused(self, mock_task_func):
mock_user = Mock()
mock_user.email = '[email protected]'
mock_privacy_form = Mock()
mock_privacy_form.cleaned_data = {'add_me_to_email_list': False}
views._add_email_to_bsd(mock_user, mock_privacy_form)
eq_(mock_task_func.delay.call_args_list, [])
示例4: _get_or_add_address
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def _get_or_add_address(self, email, **kw): # pylint: disable-msg=unused-argument
try:
mm_addr = self.mm_addresses[email]
except KeyError:
mm_addr = Mock()
mm_addr.email = email
mm_addr.verified_on = None
self.mm_addresses[email] = mm_addr
return mm_addr
示例5: testGetEmail
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def testGetEmail(self, mockRemoteStore):
email = '[email protected]'
# Mock a remote user object, and bind it to fetch_user
remote_user = Mock()
remote_user.email = email
instance = mockRemoteStore.return_value
instance.fetch_user.return_value = remote_user
ddsutil = DDSUtil(self.user)
self.assertEqual(email, ddsutil.get_remote_user(self.user_id).email)
self.assertTrue(instance.fetch_user.called)
示例6: test_google_user_logged_for_the_first_time
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_google_user_logged_for_the_first_time(self):
google_account_user = Mock()
google_account_user.user_id = lambda: '123'
google_account_user.email = lambda: '[email protected]'
google_account_user.nickname = lambda: 'foo'
user = facade.login_google(google_account_user, Mock()).execute().result
self.assertEqual('[email protected]', user.email)
self.assertEqual('foo', user.name)
self.assertEqual(MainUser.query().get(), user)
google_user = OriginsSearch(ExternalToMainUser, user).execute().result[0]
self.assertEqual('123', google_user.google_id)
示例7: test_get_email
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_get_email():
"""Tests whether it gives back the user.email property"""
with patch('h.notification.reply_template.get_user_by_name') as mock_user_db:
user = Mock()
user.email = '[email protected]'
mock_user_db.return_value = user
request = _fake_request()
annotation = _fake_anno(0)
email = rt.get_recipients(request, annotation)
assert email[0] == user.email
示例8: login
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def login(self, adapter, provider_name):
del adapter, provider_name
response = Mock()
response.error = self.error
if self.error:
response.user = False
else:
user = Mock()
user.name = self.name
user.email = self.email
response.user = user
return response
示例9: test_extract_leads_from_chats
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_extract_leads_from_chats(self):
operator = Mock()
operator.email = MagicMock(return_value='[email protected]')
product_reference = 'PF12345'
with patch.dict(CHAT1['Chat'], {'Operator': operator, 'Customs': {'Imovel': product_reference}}):
chat_list = [CHAT1]
actual = Livezilla.extract_leads_from_chats(chat_list)
expected = {'name': u'Chat #11123 | Ivone Duarte', 'description': u'Can you help me?\nA', 'contact_name': u'Ivone Duarte',
'contact_phone': u'967961100', 'contact_email': u'[email protected]', 'operator': unicode(operator.email), 'group': u'groupid1', 'product_code': product_reference}
self.assertEqual(1, len(actual))
self.assertDictEqual(expected, actual[0])
示例10: test_get_committer_data
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_get_committer_data(self):
committer = Mock()
committer.email = "[email protected]"
committer.login = "foo"
data = self.provider.get_committer_data(committer)._identity
self.assertEqual(data["name"], "foo")
self.assertEqual(data["email"], "[email protected]")
committer = Mock()
committer.email = None
committer.login = "foo"
committer.get_emails.return_value = [{"primary": True, "email": "[email protected]"},]
data = self.provider.get_committer_data(committer)._identity
self.assertEqual(data["name"], "foo")
self.assertEqual(data["email"], "[email protected]")
committer = Mock()
committer.email = None
committer.login = "foo"
committer.get_emails.return_value = []
with self.assertRaises(errors.NoPermissionError):
data = self.provider.get_committer_data(committer)
示例11: test_existing_address_but_not_verified
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_existing_address_but_not_verified(self):
# The secondary address exists but is not verified
self.mailman_client.get_address.side_effect = self._get_or_add_address
secondary_address = Mock()
secondary_address.email = "[email protected]"
secondary_address.verified_on = None
secondary_address.__unicode__ = lambda self: self.email
self.mm_user.addresses.append(secondary_address)
details = {"secondary_email": "[email protected]"}
mailman.add_user_to_mailman(self.user, details)
# The secondary address must only have been verified.
self.assertFalse(self.mm_user.add_address.called)
secondary_address.verify.assert_called_with()
示例12: test_adult_details_with_adult
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_adult_details_with_adult(self):
person = Mock()
person.name = "Bob"
person.email = "[email protected]"
person.age_str = Mock(return_value="22")
person.adult = Mock(return_value=True)
# An example using a mock instead of an actual person to prevent the need for hitting the database
# for no reason. And also to validate that the check for the user being an adult was first checked
expect(self.example.adult_details(person)).to(equal("Bob - [email protected] - 22"))
expect(person.adult.call_count).to(equal(1))
# Make sure that the adult function was called
person.adult.assert_called()
示例13: test_extract_leads_from_chats_excluding_duplicates1
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_extract_leads_from_chats_excluding_duplicates1(self):
"""
Different chats between the same operator and the same client should be merged into a single lead where the
description is the concatenation of the plain texts of the chats
"""
operator = Mock()
operator.email = MagicMock(return_value='[email protected]')
with patch.dict(CHAT1['Chat'], {'Operator': operator}), patch.dict(CHAT2['Chat'], {'Operator': operator}):
chat_list = [CHAT1, CHAT2]
actual = Livezilla.extract_leads_from_chats(chat_list)
expected = {'name': u'Chat #11123 | Ivone Duarte', 'description': u'Can you help me?\nA' + '\n' + 20 * '-' + '\n' + u'Can you help me?\nB', 'contact_name': u'Ivone Duarte',
'contact_phone': u'967961100', 'contact_email': u'[email protected]', 'operator': unicode(operator.email), 'group': u'groupid1', 'product_code': None}
self.assertEqual(1, len(actual))
self.assertDictEqual(expected, actual[0])
示例14: test_that_create_event_and_venue_does_that_given_valid_data
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_that_create_event_and_venue_does_that_given_valid_data(self):
event_kind = models.EventKind(name = "Test", slug = "test", description = "Test")
event_kind.save()
self.data['event-kind'] = str(event_kind.id)
ef = forms.EventForm(self.data)
vf = forms.VenueForm(self.data)
mock_user = Mock()
mock_user.email = '[email protected]'
event, venue = views._create_event_and_venue(mock_user, ef, vf)
ok_(event.id is not None)
ok_(venue.id is not None)
eq_(venue.location.y, 51.0)
eq_(venue, event.venue)
示例15: test_get_email
# 需要导入模块: from mock import Mock [as 别名]
# 或者: from mock.Mock import email [as 别名]
def test_get_email():
"""Tests whether it gives back the user.email property"""
with patch('h.notification.reply_template.Annotation') as mock_annotation:
mock_annotation.fetch = MagicMock(side_effect=fake_fetch)
with patch('h.notification.reply_template.get_user_by_name') as mock_user_db:
user = Mock()
user.email = '[email protected]'
mock_user_db.return_value = user
request = _create_request()
annotation = store_fake_data[1]
parent = rt.parent_values(annotation)
email = rt.get_recipients(request, parent)
assert email[0] == user.email