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


Python Form.confirmed方法代码示例

本文整理汇总了Python中formspree.forms.models.Form.confirmed方法的典型用法代码示例。如果您正苦于以下问题:Python Form.confirmed方法的具体用法?Python Form.confirmed怎么用?Python Form.confirmed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在formspree.forms.models.Form的用法示例。


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

示例1: test_unconfirm_process

# 需要导入模块: from formspree.forms.models import Form [as 别名]
# 或者: from formspree.forms.models.Form import confirmed [as 别名]
def test_unconfirm_process(client, msend):
    # confirm some forms for the same email address
    f1 = Form('[email protected]', 'testwebsite.com')
    f1.confirmed = True
    DB.session.add(f1)

    f2 = Form('[email protected]', 'othertestwebsite.com')
    f2.confirmed = True
    DB.session.add(f2)

    f3 = Form('[email protected]', 'anothertestwebsite.com')
    f3.confirmed = True
    DB.session.add(f3)
    DB.session.commit()

    # try a submission
    r = client.post('/[email protected]',
        headers = {'Referer': 'http://testwebsite.com'},
        data={'name': 'carol'}
    )
    assert msend.called
    request_unconfirm_url = url_for('request_unconfirm_form', form_id=f1.id, _external=True)
    assert request_unconfirm_url in msend.call_args[1]['text']
    msend.reset_mock()

    # this should send a confirmation email
    r = client.get(request_unconfirm_url)
    assert r.status_code == 200
    assert msend.called

    unconfirm_url_with_digest = url_for(
        'unconfirm_form',
        form_id=f1.id,
        digest=f1.unconfirm_digest(),
        _external=True
    )
    assert unconfirm_url_with_digest in msend.call_args[1]['text']
    msend.reset_mock()
    
    # unconfirm this
    r = client.get(unconfirm_url_with_digest)
    assert f1.confirmed == False

    # should show a page with the other options
    assert r.status_code == 200
    assert 'Select all' in r.data.decode('utf-8')
    assert f2.host in r.data.decode('utf-8')
    assert f3.host in r.data.decode('utf-8')

    unconfirm_multiple_url = url_for('unconfirm_multiple')
    assert unconfirm_multiple_url in r.data.decode('utf-8')

    # we can use unconfirm_multiple to unconfirm f2
    assert f2.confirmed == True
    r = client.post(unconfirm_multiple_url, data={'form_ids': [f2.id]})
    assert r.status_code == 200
    assert 'Success' in r.data.decode('utf-8')
    assert f2.confirmed == False
开发者ID:ajabo,项目名称:formspree,代码行数:60,代码来源:test_unsubscribe.py


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