Package ganeti :: Package rapi :: Module testutils
[hide private]
[frames] | no frames]

Module testutils

source code

Remote API test utilities.

Classes [hide private]
  VerificationError
Dedicated error class for test utilities.
  FakeCurl
Fake cURL object.
  _RapiMock
Mocking out the RAPI server parts.
  _TestLuxiTransport
Mocked LUXI transport.
  _LuxiCallRecorder
Records all called LUXI client methods.
  InputTestClient
Test version of RAPI client.
Functions [hide private]
 
_GetOpById(op_id)
Tries to get an opcode class based on its OP_ID.
source code
 
_HideInternalErrors(fn)
Hides Ganeti-internal exceptions, see VerificationError.
source code
 
VerifyOpInput(op_id, data)
Verifies opcode parameters according to their definition.
source code
 
VerifyOpResult(op_id, result)
Verifies opcode results used in tests (e.g.
source code
 
_GetPathFromUri(uri)
Gets the path and query from a URI.
source code
string
_FormatHeaders(headers)
Formats HTTP headers.
source code
 
_TestWrapper(fn, *args, **kwargs)
Wrapper for ignoring errors.RapiTestResult.
source code
Variables [hide private]
  _URI_RE = re.compile(r"https://(?P<host>.*):(?P<port>\d+)(?P<p...

Imports: logging, re, base64, pycurl, StringIO, errors, opcodes, http, server, utils, compat, luxi, rapi, ganeti


Function Details [hide private]

VerifyOpInput(op_id, data)

source code 

Verifies opcode parameters according to their definition.

Parameters:
  • op_id (string) - Opcode ID (OP_ID attribute), e.g. OP_CLUSTER_VERIFY
  • data (dict) - Opcode parameter values
Decorators:
  • @_HideInternalErrors
Raises:

VerifyOpResult(op_id, result)

source code 

Verifies opcode results used in tests (e.g. in a mock).

Parameters:
  • op_id (string) - Opcode ID (OP_ID attribute), e.g. OP_CLUSTER_VERIFY
  • result - Mocked opcode result
Decorators:
  • @_HideInternalErrors
Raises:

_FormatHeaders(headers)

source code 

Formats HTTP headers.

Parameters:
  • headers (sequence of strings)
Returns: string

Variables Details [hide private]

_URI_RE

Value:
re.compile(r"https://(?P<host>.*):(?P<port>\d+)(?P<path>/.*)")