API Documentation¶
-
class
mocurly.
mocurly
(func=None)¶ Main class that provides the mocked context.
This can be used as a decorator, as a context manager, or manually. In all three cases, the guarded context will route all recurly requests to the mocked callback functions defined in endpoints.py.
-
register_transaction_failure
(account_code, error_code)¶ Register a transaction failure for the given account.
This will setup mocurly such that all transactions made by the account with the given account_code will fail with the selected error_code.
-
start
()¶ Starts the mocked context by enabling HTTPretty to route requests to the defined endpoints.
-
start_timeout
(timeout_filter=None)¶ Notifies mocurly to start simulating time outs within the current context.
You can pass in a filter function which will be used to decide what requests to timeout. The function will get one parameter, request, which is an instance of the HTTPrettyRequest class, and should return a boolean which when True, the request will time out.
- The following attributes are available on the request object:
headers -> a mimetype object that can be cast into a dictionary, contains all the request headers.
method -> the HTTP method used in this request.
path -> the full path to the requested URI.
querystring -> a dictionary containing lists with the attributes.
body -> the raw contents of the request body.
- parsed_body -> a dictionary containing parsed request body or
- None if HTTPrettyRequest doesn’t know how to parse it.
-
start_timeout_successful_post
(timeout_filter=None)¶ Notifies mocurly to make timeouts on POST requests, but only after it has caused state changes.
Like start_timeout, you can pass in a filter function used to decide which requests to cause the timeout on.
-
stop
()¶ Stops the mocked context, restoring the routes back to what they were
-
stop_timeout
()¶ Notifies mocurly to stop simulating time outs within the current context.
-
stop_timeout_successful_post
()¶ Notifies mocurly to stop simulating successful POST time outs within the current context.
-