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)
test_forms.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录