def test_encode(self): fields = {'a': '1', 'b': '2'} files = [{ 'filename': 'key1', 'data': 'data1', 'mime_type': 'application/octet-stream', }, { 'filename': 'key2', 'data': 'data2', 'mime_type': 'application/octet-stream', }] content_type, mr = rpc.Client('localhost').encode_multipart_formdata( fields, files) t, b = encode_multipart_formdata2([('a', '1'), ('b', '2')], [('file', 'key1', 'data1'), ('file', 'key2', 'data2')]) assert t == content_type assert len(b) == mr.length()
def test4(): files = [{'filename': u'你好', 'data': u'你好', 'mime_type': ''}] _, body = rpc.Client('localhost').encode_multipart_formdata(None, files) return len(body.read())