Package tlib :: Package base :: Module HttpRequestor :: Class HttpRequestor |
[hide private]
[frames] | no frames]

# Class HttpRequestor

source code

    object --+
             |
            HttpRequestor

Helper class for sending requests of HTTP with GET and POST

Instance Methods | [hide private]
__init__(self, api_url, logger) Constructor for class | source code
make_path_params(self, params) Constucts a request with the parameters formated in path parameter format. | source code
make_query_params(self, params) Constucts a request with the parameters formated in query parameter format. | source code
make_get_request(self) Sends a GET HTTP request. | source code
make_post_request(self) Sends a POST HTTP request. | source code
get_auth(self, credentials) Creates the authentication for accessing HTTP | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Variables | [hide private]
| api_url = ``'````'`` domain url to use when sending requests
| api_method = ``'````'`` api method to use when sending requests
| api_params = ``'````'`` parameters to send to the method when sending requests
| api_header = ``{``}`` Authorization to put into header when sending requests
| api_post_payload = ``{``}`` Payload to be delivered when sending a POST request
| logger = `None` logger to send loggin information to.
| api_path_params = ``'````'``
| formatted_params = ``'````'``

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, api_url, logger) (Constructor) | source code
Constructor for class Args : api_url : (str) URL to the base of the API logger : (logger) instance of a logging object configured in testing project Overrides: object.__init__

### make_path_params(self, params) | source code
    Constucts a request with the parameters formated in path parameter format.
        EX: http://myserver.com/api/method/pathParam1/pathParam2

    Args :(list) a list of parameter values to send to the api

    Returns :null

    Raises :null

### make_query_params(self, params) | source code
    Constucts a request with the parameters formated in query parameter format.
        EX: http://myserver.com/api/method?queryParam=paramValue

    Args :(dict) a dictionary of parameter names and values to send to the api

    Returns :null

    Raises :null

### make_get_request(self) | source code
Sends a GET HTTP request. Make sure you have set the classe's api_params,api_url and api_method first Args :null Returns : (file-like object) the HTTP response Raises :null

### make_post_request(self) | source code
    Sends a POST HTTP request.  Make sure you have set the classe's api_params,api_url,
        api_header and api_method first

    Args :null

    Returns : (file-like object) the HTTP response

    Raises :null

### get_auth(self, credentials) | source code
    Creates the authentication for accessing HTTP

    Args :
    credentials : (dict) 'username' and 'password' keys for a dictionary containing the HTTP Basic Auth to access
                            the api

    Returns : null

    Raises :null

Class Variable Details | [hide private]

  ### logger logger to send loggin information to. Logger comes from pytest test definitions Value:
      None