def test_plug_vip_port_mock_with_host(self): exp = { 'device_owner': 'neutron:' + constants.LOADBALANCER, 'admin_state_up': True, portbindings.HOST_ID: 'host' } with mock.patch.object( self.plugin._core_plugin, 'update_port') as mock_update_port: with self.pool() as pool: with self.vip(pool=pool) as vip: ctx = context.get_admin_context() self.callbacks.plug_vip_port( ctx, port_id=vip['vip']['port_id'], host='host') mock_update_port.assert_called_once_with( ctx, vip['vip']['port_id'], {'port': testlib_api.SubDictMatch(exp)})
def test_plug_vip_port_mock_with_host(self): exp = { 'device_owner': 'neutron:' + n_constants.LOADBALANCERV2, 'admin_state_up': True, portbindings.HOST_ID: 'host' } with mock.patch.object(self.plugin.db._core_plugin, 'update_port') as mock_update_port: with self.loadbalancer() as loadbalancer: lb_id = loadbalancer['loadbalancer']['id'] ctx = context.get_admin_context() self.callbacks.update_status(ctx, 'loadbalancer', lb_id, constants.ACTIVE) (self.plugin_instance.db. update_loadbalancer_provisioning_status(ctx, lb_id)) db_lb = self.plugin_instance.db.get_loadbalancer(ctx, lb_id) self.callbacks.plug_vip_port(ctx, port_id=db_lb.vip_port_id, host='host') mock_update_port.assert_called_once_with( ctx, db_lb.vip_port_id, {'port': testlib_api.SubDictMatch(exp)})