Package cm_api_tests :: Module utils :: Class MockResource
[hide private]
[frames] | no frames]

Class MockResource

source code

              object --+    
                       |    
cm_api.resource.Resource --+
                           |
                          MockResource

Allows code to control the behavior of a resource's "invoke" method for unit testing.

Instance Methods [hide private]
 
__init__(self, test, version=5)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
invoke(self, method, relpath=None, params=None, data=None, headers=None)
Checks the expected input data and returns the appropriate data to the caller.
source code
 
expect(self, method, reqpath, params=None, data=None, headers=None, retdata=None)
Sets the data to expect in the next call to invoke().
source code

Inherited from cm_api.resource.Resource: delete, get, post, put

Inherited from cm_api.resource.Resource (private): _join_uri, _make_headers

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]
  base_url

Inherited from object: __class__

Method Details [hide private]

__init__(self, test, version=5)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  • client - A Client object.
  • relpath - The relative path of the resource.
Overrides: object.__init__
(inherited documentation)

invoke(self, method, relpath=None, params=None, data=None, headers=None)

source code 

Checks the expected input data and returns the appropriate data to the caller.

Returns:
Raw body or JSON dictionary (if response content type is JSON).
Overrides: cm_api.resource.Resource.invoke

expect(self, method, reqpath, params=None, data=None, headers=None, retdata=None)

source code 

Sets the data to expect in the next call to invoke().

Parameters:
  • method - method to expect, or None for any.
  • reqpath - request path, or None for any.
  • params - query parameters, or None for any.
  • data - request body, or None for any.
  • headers - request headers, or None for any.
  • retdata - data to return from the invoke call.

Property Details [hide private]

base_url

Get Method:
unreachable.base_url(self)