• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python fake.email函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.base.fake.email函数的典型用法代码示例。如果您正苦于以下问题:Python email函数的具体用法?Python email怎么用?Python email使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了email函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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))
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:29,代码来源:test_email.py


示例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)
开发者ID:Alpani,项目名称:osf.io,代码行数:12,代码来源:webtest_tests.py


示例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)
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:15,代码来源:test_email.py


示例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]
开发者ID:AllisonLBowers,项目名称:osf.io,代码行数:27,代码来源:test_views.py


示例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)
开发者ID:GageGaskins,项目名称:osf.io,代码行数:29,代码来源:test_contributors_views.py


示例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)
开发者ID:lbanner,项目名称:osf.io,代码行数:25,代码来源:webtest_tests.py


示例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()
开发者ID:Alpani,项目名称:osf.io,代码行数:7,代码来源:webtest_tests.py


示例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)
开发者ID:GageGaskins,项目名称:osf.io,代码行数:8,代码来源:test_user.py


示例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)
开发者ID:Alpani,项目名称:osf.io,代码行数:9,代码来源:webtest_tests.py


示例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))
开发者ID:njantrania,项目名称:osf.io,代码行数:12,代码来源:test_contributors_views.py


示例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"))
开发者ID:Alpani,项目名称:osf.io,代码行数:15,代码来源:webtest_tests.py


示例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)
开发者ID:Alpani,项目名称:osf.io,代码行数:15,代码来源:webtest_tests.py


示例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
开发者ID:adlius,项目名称:osf.io,代码行数:16,代码来源:factories.py


示例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
开发者ID:545zhou,项目名称:osf.io,代码行数:17,代码来源:factories.py


示例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)
开发者ID:545zhou,项目名称:osf.io,代码行数:17,代码来源:test_migrate_was_invited.py


示例16: test_cannot_set_email_to_a_user_that_already_exists

 def test_cannot_set_email_to_a_user_that_already_exists(self):
     reg_user = UserFactory()
     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"]
     # Fills out an email that is the username of another user
     form["username"] = reg_user.username
     form["password"] = "killerqueen"
     form["password2"] = "killerqueen"
     res = form.submit().maybe_follow(expect_errors=True)
     assert_in(language.ALREADY_REGISTERED.format(email=reg_user.username), res)
开发者ID:Alpani,项目名称:osf.io,代码行数:17,代码来源:webtest_tests.py


示例17: test_unregistered_user_can_create_an_account

 def test_unregistered_user_can_create_an_account(self):
     # User is added as an unregistered contributor to a project
     email, name = fake.email(), fake.name()
     self.project.add_unregistered_contributor(
         email=email,
         fullname=name,
         auth=Auth(self.referrer)
     )
     self.project.save()
     # Goes to registration page (instead of claiming their email)
     res = self.app.get('/account/').maybe_follow()
     form = res.forms['registerForm']
     form['register-fullname'] = name
     form['register-username'] = email
     form['register-username2'] = email
     form['register-password'] = 'example'
     form['register-password2'] = 'example'
     res = form.submit()
     # registered successfully
     assert_in(language.REGISTRATION_SUCCESS.format(email=email), res)
开发者ID:lbanner,项目名称:osf.io,代码行数:20,代码来源:webtest_tests.py


示例18: 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().maybe_follow()
     new_user.reload()
     # at settings page
     assert_equal(res.request.path, '/settings/')
     assert_in('Welcome to the OSF', res)
开发者ID:lbanner,项目名称:osf.io,代码行数:21,代码来源:webtest_tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fake.md5函数代码示例发布时间:2022-05-27
下一篇:
Python fake.bs函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap