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


Python fake.name函数代码示例

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


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

示例1: 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

示例2: test_correct_display_name_is_shown_at_claim_page

    def test_correct_display_name_is_shown_at_claim_page(self):
        original_name = fake.name()
        unreg = UnregUserFactory(fullname=original_name)

        different_name = fake.name()
        new_user = self.project.add_unregistered_contributor(
            email=unreg.username, fullname=different_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)
        # Correct name (different_name) should be on page
        assert_in_html(different_name, res)
开发者ID:Alpani,项目名称:osf.io,代码行数:13,代码来源:webtest_tests.py

示例3: 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

示例4: 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

示例5: 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

示例6: test_claim_user_registered_preprint_with_correct_password

    def test_claim_user_registered_preprint_with_correct_password(self):
        preprint = PreprintFactory(creator=self.referrer)
        name, email = fake.name(), fake_email()
        unreg_user = preprint.add_unregistered_contributor(
            fullname=name,
            email=email,
            auth=Auth(user=self.referrer)
        )
        reg_user = AuthUserFactory()  # NOTE: AuthUserFactory sets password as 'queenfan86'
        url = unreg_user.get_claim_url(preprint._id)
        # Follow to password re-enter page
        res = self.app.get(url, auth=reg_user.auth).follow(auth=reg_user.auth)

        # verify that the "Claim Account" form is returned
        assert_in('Claim Contributor', res.body)

        form = res.forms['claimContributorForm']
        form['password'] = 'queenfan86'
        res = form.submit(auth=reg_user.auth)

        preprint.reload()
        unreg_user.reload()
        # user is now a contributor to the project
        assert_in(reg_user, preprint.contributors)

        # the unregistered user (unreg_user) is removed as a contributor, and their
        assert_not_in(unreg_user, preprint.contributors)

        # unclaimed record for the project has been deleted
        assert_not_in(preprint, unreg_user.unclaimed_records)
开发者ID:CenterForOpenScience,项目名称:osf.io,代码行数:30,代码来源:test_webtests.py

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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