arjuna.tpi.httpauto.service module

class arjuna.tpi.httpauto.service.HttpService(*, name='anon', url=None, oauth_token=None, request_content_handler=None, headers=None, max_redirects=None, auth=None, proxy=None, _auto_session=True)

Bases: object

HTTP Service representing SEAMful automation in Arjuna.

Keyword Arguments
  • name – Name of service. Should have a corresponding named directory in Project root/httpauto/service directory. If not provided then the name is set to anon and root directory is set to Project root/httpauto.

  • url – Base URL for this HTTP session. If relative path is used as a route in sender methods like .get, then this URL is prefixed to their provided routes.

  • oauth_token – OAuth 2.0 Bearer token for this service.

  • request_content_handler – Default content type handler for requests sent in this service. Overridable in individual sender methods. Default is Http.content.urlencoded.

  • headers – HTTP headers to be added to request headers made by this service.

  • max_redirects – Maximum number of redirects allowed for a request. Default is 30.

  • auth – HTTP Authentication object: Basic/Digest.

  • proxy – Proxies dict to be associated with this service.

property action

Http Action Loader for this service using default end point.

add_cookies(cookie_dict)

Add cookies to the service.

property auth

HTTP Authentication object.

property cookies: dict

All current cookie name/values in this service.

delete(route, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: Optional[float] = None, pretty_url=False, query_params=None, **named_query_params) arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP DELETE request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

property ep

Http End Point loader for this service.

get(route, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: Optional[float] = None, pretty_url=False, query_params=None, **named_query_params) arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP GET request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

head(route, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: Optional[float] = None, pretty_url=False, query_params=None, **named_query_params) arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP HEAD request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

property headers

Request headers.

property message

Http Message Loader for this service using default end point.

property name

Name of service

options(route, *, content, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: Optional[float] = None, pretty_url=False, query_params=None, **named_query_params) arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP OPTIONS request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

property parsed_cookies: dict

All current cookie name and corresponding HttpCookie object in this service.

patch(route, *, content, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: Optional[float] = None, pretty_url=False, query_params=None, **named_query_params) arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP PATCH request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

perform(action=None, **fargs) arjuna.tpi.httpauto.response.HttpResponse

Perform an HTTP Action using this service using default end point.

post(route, *, content, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: Optional[float] = None, pretty_url=False, query_params=None, **named_query_params) arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP POST request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

put(route, *, content, label=None, xcodes=None, headers=None, cookies=None, allow_redirects=True, auth=None, timeout: Optional[float] = None, pretty_url=False, query_params=None, **named_query_params) arjuna.tpi.httpauto.response.HttpResponse

Sends an HTTP PUT request.

Parameters

route – Absolute or relative URL. If relative, then url of this session object is pre-fixed.

Keyword Arguments
  • label – Label for this request. If available, it is used in reports and logs.

  • content – Content to be sent in this HTTP request. If passed as string, then content-type set in session is used using the content request handler. It can also be a dictionary with keys - ‘content’ and ‘type’.

  • xcodes – Expected HTTP response code(s).

  • headers – Mapping of additional HTTP headers to be sent with this request.

  • cookies – Python dict of cookies to send with request.

  • allow_redirects – If True, redirections are allowed for the HTTP message. Default is True.

  • auth – HTTP Authentication object: Basic/Digest.

  • timeout – How long to wait for the server to send data before giving up.

  • pretty_url – If True, the query params are formatted using pretty URL format instead of usual query string which is the default.

  • query_params – A mapping of key-values to be included in query string.

  • **named_query_params – Arbitrary key/value pairs. These are appended to the query string of URL for this request.

Note

query_params and named_query_params have the same goal. In case of duplicates, named_query_params override query_params.

property request_content_handler

Request content handler for content formatting.

property root_dir
send(msg=None, **fargs) arjuna.tpi.httpauto.response.HttpResponse

Send an HTTP Message using this service using default end point.

property url

Base URL for this session.