test_forms.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:NZ-ORCID-Hub 作者: Royal-Society-of-New-Zealand 项目源码 文件源码
def test_orcid_validation(test_form):  # noqa

    orcid_id = StringField("ORCID iD", [
        validate_orcid_id_field,
    ])
    orcid_id.data = "0000-0001-8228-7153"
    validate_orcid_id_field(test_form, orcid_id)

    orcid_id.data = "INVALID FORMAT"
    with pytest.raises(ValueError) as excinfo:
        validate_orcid_id_field(test_form, orcid_id)
    assert "Invalid ORCID iD. It should be in the form of 'xxxx-xxxx-xxxx-xxxx' where x is a digit." in str(
        excinfo.value)

    orcid_id.data = "0000-0001-8228-7154"
    with pytest.raises(ValueError) as excinfo:
        validate_orcid_id_field(test_form, orcid_id)
    assert "Invalid ORCID iD checksum. Make sure you have entered correct ORCID iD." in str(
        excinfo.value)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号