Esempio n. 1
0
def methodTest(verb,
               url,
               request_input={},
               accept='text/json',
               contentType=None,
               output={},
               expireTime=0,
               secure=False,
               secureParam={}):

    data, code, content_type, response = makeRequest(url, request_input, verb,
                                                     accept, contentType,
                                                     secure, secureParam)

    keyMap = {
        'code': code,
        'data': data,
        'type': content_type,
        'response': response
    }
    for key, value in output.items():
        msg = 'Got a return %s != %s (got %s, type %s) (data %s, type %s)' \
                % (keyMap[key], value, keyMap[key], type(keyMap[key]), data, type(data))
        assert keyMap[key] == value, msg

    expires = response.getheader('Expires')
    if expireTime != 0:
        timeStamp = make_rfc_timestamp(expireTime)
        assert expires == timeStamp,\
                 'Expires header incorrect (%s) != (%s)' % (expires, timeStamp)

    return data, expires
Esempio n. 2
0
def methodTest(verb, url, input={}, accept='text/json', contentType = None, output={} , expireTime=0):
    
    data, code, type, response = makeRequest(url, input, verb, accept, contentType)
    
    keyMap = {'code': code, 'data': data, 'type': type, 'response': response}
    for key, value in output.items():
        assert keyMap[key] == value, \
            'Got a return %s != %s (got %s) (data %s)' % (key, value, keyMap[key], data)
    
    expires = response.getheader('Expires')
    if expireTime != 0:
        timeStamp = make_rfc_timestamp(expireTime)
        print expires
        print timeStamp        
        assert expires == timeStamp,\
                 'Expires header incorrect (%s) != (%s)' % (expires % timeStamp)
        
    return data, expires
Esempio n. 3
0
def methodTest(verb, url, request_input={}, accept='text/json', contentType=None,
               output={}, expireTime=0, secure=False, secureParam={}):
    data, code, content_type, response = makeRequest(url, request_input, verb,
                                                     accept, contentType,
                                                     secure, secureParam)

    keyMap = {'code': code, 'data': data, 'type': content_type, 'response': response}
    for key, value in output.items():
        msg = 'Got a return %s != %s (got %s, type %s) (data %s, type %s)' \
              % (keyMap[key], value, keyMap[key], type(keyMap[key]), data, type(data))
        assert keyMap[key] == value, msg

    expires = response.getheader('Expires')
    if expireTime != 0:
        timeStamp = make_rfc_timestamp(expireTime)
        assert expires == timeStamp, \
            'Expires header incorrect (%s) != (%s)' % (expires, timeStamp)

    return data, expires
Esempio n. 4
0
def methodTest(
    verb,
    url,
    request_input={},
    accept="text/json",
    contentType=None,
    output={},
    expireTime=0,
    secure=False,
    secureParam={},
):

    data, code, content_type, response = makeRequest(url, request_input, verb, accept, contentType, secure, secureParam)

    keyMap = {"code": code, "data": data, "type": content_type, "response": response}
    for key, value in output.items():
        assert keyMap[key] == value, "Got a return %s != %s (got %s) (data %s)" % (key, value, keyMap[key], data)

    expires = response.getheader("Expires")
    if expireTime != 0:
        timeStamp = make_rfc_timestamp(expireTime)
        assert expires == timeStamp, "Expires header incorrect (%s) != (%s)" % (expires % timeStamp)

    return data, expires