Esempio n. 1
0
    def _test(self, name, dp, method, path, body):
        print('processing %s ...' % name)

        dpset = DPSet()
        dpset._register(dp)
        wsgi = WSGIApplication()
        contexts = {
            'dpset': dpset,
            'wsgi': wsgi,
        }
        ofctl_rest.RestStatsApi(**contexts)

        req = Request.blank(path)
        req.body = json.dumps(body).encode('utf-8')
        req.method = method

        with mock.patch('ryu.lib.ofctl_utils.send_stats_request'),\
                mock.patch('ryu.lib.ofctl_utils.send_msg'):
            res = req.get_response(wsgi)
        eq_(res.status, '200 OK')
Esempio n. 2
0
#*** JSON imports:
import json
from json import JSONEncoder

#*** nmeta2 imports:
import nmeta2
import switch_abstraction
import config

#*** Instantiate Config class:
_config = config.Config()

#====================== switch_abstraction.py Unit Tests ======================
#*** Instantiate class:
wsgi_app = WSGIApplication()
nmeta = nmeta2.Nmeta(wsgi=wsgi_app)

switches = switch_abstraction.Switches(nmeta, _config)

sock_mock = mock.Mock()
addr_mock = mock.Mock()

#*** Constant to use for a port not found value:
PORT_NOT_FOUND = 999999999

#*** Test Constants:
MAC123 = '00:00:00:00:01:23'
PORT123 = 123
CONTEXT1 = 1
Esempio n. 3
0
 def setUp(self):
     wsgi = WSGIApplication()
     #*** Instantiate API class:
     self.api = api.Api(self, _config, wsgi)
Esempio n. 4
0
 def create_wsgi_app(self, host, port):
     wsgi = WSGIApplication()
     webapp = hub.WSGIServer((host, port), wsgi)
     hub.spawn(webapp.serve_forever)
     return wsgi
Esempio n. 5
0
 def setUp(self):
     controller_data = {
         'test_param': 'foo'
     }
     self.wsgi_app = WSGIApplication()
     self.wsgi_app.register(_TestController, controller_data)