本文整理汇总了Python中tests.base.fake.email函数的典型用法代码示例。如果您正苦于以下问题:Python email函数的具体用法?Python email怎么用?Python email使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了email函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_send_with_sendgrid_success
def test_send_with_sendgrid_success(self):
mock_client = mock.MagicMock()
mock_client.send.return_value = 200, 'success'
from_addr, to_addr = fake.email(), fake.email()
category1, category2 = fake.word(), fake.word()
subject = fake.bs()
message = fake.text()
ret = _send_with_sendgrid(
from_addr=from_addr,
to_addr=to_addr,
subject=subject,
message=message,
mimetype='txt',
client=mock_client,
categories=(category1, category2)
)
assert_true(ret)
mock_client.send.assert_called_once()
# First call's argument should be a Mail object with
# the correct configuration
first_call_arg = mock_client.send.call_args[0][0]
assert_is_instance(first_call_arg, sendgrid.Mail)
assert_equal(first_call_arg.from_email, from_addr)
assert_equal(first_call_arg.to[0], to_addr)
assert_equal(first_call_arg.subject, subject)
assert_equal(first_call_arg.text, message)
# Categories are set
assert_equal(first_call_arg.smtpapi.data['category'], (category1, category2))
示例2: test_correct_name_shows_in_contributor_list
def test_correct_name_shows_in_contributor_list(self):
name1, email = fake.name(), fake.email()
UnregUserFactory(fullname=name1, email=email)
name2, email = fake.name(), fake.email()
# Added with different name
self.project.add_unregistered_contributor(fullname=name2, email=email, auth=Auth(self.referrer))
self.project.save()
res = self.app.get(self.project.url, auth=self.referrer.auth)
# Correct name is shown
assert_in_html(name2, res)
assert_not_in(name1, res)
示例3: test_send_with_sendgrid_failure_returns_false
def test_send_with_sendgrid_failure_returns_false(self):
mock_client = mock.MagicMock()
mock_client.send.return_value = 400, 'failed'
from_addr, to_addr = fake.email(), fake.email()
subject = fake.bs()
message = fake.text()
ret = _send_with_sendgrid(
from_addr=from_addr,
to_addr=to_addr,
subject=subject,
message=message,
mimetype='txt',
client=mock_client
)
assert_false(ret)
示例4: setUp
def setUp(self):
super(PreregViewsTests, self).setUp()
ensure_schemas()
self.osf_user = factories.AuthUserFactory()
password = fake.password(),
self.user = User.objects.create(
email=fake.email(),
first_name=fake.first_name(),
last_name=fake.last_name(),
osf_id=self.osf_user._id
)
self.user.set_password(password)
self.user.save()
self.logged_in = self.client.login(username=self.user.email, password=password)
PREREG_GROUP.user_set.add(self.user)
PREREG_GROUP.save()
self.prereg_schema = MetaSchema.find_one(
Q('name', 'eq', 'Prereg Challenge') &
Q('schema_version', 'eq', 2)
)
self.other_schema = MetaSchema.find(
Q('name', 'ne', 'Prereg Challenge') &
Q('schema_version', 'eq', 2)
)[0]
示例5: test_get_most_in_common_contributors
def test_get_most_in_common_contributors(self):
# project 1 (contrib 1, contrib 2, unreg_contrib 3)
# - component 1 (contrib 1)
# project 2 - add should show contrib 1 first (2 links), contrib 2 second (1 link)
contributor_1 = AuthUserFactory()
contributor_2 = AuthUserFactory()
self.project.add_contributor(contributor_1, auth=self.auth)
self.project.add_contributor(contributor_2, auth=self.auth)
# has one unregistered contributor
self.project.add_unregistered_contributor(
fullname=fake.name(),
email=fake.email(),
auth=self.auth,
)
self.project.save()
component = NodeFactory(parent=self.project, creator=self.user)
component.add_contributor(contributor_1, auth=self.auth)
component.save()
project_2 = ProjectFactory(creator=self.user)
project_2.add_contributor(contributor_1, auth=self.auth)
url = project_2.api_url_for('get_most_in_common_contributors')
res = self.app.get(url, auth=self.user.auth)
project_2.reload()
res_contribs = res.json['contributors']
assert_equal(len(res.json['contributors']), 2)
assert_equal(contributor_1._id, res_contribs[0]['id'])
assert_equal(res_contribs[0]['n_projects_in_common'], 2)
assert_equal(contributor_2._id, res_contribs[1]['id'])
assert_equal(res_contribs[1]['n_projects_in_common'], 1)
示例6: test_cannot_go_to_claim_url_after_setting_password
def test_cannot_go_to_claim_url_after_setting_password(self):
name, email = fake.name(), fake.email()
new_user = self.project.add_unregistered_contributor(
email=email,
fullname=name,
auth=Auth(self.referrer)
)
self.project.save()
# Goes to claim url and successfully claims account
claim_url = new_user.get_claim_url(self.project._primary_key)
res = self.app.get(claim_url)
self.project.reload()
assert_in('Set Password', res)
form = res.forms['setPasswordForm']
#form['username'] = new_user.username #Removed as long as the E-mail can't be changed
form['password'] = 'killerqueen'
form['password2'] = 'killerqueen'
res = form.submit().maybe_follow()
# logs out
res = self.app.get('/logout/').maybe_follow()
# tries to go to claim url again
res = self.app.get(claim_url, expect_errors=True)
assert_equal(res.status_code, 400)
assert_in('already been claimed', res)
示例7: setUp
def setUp(self):
super(TestClaimingAsARegisteredUser, self).setUp()
self.referrer = AuthUserFactory()
self.project = ProjectFactory(creator=self.referrer, is_public=True)
name, email = fake.name(), fake.email()
self.user = self.project.add_unregistered_contributor(fullname=name, email=email, auth=Auth(user=self.referrer))
self.project.save()
示例8: test_add_unconfirmed_email_when_email_verifications_is_None
def test_add_unconfirmed_email_when_email_verifications_is_None(self):
self.user.email_verifications = None
self.user.save()
email = fake.email()
self.user.add_unconfirmed_email(email)
self.user.save()
assert_in(email, self.user.unconfirmed_emails)
示例9: test_sees_is_redirected_if_user_already_logged_in
def test_sees_is_redirected_if_user_already_logged_in(self):
name, email = fake.name(), fake.email()
new_user = self.project.add_unregistered_contributor(email=email, fullname=name, auth=Auth(self.referrer))
self.project.save()
existing = AuthUserFactory()
claim_url = new_user.get_claim_url(self.project._primary_key)
# a user is already logged in
res = self.app.get(claim_url, auth=existing.auth, expect_errors=True)
assert_equal(res.status_code, 302)
示例10: test_get_recently_added_contributors
def test_get_recently_added_contributors(self):
project = ProjectFactory(creator=self.user)
project.add_contributor(AuthUserFactory(), auth=self.auth)
project.add_contributor(AuthUserFactory(), auth=self.auth)
# has one unregistered contributor
project.add_unregistered_contributor(fullname=fake.name(), email=fake.email(), auth=self.auth)
project.save()
url = self.project.api_url_for("get_recently_added_contributors")
res = self.app.get(url, auth=self.user.auth)
project.reload()
recent = [c for c in self.user.recently_added if c.is_active]
assert_equal(len(res.json["contributors"]), len(recent))
示例11: test_user_can_set_password_on_claim_page
def test_user_can_set_password_on_claim_page(self):
name, email = fake.name(), fake.email()
new_user = self.project.add_unregistered_contributor(email=email, fullname=name, auth=Auth(self.referrer))
self.project.save()
claim_url = new_user.get_claim_url(self.project._primary_key)
res = self.app.get(claim_url)
self.project.reload()
assert_in("Set Password", res)
form = res.forms["setPasswordForm"]
# form['username'] = new_user.username #Removed as long as E-mail can't be updated.
form["password"] = "killerqueen"
form["password2"] = "killerqueen"
res = form.submit().follow()
new_user.reload()
assert_true(new_user.check_password("killerqueen"))
示例12: test_unregistered_users_names_are_project_specific
def test_unregistered_users_names_are_project_specific(self):
name1, name2, email = fake.name(), fake.name(), fake.email()
project2 = ProjectFactory(creator=self.referrer)
# different projects use different names for the same unreg contributor
self.project.add_unregistered_contributor(email=email, fullname=name1, auth=Auth(self.referrer))
self.project.save()
project2.add_unregistered_contributor(email=email, fullname=name2, auth=Auth(self.referrer))
project2.save()
self.app.authenticate(*self.referrer.auth)
# Each project displays a different name in the contributor list
res = self.app.get(self.project.url)
assert_in_html(name1, res)
res2 = self.app.get(project2.url)
assert_in_html(name2, res2)
示例13: create_fake_user
def create_fake_user():
email = fake.email()
name = fake.name()
parsed = impute_names(name)
user = UserFactory(
username=email,
fullname=name,
is_registered=True,
is_claimed=True,
date_registered=fake.date_time(),
emails=[email],
**parsed
)
user.set_password('faker123')
user.save()
return user
示例14: create_fake_user
def create_fake_user():
email = fake.email()
name = fake.name()
parsed = impute_names(name)
user = UserFactory(
username=email,
fullname=name,
is_registered=True,
is_claimed=True,
verification_key=security.random_string(15),
date_registered=fake.date_time(),
emails=[email],
**parsed
)
user.set_password('faker123')
user.save()
return user
示例15: test_was_invited
def test_was_invited(self):
referrer = UserFactory()
node = NodeFactory(creator=referrer)
name = fake.name()
email = fake.email()
user = node.add_unregistered_contributor(
fullname=name,
email=email,
auth=Auth(user=referrer),
)
user.register(email, 'secret')
assert_true(is_invited(user))
user.is_invited = None
user.save()
main(dry_run=False)
user.reload()
assert_true(user.is_invited)