def prepare_request(request, openid=True): """ Given a raw request coming from a RequestFactory, process it using the middleware and (if openid is True) attach an openid to it """ if openid: request.openid = OpenID('http://foo.example.com/', 1302206357) for m in (CommonMiddleware, SessionMiddleware, AuthenticationMiddleware): m().process_request(request) return request
def test_openid(self): self.assertEqual( json.loads(JSONEncoder().encode({'k': OpenID(openid='a', issued='b')})), {"k": {"openid": "a", "attrs": {}, "sreg_": {}, "ax_": {}, "issued": "b", "__class__": "OpenID"}} )