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

Python db_utils.create_session函数代码示例

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

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



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

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


示例2: test_create_notifications

def test_create_notifications(app, monkeypatch):
    admin_user = db_utils.create_user()
    normal_user = db_utils.create_user()
    admin_cookie = db_utils.create_session(admin_user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([admin_user]))

    resp = app.post('/admincontrol/siteupdate', _FORM, headers={'Cookie': admin_cookie}).follow()
    assert resp.html.find(None, 'content').h3.string == _FORM['title']

    normal_cookie = db_utils.create_session(normal_user)
    resp = app.get('/messages/notifications', headers={'Cookie': normal_cookie})
    assert list(resp.html.find(id='header-messages').find(title='Notifications').stripped_strings)[1] == '1'
    assert resp.html.find(id='site_updates').find(None, 'item').a.string == _FORM['title']
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:13,代码来源:test_site_updates.py


示例3: test_edit_restricted

def test_edit_restricted(app, monkeypatch, site_updates):
    _, updates = site_updates

    resp = app.get('/site-updates/%d/edit' % (updates[-1].updateid,))
    assert resp.html.find(id='error_content').contents[0].strip() == errorcode.unsigned
    resp = app.post('/site-updates/%d' % (updates[-1].updateid,), _FORM)
    assert resp.html.find(id='error_content').contents[0].strip() == errorcode.unsigned

    user = db_utils.create_user()
    cookie = db_utils.create_session(user)

    resp = app.get('/site-updates/%d/edit' % (updates[-1].updateid,), headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission
    resp = app.post('/site-updates/%d' % (updates[-1].updateid,), _FORM, headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission

    monkeypatch.setattr(staff, 'TECHNICAL', frozenset([user]))
    monkeypatch.setattr(staff, 'MODS', frozenset([user]))

    resp = app.get('/site-updates/%d/edit' % (updates[-1].updateid,), headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission
    resp = app.post('/site-updates/%d' % (updates[-1].updateid,), _FORM, headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission

    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.get('/site-updates/%d/edit' % (updates[-1].updateid,), headers={'Cookie': cookie})
    assert resp.html.find(id='error_content') is None
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:28,代码来源:test_site_updates.py


示例4: test_profile_friend

def test_profile_friend(app, journal_user):
    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    db_utils.create_friendship(user, journal_user)

    resp = app.get('/~journal_test', headers={'Cookie': cookie})
    assert resp.html.find(id='user-journal').h4.string == u'Recent journal'
开发者ID:Weasyl,项目名称:weasyl,代码行数:7,代码来源:test_journals.py


示例5: test_create_restricted

def test_create_restricted(app, monkeypatch):
    resp = app.get('/admincontrol/siteupdate')
    assert resp.html.find(id='error_content').contents[0].strip() == errorcode.unsigned
    resp = app.post('/admincontrol/siteupdate', _FORM)
    assert resp.html.find(id='error_content').contents[0].strip() == errorcode.unsigned

    user = db_utils.create_user()
    cookie = db_utils.create_session(user)

    resp = app.get('/admincontrol/siteupdate', headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission
    resp = app.post('/admincontrol/siteupdate', _FORM, headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission

    monkeypatch.setattr(staff, 'TECHNICAL', frozenset([user]))
    monkeypatch.setattr(staff, 'MODS', frozenset([user]))

    resp = app.get('/admincontrol/siteupdate', headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission
    resp = app.post('/admincontrol/siteupdate', _FORM, headers={'Cookie': cookie})
    assert resp.html.find(id='error_content').p.string == errorcode.permission

    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.get('/admincontrol/siteupdate', headers={'Cookie': cookie})
    assert resp.html.find(id='error_content') is None
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:26,代码来源:test_site_updates.py


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


示例7: test_create_csrf

def test_create_csrf(app, monkeypatch):
    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.post('/admincontrol/siteupdate', _FORM, headers={'Cookie': cookie}, status=403)
    assert resp.html.find(id='error_content').p.string == errorcode.token
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:7,代码来源:test_site_updates.py


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


示例9: test_create

def test_create(app, journal_user):
    cookie = db_utils.create_session(journal_user)

    app.post('/submit/journal', {'title': u'Created journal', 'rating': '10', 'content': u'A journal'}, headers={'Cookie': cookie})

    resp = app.get('/~journal_test')
    assert resp.html.find(id='user-journal').h4.string == u'Created journal'
开发者ID:Weasyl,项目名称:weasyl,代码行数:7,代码来源:test_journals.py


示例10: test_create

def test_create(app, monkeypatch):
    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.post('/admincontrol/siteupdate', _FORM, headers={'Cookie': cookie}).follow()
    assert resp.html.find(None, 'content').h3.string == _FORM['title']
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:7,代码来源:test_site_updates.py


示例11: test_edit_nonexistent

def test_edit_nonexistent(app, monkeypatch, site_updates):
    _, updates = site_updates

    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    app.post('/site-updates/%d' % (updates[-1].updateid + 1,), _FORM, headers={'Cookie': cookie}, status=404)
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:8,代码来源:test_site_updates.py


示例12: test_edit_csrf

def test_edit_csrf(app, monkeypatch, site_updates):
    _, updates = site_updates

    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.post('/site-updates/%d' % (updates[-1].updateid,), _FORM, headers={'Cookie': cookie}, status=403)
    assert resp.html.find(id='error_content').p.string == errorcode.token
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:9,代码来源:test_site_updates.py


示例13: test_edit

def test_edit(app, monkeypatch, site_updates):
    _, updates = site_updates

    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.post('/site-updates/%d' % (updates[-1].updateid,), _FORM, headers={'Cookie': cookie}).follow()
    assert resp.html.find(None, 'content').h3.string == _FORM['title']
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:9,代码来源:test_site_updates.py


示例14: test_create_validation

def test_create_validation(app, monkeypatch):
    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.post('/admincontrol/siteupdate', {'title': u'', 'content': u'Content'}, headers={'Cookie': cookie}, status=422)
    assert resp.html.find(id='error_content').p.string == errorcode.error_messages['titleInvalid']

    resp = app.post('/admincontrol/siteupdate', {'title': u'Title', 'content': u''}, headers={'Cookie': cookie}, status=422)
    assert resp.html.find(id='error_content').p.string == errorcode.error_messages['contentInvalid']
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:10,代码来源:test_site_updates.py


示例15: test_owner_reupload

def test_owner_reupload(character_user, character):
    cookie = db_utils.create_session(character_user)

    resp = app.post('/reupload/character', {
        'targetid': str(character),
        'submitfile': webtest.Upload('wesley', _static('images/wesley-draw.png'), 'image/png'),
    }, headers={'Cookie': cookie}).follow()

    image_url = resp.html.find(id='detail-art').a['href']
    assert _read_character_image(image_url).tobytes() == _read_static_image('images/wesley-draw.png').tobytes()
开发者ID:Syfaro,项目名称:weasyl,代码行数:10,代码来源:test_characters.py


示例16: test_owner_edit_details

def test_owner_edit_details(character_user, character):
    cookie = db_utils.create_session(character_user)

    form = dict(
        _BASE_FORM,
        charid=str(character),
        title=u'Edited name',
    )

    resp = app.post('/edit/character', form, headers={'Cookie': cookie}).follow()
    assert resp.html.find(id='detail-bar-title').string == u'Edited name'
开发者ID:Syfaro,项目名称:weasyl,代码行数:11,代码来源:test_characters.py


示例17: _character

def _character(db, character_user, no_csrf):
    cookie = db_utils.create_session(character_user)

    form = dict(
        _BASE_FORM,
        submitfile=webtest.Upload('wesley', _static('images/wesley1.png'), 'image/png'),
    )

    resp = app.post('/submit/character', form, headers={'Cookie': cookie}).follow(headers={'Cookie': cookie})
    charid = int(resp.html.find('input', {'name': 'charid'})['value'])

    return charid
开发者ID:Syfaro,项目名称:weasyl,代码行数:12,代码来源:test_characters.py


示例18: test_edit_validation

def test_edit_validation(app, monkeypatch, site_updates):
    _, updates = site_updates

    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))

    resp = app.post('/site-updates/%d' % (updates[-1].updateid,), {'title': u'', 'content': u'Content'}, headers={'Cookie': cookie}, status=422)
    assert resp.html.find(id='error_content').p.string == errorcode.error_messages['titleInvalid']

    resp = app.post('/site-updates/%d' % (updates[-1].updateid,), {'title': u'Title', 'content': u''}, headers={'Cookie': cookie}, status=422)
    assert resp.html.find(id='error_content').p.string == errorcode.error_messages['contentInvalid']
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:12,代码来源:test_site_updates.py


示例19: test_csrf_on_journal_edit

def test_csrf_on_journal_edit(app, journal_user):
    # Test purpose: Verify that a CSRF token is required to submit a journal entry.
    cookie = db_utils.create_session(journal_user)
    journalid = db_utils.create_journal(journal_user, "Test", content="Test")

    resp = app.post(
        '/edit/journal',
        {'title': u'Created journal', 'rating': '10', 'content': u'A journal', 'journalid': journalid},
        headers={'Cookie': cookie},
        status=403,
    )
    assert resp.html.find(id='error_content').p.text.startswith(u"This action appears to have been performed illegitimately")
开发者ID:Weasyl,项目名称:weasyl,代码行数:12,代码来源:test_journals.py


示例20: test_list

def test_list(app, monkeypatch, site_updates):
    _, updates = site_updates
    resp = app.get('/site-updates/')
    assert len(resp.html.findAll(None, 'text-post-item')) == 3
    assert resp.html.find(None, 'text-post-actions') is None
    assert len(resp.html.findAll(None, 'text-post-group-header')) == 1

    user = db_utils.create_user()
    cookie = db_utils.create_session(user)
    monkeypatch.setattr(staff, 'ADMINS', frozenset([user]))
    resp = app.get('/site-updates/', headers={'Cookie': cookie})
    assert len(resp.html.findAll(None, 'text-post-item')) == 3
    assert resp.html.find(None, 'text-post-actions').a['href'] == '/site-updates/%d/edit' % (updates[-1].updateid,)
开发者ID:kfkitsune,项目名称:wzl-test,代码行数:13,代码来源:test_site_updates.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python db_utils.create_submission函数代码示例发布时间:2022-05-26
下一篇:
Python profile.select_userinfo函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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