Package tlib :: Package base :: Module ApiMockServer
[hide private]
[frames] | no frames]

Module ApiMockServer

source code

Functions [hide private]
 
shutdown() source code
 
add_response()
This method adds new responses to the mock.
source code
 
clear_responses()
Delete existing responses
source code
 
get_responses()
Get all responses
source code
 
catch_all(path)
This method will catch all requests for which there are no explicit routes.
source code
Variables [hide private]
  mock_server = <Flask 'tlib.base.ApiMockServer'>
  _rules = []
  __package__ = 'tlib.base'
Function Details [hide private]

shutdown()

source code 
Decorators:
  • @mock_server.route("/mock/shutdown", methods= ['GET'])

add_response()

source code 

This method adds new responses to the mock.
To add a response send a POST request with a payload like this:

{
    "url_filter": ".*",
    "headers": {
        "Accept": "text/xml"
    },
    "body": "Sample body",
    "status_code": 200
}

Server will validate each matching rule and apply the first match
If there is no match, it will return a 500 response

Decorators:
  • @mock_server.route("/mock/responses", methods= ['POST'])

clear_responses()

source code 

Delete existing responses

Decorators:
  • @mock_server.route("/mock/responses", methods= ['DELETE'])

get_responses()

source code 

Get all responses

Decorators:
  • @mock_server.route("/mock/responses", methods= ['GET'])

catch_all(path)

source code 

This method will catch all requests for which there are no explicit routes. Here is where we build responses based on the rules that have been configured It will go though the list of rules and apply one by one until a match is found. If there is no match, it will return a 500 response

Decorators:
  • @mock_server.route('/', defaults= {'path': ''}, methods= ['GET', 'POST', 'PUT', 'DELETE'])
  • @mock_server.route('/', methods= ['GET', 'POST', 'PUT', 'DELETE'])