def t(transfer, encoding): print "\n---> Testing transfer=%s, encoding=%s" % (transfer, encoding) o = transports.Output(transfer=transfer, encoding=encoding) o.process(REFERENCE) print "Output: data length: %s; headers: %s" % (len(o.data), o.headers) i = transports.Input(o.headers) i.read(StringIO(o.data)) io = i.decode() io.seek(0, 0) data = io.read() assert (REFERENCE == data)
def test_blob(transfer, encoding): print "\n---> BLOB Testing transfer=%s, encoding=%s" % (transfer, encoding) o = transports.Output(transfer=transfer, encoding=encoding) o.set_header('Content-Type', 'application/binary') o.process(REFERENCE_BLOB) headers = o.headers # Added by the connection layer headers['Content-Length'] = len(o.data) print "Output: headers: %s" % headers.items() i = transports.Input(headers) io = i.decode(StringIO(o.data)) assert (string.lower(i.type) == 'application/binary') io.seek(0, 0) data = io.read() assert (REFERENCE_BLOB == data)
def test_xmlrpc(transfer, encoding): print "\n---> XML Testing transfer=%s, encoding=%s" % (transfer, encoding) data = xmlrpclib.dumps((REFERENCE_XML, ), methodresponse=1) o = transports.Output(transfer=transfer, encoding=encoding) o.set_header('Content-Type', 'text/xml') o.process(data) headers = o.headers # Added by the connection layer headers['Content-Length'] = len(o.data) print "Output: headers: %s" % headers.items() i = transports.Input(headers) io = i.decode(StringIO(o.data)) assert (string.lower(i.type) == 'text/xml') io.seek(0, 0) data = io.read() params, dummy = xmlrpclib.loads(data) assert (REFERENCE_XML == params[0])