This Page

The quantum.plugins.bigswitch.tests.test_server Module

Test server mocking a REST based network ctrl. Used for QuantumRestProxy tests

class quantum.plugins.bigswitch.tests.test_server.TestNetworkCtrl(host='', port=8000, default_status='404 Not Found', default_response='404 Not Found', debug=False)

Bases: object

match(prior, method_regexp, uri_regexp, handler, data=None, multi=True)

Adds to the list of exptected inputs. The incomming request is matched in the order of priority. For same priority, match the oldest match request first.

Parameters:
  • prior – intgere priority of this match (e.g. 100)
  • method_regexp – regexp to match method (e.g. ‘PUT|POST’)
  • uri_regexp – regexp to match uri (e.g. ‘/quantum/v?.?/’)
  • handler

    function with signature: lambda(method, uri, body, **kwargs) : status, body

    where
    • method: HTTP method for this request
    • uri: URI for this HTTP request
    • body: body of this HTTP request
    • kwargs are:
      • data: data object that was in the match call
      • node: TestNetworkCtrl object itself
      • id: offset of the matching tuple
    and return values is:
    (status, body) where: - status: HTTP resp status (e.g. ‘200 OK’).
    If None, use default_status
    • body: HTTP resp body. If None, use ‘’
remove_id(id_)
remove_match(prior, method_regexp, uri_regexp)
request_handler(method, uri, body)
run()
server()