示例#1
0
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)
示例#2
0
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)
示例#3
0
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])