avocado.core.restclient package


avocado.core.restclient.connection module

This module provides connection classes the avocado server.

A connection is a simple wrapper around a HTTP request instance. It is this basic object that allows methods to be called on the remote server.


Returns the global, default connection to avocado-server

Returns:an avocado.core.restclient.connection.Connection instance
class avocado.core.restclient.connection.Connection(hostname=None, port=None, username=None, password=None)

Bases: object

Connection to the avocado server

Initializes a connection to an avocado-server instance

  • hostname (str) – the hostname or IP address to connect to
  • port (int) – the port number where avocado-server is running
  • username (str) – the name of the user to be authenticated as
  • password (str) – the password to use for authentication

Checks the minimum server version


Gets the list of APIs the server makes available to the current user


Returns a representation of the current connection as an HTTP URL


Tests connectivity to the currently set avocado-server

This is intentionally a simple method that will only return True if a request is made, and a response is received from the server.

request(path, method=<function get>, check_status=True, **data)

Performs a request to the server

This method is heavily used by upper level API methods, and more often than not, those upper level API methods should be used instead.

  • path (str) – the path on the server where the resource lives
  • method – the method you want to call on the remote server, defaults to a HTTP GET
  • check_status – whether to check the HTTP status code that comes with the response. If set to True, it will depend on the method chosen. If set to False, no check will be performed. If an integer is given then that specific status will be checked for.
  • data – keyword arguments to be passed to the remote method

JSON data

avocado.core.restclient.response module

Module with base model functions to manipulate JSON data

class avocado.core.restclient.response.BaseResponse(json_data)

Bases: object

Base class that provides commonly used features for response handling

exception avocado.core.restclient.response.InvalidJSONError

Bases: exceptions.Exception

Data given to a loader/decoder is not valid JSON

exception avocado.core.restclient.response.InvalidResultResponseError

Bases: exceptions.Exception

Returned result response does not conform to expectation

Even though the result may be a valid json, it may not have the required or expected information that would normally be sent by avocado-server.

class avocado.core.restclient.response.ResultResponse(json_data)

Bases: avocado.core.restclient.response.BaseResponse

Provides a wrapper around an ideal result response

This class should be instantiated with the JSON data received from an avocado-server, and will check if the required data members are present and thus the response is well formed.

REQUIRED_DATA = ['count', 'next', 'previous', 'results']

Module contents