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() source code
 
get_responses() source code
 
catch_all(path)
This method handles all requests that are not defined below It will go though the list of rules and apply one by one until a match is found.
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 200 response with empty body

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

clear_responses()

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

get_responses()

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

catch_all(path)

source code 

This method handles all requests that are not defined below 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 200 response with empty body

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