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


Python db_utils.create_user函数代码示例

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


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

示例1: test_block_user_homepage

def test_block_user_homepage(app):
    """
    Assert that changes to blocked users apply to the home page immediately.
    """
    submitting_user1 = db_utils.create_user()
    submitting_user2 = db_utils.create_user()
    viewing_user = db_utils.create_user()

    db_utils.create_submission(submitting_user1, rating=ratings.GENERAL.code, subtype=1010)
    db_utils.create_submission(submitting_user2, rating=ratings.GENERAL.code, subtype=1010)

    cookie = db_utils.create_session(viewing_user)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2

    app.post('/ignoreuser',
             {'userid': str(submitting_user1), 'action': 'ignore'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 1

    app.post('/ignoreuser',
             {'userid': str(submitting_user1), 'action': 'unignore'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2
开发者ID:Weasyl,项目名称:weasyl,代码行数:29,代码来源:test_blacklist.py

示例2: test_blacklist_homepage

def test_blacklist_homepage(app):
    """
    Assert that changes to the blacklist apply to the home page immediately.
    """
    submitting_user = db_utils.create_user()
    viewing_user = db_utils.create_user()
    tag1 = db_utils.create_tag('walrus')
    tag2 = db_utils.create_tag('penguin')

    s1 = db_utils.create_submission(submitting_user, rating=ratings.GENERAL.code, subtype=1010)
    db_utils.create_submission_tag(tag1, s1)

    s2 = db_utils.create_submission(submitting_user, rating=ratings.GENERAL.code, subtype=1010)
    db_utils.create_submission_tag(tag2, s2)

    cookie = db_utils.create_session(viewing_user)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2

    app.post('/manage/tagfilters',
             {'title': 'walrus', 'rating': str(ratings.GENERAL.code), 'do': 'create'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 1

    app.post('/manage/tagfilters',
             {'title': 'walrus', 'rating': str(ratings.GENERAL.code), 'do': 'remove'},
             headers={'Cookie': cookie}, status=303)

    resp = app.get('/', headers={'Cookie': cookie})
    assert len(resp.html.select('#home-art .thumb')) == 2
开发者ID:Weasyl,项目名称:weasyl,代码行数:33,代码来源:test_blacklist.py

示例3: test_edit_global_tag_restrictions_when_user_is_not_a_director_fails

def test_edit_global_tag_restrictions_when_user_is_not_a_director_fails(monkeypatch):
    normal_user_id = db_utils.create_user()
    developer_user_id = db_utils.create_user()
    mod_user_id = db_utils.create_user()
    admin_user_id = db_utils.create_user()
    technical_user_id = db_utils.create_user()

    monkeypatch.setattr(staff, 'DEVELOPERS', frozenset([developer_user_id]))
    monkeypatch.setattr(staff, 'MODS', frozenset([mod_user_id]))
    monkeypatch.setattr(staff, 'ADMINS', frozenset([admin_user_id]))
    monkeypatch.setattr(staff, 'TECHNICAL', frozenset([technical_user_id]))

    # Function under test; users and staff (except director) should error
    with pytest.raises(WeasylError) as err:
        searchtag.edit_global_tag_restrictions(normal_user_id, combined_tags)
    assert 'InsufficientPermissions' == err.value.value
    with pytest.raises(WeasylError) as err:
        searchtag.edit_global_tag_restrictions(developer_user_id, combined_tags)
    assert 'InsufficientPermissions' == err.value.value
    with pytest.raises(WeasylError) as err:
        searchtag.edit_global_tag_restrictions(mod_user_id, combined_tags)
    assert 'InsufficientPermissions' == err.value.value
    with pytest.raises(WeasylError) as err:
        searchtag.edit_global_tag_restrictions(admin_user_id, combined_tags)
    assert 'InsufficientPermissions' == err.value.value
    with pytest.raises(WeasylError) as err:
        searchtag.edit_global_tag_restrictions(technical_user_id, combined_tags)
    assert 'InsufficientPermissions' == err.value.value
开发者ID:Syfaro,项目名称:weasyl,代码行数:28,代码来源:test_edit_global_tag_restrictions.py

示例4: test_attempt_setting_tags_when_some_tags_have_been_restricted

def test_attempt_setting_tags_when_some_tags_have_been_restricted():
    """
    Verify that tags are excluded from being added to a submission's tags if the tag is restricted
    """
    userid_owner = db_utils.create_user()
    userid_tag_adder = db_utils.create_user()
    journalid = db_utils.create_journal(userid_owner)
    charid = db_utils.create_character(userid_owner)
    submitid = db_utils.create_submission(userid_owner)
    restricted_tag = searchtag.parse_restricted_tags("pearl")
    searchtag.edit_user_tag_restrictions(userid_owner, restricted_tag)

    searchtag.associate(userid_tag_adder, tags, submitid=submitid)
    searchtag.associate(userid_tag_adder, tags, charid=charid)
    searchtag.associate(userid_tag_adder, tags, journalid=journalid)

    # Verify that the "pearl" tag was not added
    submission_tags = searchtag.select(submitid=submitid)
    assert tags_two == set(submission_tags)

    character_tags = searchtag.select(charid=charid)
    assert tags_two == set(character_tags)

    journal_tags = searchtag.select(journalid=journalid)
    assert tags_two == set(journal_tags)
开发者ID:Syfaro,项目名称:weasyl,代码行数:25,代码来源:test_associate.py

示例5: test_retag_no_owner_remove

    def test_retag_no_owner_remove(self):
        config = CharSettings({'disallow-others-tag-removal'}, {}, {})
        owner = db_utils.create_user(config=config)
        tagger = db_utils.create_user()
        s = db_utils.create_submission(owner, rating=ratings.GENERAL.code)

        searchtag.associate(owner, {'orange'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['orange'])

        searchtag.associate(tagger, {'apple', 'tomato'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['apple', 'orange', 'tomato'])

        searchtag.associate(tagger, {'tomato'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['orange', 'tomato'])

        searchtag.associate(owner, {'kale'}, submitid=s)
        self.assertEqual(
            submission.select_view(owner, s, ratings.GENERAL.code)['tags'],
            ['kale'])
开发者ID:Syfaro,项目名称:weasyl,代码行数:25,代码来源:test_submission.py

示例6: test_reply_when_blocked

def test_reply_when_blocked(app):
    user1 = db_utils.create_user(username='user1')
    user2 = db_utils.create_user(username='user2')
    session1 = db_utils.create_session(user1)
    session2 = db_utils.create_session(user2)

    app.post('/notes/compose', {
        'recipient': 'user2',
        'title': 'Title',
        'content': 'Content',
    }, headers={'Cookie': session1}, status=303)

    app.post('/ignoreuser', {
        'userid': str(user2),
        'action': 'ignore',
    }, headers={'Cookie': session1}, status=303)

    def try_send(status):
        app.post('/notes/compose', {
            'recipient': 'user1',
            'title': 'Title',
            'content': 'Content',
        }, headers={'Cookie': session2}, status=status)

    try_send(422)

    d.engine.execute("UPDATE profile SET config = config || 'z' WHERE userid = %(user)s", user=user1)

    try_send(422)
开发者ID:Weasyl,项目名称:weasyl,代码行数:29,代码来源:test_notes.py

示例7: test_moderators_and_above_can_add_restricted_tags_successfully

def test_moderators_and_above_can_add_restricted_tags_successfully(monkeypatch):
    """
    Moderators (and admins, technical, and directors) can add restricted tags to content.
    Developers are not included in this test, as they are for all intents and purposes just
      normal user accounts.
    """
    userid_owner = db_utils.create_user()
    mod_tag_adder = db_utils.create_user()
    monkeypatch.setattr(staff, 'MODS', frozenset([mod_tag_adder]))
    journalid = db_utils.create_journal(userid_owner)
    charid = db_utils.create_character(userid_owner)
    submitid = db_utils.create_submission(userid_owner)
    restricted_tag = searchtag.parse_restricted_tags("pearl")
    searchtag.edit_user_tag_restrictions(userid_owner, restricted_tag)

    searchtag.associate(mod_tag_adder, tags, submitid=submitid)
    searchtag.associate(mod_tag_adder, tags, charid=charid)
    searchtag.associate(mod_tag_adder, tags, journalid=journalid)

    # Verify that all tags were added successfully. 'pearl' is restricted.
    submission_tags = searchtag.select(submitid=submitid)
    assert tags == set(submission_tags)

    character_tags = searchtag.select(charid=charid)
    assert tags == set(character_tags)

    journal_tags = searchtag.select(journalid=journalid)
    assert tags == set(journal_tags)
开发者ID:Syfaro,项目名称:weasyl,代码行数:28,代码来源:test_associate.py

示例8: test_search_blocked_tags

def test_search_blocked_tags(db, rating, block_rating):
    owner = db_utils.create_user()
    viewer = db_utils.create_user()

    allowed_tag = db_utils.create_tag('walrus')
    blocked_tag = db_utils.create_tag('penguin')

    db_utils.create_blocktag(viewer, blocked_tag, block_rating.code)

    s1 = db_utils.create_submission(owner, rating=rating.code)
    db_utils.create_submission_tag(allowed_tag, s1)
    db_utils.create_submission_tag(blocked_tag, s1)

    s2 = db_utils.create_submission(owner, rating=rating.code)
    db_utils.create_submission_tag(allowed_tag, s2)

    s3 = db_utils.create_submission(owner, rating=rating.code)
    db_utils.create_submission_tag(blocked_tag, s3)

    def check(term, n_results):
        results, _, _ = search.select(
            search=search.Query.parse(term, 'submit'),
            userid=viewer, rating=ratings.EXPLICIT.code, limit=100,
            cat=None, subcat=None, within='', backid=None, nextid=None)

        assert len(results) == n_results

    if rating < block_rating:
        check(u'walrus', 2)
        check(u'penguin', 2)
    else:
        check(u'walrus', 1)
        check(u'penguin', 0)
开发者ID:charmander,项目名称:weasyl,代码行数:33,代码来源:test_search.py

示例9: test_friends_only

    def test_friends_only(self):
        user1 = db_utils.create_user()
        user2 = db_utils.create_user()
        db_utils.create_submission(user1, rating=ratings.GENERAL.code, settings=CharSettings({'friends-only'}, {}, {}))

        # poster can view their submission
        self.assertEqual(
            1, len(submission.select_list(user1, ratings.GENERAL.code, 10)))

        # but a non-friend or a non-logged in user cannot
        self.assertEqual(
            0, len(submission.select_list(None, ratings.GENERAL.code, 10)))
        self.assertEqual(
            0, len(submission.select_list(user2, ratings.GENERAL.code, 10)))

        # user with a pending friendship cannot view
        db_utils.create_friendship(user1, user2, settings=CharSettings({'pending'}, {}, {}))
        self.assertEqual(
            0, len(submission.select_list(user2, ratings.GENERAL.code, 10)))

        # but a friend can
        d.sessionmaker().query(users.Friendship).delete()
        db_utils.create_friendship(user1, user2)
        self.assertEqual(
            1, len(submission.select_list(user2, ratings.GENERAL.code, 10)))
开发者ID:0x15,项目名称:weasyl,代码行数:25,代码来源:test_submission.py

示例10: test_setting_alias_fails_if_target_alias_exists

def test_setting_alias_fails_if_target_alias_exists():
    user_id = db_utils.create_user()
    user_id_existing = db_utils.create_user()
    d.engine.execute("INSERT INTO useralias VALUES (%(id)s, %(alias)s, 'p')", id=user_id_existing, alias="existingalias")
    with pytest.raises(WeasylError) as err:
        useralias.set(user_id, "existingalias")
    assert 'usernameExists' == err.value.value
开发者ID:Syfaro,项目名称:weasyl,代码行数:7,代码来源:test_set.py

示例11: test_blocked_tag

    def test_blocked_tag(self):
        user1 = db_utils.create_user()
        user2 = db_utils.create_user()

        # submission s1 has a walrus in it, but user2 does not like walruses
        s1 = db_utils.create_submission(user1, rating=ratings.GENERAL.code)
        tag1 = db_utils.create_tag("walrus")
        db_utils.create_submission_tag(tag1, s1)
        db_utils.create_blocktag(user2, tag1, ratings.GENERAL.code)
        self.assertEqual(
            0, len(submission.select_list(user2, ratings.GENERAL.code, 10)))

        # submission s2 has a penguin in it. user2 does not want to see penguins in
        # adult circumstances, but s2 is general, so visibility is OK
        s2 = db_utils.create_submission(user1, rating=ratings.GENERAL.code)
        tag2 = db_utils.create_tag("penguin")
        db_utils.create_submission_tag(tag2, s2)
        db_utils.create_blocktag(user2, tag2, ratings.EXPLICIT.code)
        self.assertEqual(
            1, len(submission.select_list(user2, ratings.EXPLICIT.code, 10)))

        # submission s3 has penguins on it in adult situations, but User2
        # is okay with that if it's one of User2's own submissions.
        s3 = db_utils.create_submission(user2, rating=ratings.EXPLICIT.code)
        db_utils.create_submission_tag(tag2, s3)
        self.assertEqual(
            2, len(submission.select_list(user2, ratings.EXPLICIT.code, 10)))
开发者ID:0x15,项目名称:weasyl,代码行数:27,代码来源:test_submission.py

示例12: test_passwordMismatch_WeasylError_if_supplied_passwords_dont_match

def test_passwordMismatch_WeasylError_if_supplied_passwords_dont_match():
    db_utils.create_user(email_addr=email_addr, username=user_name)
    form = Bag(email=email_addr, username=user_name, day=arrow.now().day,
               month=arrow.now().month, year=arrow.now().year, token=token,
               password='qwe', passcheck='asd')
    with pytest.raises(WeasylError) as err:
        resetpassword.reset(form)
    assert 'passwordMismatch' == err.value.value
开发者ID:Syfaro,项目名称:weasyl,代码行数:8,代码来源:test_reset.py

示例13: test_usernames_must_be_unique

def test_usernames_must_be_unique():
    db_utils.create_user(username=user_name, email_addr="[email protected]")
    form = Bag(username=user_name, password='0123456789', passcheck='0123456789',
               email=email_addr, emailcheck=email_addr,
               day='12', month='12', year=arrow.now().year - 19)
    with pytest.raises(WeasylError) as err:
        login.create(form)
    assert 'usernameExists' == err.value.value
开发者ID:makyo,项目名称:weasyl,代码行数:8,代码来源:test_create.py

示例14: setUp

 def setUp(self):
     self.user1 = db_utils.create_user()
     self.user2 = db_utils.create_user()
     self.friend1 = db_utils.create_user()
     db_utils.create_friendship(self.user1, self.friend1)
     self.count = 20
     self.pivot = 5
     s = db_utils.create_journals(self.count, self.user1, ratings.GENERAL.code)
     self.pivotid = s[self.pivot]
开发者ID:hyena,项目名称:weasyl,代码行数:9,代码来源:test_journal.py

示例15: test_forgotpasswordRecordMissing_WeasylError_if_reset_record_not_found

def test_forgotpasswordRecordMissing_WeasylError_if_reset_record_not_found():
    db_utils.create_user(email_addr=email_addr, username=user_name)
    password = '01234567890123'
    form = Bag(email=email_addr, username=user_name, day=arrow.now().day,
               month=arrow.now().month, year=arrow.now().year, token=token,
               password=password, passcheck=password)
    # Technically we did this in the above test, but for completeness, target it alone
    with pytest.raises(WeasylError) as err:
        resetpassword.reset(form)
    assert 'forgotpasswordRecordMissing' == err.value.value
开发者ID:Syfaro,项目名称:weasyl,代码行数:10,代码来源:test_reset.py


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