def test_accepts_valid_input(self, pyramid_csrf_request): schema = 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", })
def test_accepts_valid_input(self, pyramid_csrf_request): schema = 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', })
def test_accepts_valid_input(self, pyramid_csrf_request): schema = 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", } )
def __init__(self, request): self.request = request self.schema = EditProfileSchema().bind(request=self.request) self.form = request.create_form(self.schema, buttons=(_("Save"), ), use_inline_editing=True)
def test_rejects_invalid_url(self, pyramid_csrf_request, validate_url): validate_url.side_effect = ValueError("Invalid URL") schema = 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"
def test_rejects_invalid_orcid(self, pyramid_csrf_request, validate_orcid): validate_orcid.side_effect = ValueError("Invalid ORCID") schema = EditProfileSchema().bind(request=pyramid_csrf_request) with pytest.raises(colander.Invalid) as exc: schema.deserialize({"orcid": "abcdef"}) assert exc.value.asdict()["orcid"] == "Invalid ORCID"