def response_mode(self, request, **kwargs): resp_mode = request["response_mode"] if resp_mode == "form_post": msg = FORM_POST.format( inputs=inputs(kwargs["response_args"].to_dict()), action=kwargs["return_uri"], ) kwargs.update({ "response_msg": msg, "content_type": 'text/html', "response_placement": "body" }) elif resp_mode == "fragment": if "fragment_enc" in kwargs: if not kwargs["fragment_enc"]: # Can't be done raise InvalidRequest("wrong response_mode") else: kwargs["fragment_enc"] = True elif resp_mode == "query": if "fragment_enc" in kwargs: if kwargs["fragment_enc"]: # Can't be done raise InvalidRequest("wrong response_mode") else: raise InvalidRequest("Unknown response_mode") return kwargs
def test_inputs(): elems = inputs(dict(foo="bar", home="stead")) test_elems = ( '<input type="hidden" name="foo" value="bar"/>', '<input type="hidden" name="home" value="stead"/>', ) assert test_elems[0] in elems and test_elems[1] in elems