コード例 #1
0
 def test_accepts_valid_input(self, pyramid_csrf_request):
     schema = schemas.EditProfileSchema().bind(request=pyramid_csrf_request)
     schema.deserialize({
         'display_name': 'Michael Granitzer',
         'description': 'Professor at University of Passau',
         'link': 'http://mgrani.github.io/',
         'location': 'Bavaria, Germany',
         'orcid': '0000-0003-3566-5507',
     })
コード例 #2
0
 def test_rejects_invalid_url(self, pyramid_csrf_request, validate_url):
     validate_url.side_effect = ValueError('Invalid URL')
     schema = schemas.EditProfileSchema().bind(request=pyramid_csrf_request)
     with pytest.raises(colander.Invalid) as exc:
         schema.deserialize({'link': '"invalid URL"'})
     assert exc.value.asdict()['link'] == 'Invalid URL'
コード例 #3
0
 def test_rejects_invalid_orcid(self, pyramid_csrf_request, validate_orcid):
     validate_orcid.side_effect = ValueError('Invalid ORCID')
     schema = schemas.EditProfileSchema().bind(request=pyramid_csrf_request)
     with pytest.raises(colander.Invalid) as exc:
         schema.deserialize({'orcid': 'abcdef'})
     assert exc.value.asdict()['orcid'] == 'Invalid ORCID'
コード例 #4
0
 def __init__(self, request):
     self.request = request
     self.schema = schemas.EditProfileSchema().bind(request=self.request)
     self.form = request.create_form(self.schema,
                                     buttons=(_('Save'), ),
                                     use_inline_editing=True)