def test_create_lb_1(self, *mocks):
     """Exception"""
     mocks[6].return_value = {'id': 2}
     mocks[1].side_effect = exception.Invalid
     mocks[2].return_value = {'id': 1}
     mocks[4].return_value = mock.MagicMock()
     api.create_lb(self.conf, self.dict_list_0)
     mocks[1].called_once_with(exception.Invalid)
 def test_create_lb_0(self, *mocks):
     """No exception"""
     mocks[6].return_value = {'id': 2}
     mocks[2].return_value = {'id': 1}
     mocks[4].return_value = mock.MagicMock()
     api.create_lb(self.conf, self.dict_list_0)
     for mok in mocks:
         self.assertTrue(mok.called, "Mock %s didn't call"
                 % mok._mock_name)
Exemplo n.º 3
0
 def create(self, req, **args):
     logger.debug("Got create request. Request: %s", req)
     #here we need to decide which device should be used
     params = args['body']
     # We need to create LB object and return its id
     tenant_id = req.headers.get('X-Tenant-Id', "")
     lb_ref = db_api.loadbalancer_create(self.conf, {
                                             'tenant_id': tenant_id})
     params['lb'] = lb_ref
     core_api.create_lb(self.conf, **params)
     return {'loadbalancers': {'id': lb_ref['id']}}
Exemplo n.º 4
0
 def test_create_lb_0(self, *mocks):
     """No exception"""
     mocks[2].return_value = {'id': 1}
     mocks[4].return_value = {'id': 2, 'algorithm': 'test',
                              'protocol': 'test'}
     api.create_lb(self.conf, self.dict_list_0)
     for mok in mocks:
         self.assertTrue(mok.called, "Mock %s didn't call"
                 % mok._mock_name)
     mocks[5].assert_called_with(self.conf, 2,
                                 {'status': 'ACTIVE', 'deployed': True})
Exemplo n.º 5
0
 def create(self, req, tenant_id, body):
     LOG.debug("Got create request. Request: %s", req)
     #here we need to decide which device should be used
     params = body.copy()
     LOG.debug("Headers: %s", req.headers)
     # We need to create LB object and return its id
     params['tenant_id'] = tenant_id
     lb_id = core_api.create_lb(self.conf, params)
     return {'loadbalancer': {'id': lb_id}}
Exemplo n.º 6
0
 def test_create_lb_1(self, mock_driver, mock_commands,
         mock_sched, mock_bal):
     """Exception"""
     mock_commands.side_effect = exception.Invalid
     api.create_lb(self.conf, async=False)
     mock_commands.called_once_with(exception.Invalid)
Exemplo n.º 7
0
 def test_create_lb_0(self, mock_driver, mock_commands,
         mock_sched, mock_bal):
     """No exception"""
     api.create_lb(self.conf, async=False)
     self.assertTrue(mock_driver.called)
     self.assertTrue(mock_commands.called)