Exemplo n.º 1
0
 def test_msgpack_valid(self):
     """ Environ: Request.msgpack property. """
     test = dict(a=5, b='test', c=[1,2,3])
     e = {'CONTENT_TYPE': 'application/msgpack; charset=UTF-8'}
     wsgiref.util.setup_testing_defaults(e)
     e['wsgi.input'].write(tob(msgpack_dumps(test)))
     e['wsgi.input'].seek(0)
     e['CONTENT_LENGTH'] = str(len(msgpack_dumps(test)))
     self.assertEqual(BaseRequest(e).msgpack, test)
Exemplo n.º 2
0
 def test_msgpack_noheader(self):
     """ Environ: Request.msgpack property with missing content-type header. """
     test = dict(a=5, b='test', c=[1,2,3])
     e = {}
     wsgiref.util.setup_testing_defaults(e)
     e['wsgi.input'].write(tob(msgpack_dumps(test)))
     e['wsgi.input'].seek(0)
     e['CONTENT_LENGTH'] = str(len(msgpack_dumps(test)))
     self.assertEqual(BaseRequest(e).msgpack, None)