def test_status(self): plugin = mock.Mock() plugin_context = mock.Mock() network = mock.MagicMock() binding = mock.Mock() port = {'device_owner': constants.DEVICE_OWNER_DVR_INTERFACE} binding.status = 'foostatus' with mock.patch.object(driver_context.db, 'get_network_segments'): ctx = driver_context.DvrPortContext(plugin, plugin_context, port, network, binding) self.assertEqual('foostatus', ctx.status)
def test_status_super(self): plugin = mock.Mock() plugin_context = mock.Mock() network = mock.MagicMock() binding = mock.Mock() port = {'device_owner': 'compute', 'status': 'status'} binding.status = 'foostatus' with mock.patch.object(driver_context.db, 'get_network_segments'): ctx = driver_context.DvrPortContext(plugin, plugin_context, port, network, binding) self.assertEqual('status', ctx.status)
def test_host_super(self): plugin = mock.Mock() plugin_context = mock.Mock() network = mock.MagicMock() binding = mock.Mock() port = {'device_owner': 'compute', portbindings.HOST_ID: 'host'} binding.host = 'foohost' with mock.patch.object(driver_context.db, 'get_network_segments'): ctx = driver_context.DvrPortContext(plugin, plugin_context, port, network, binding) self.assertEqual('host', ctx.host)
def test_process_dvr_port_binding_update_router_id(self): host_id = 'host' binding = models.DVRPortBinding(port_id='port_id', host=host_id, router_id='old_router_id', vif_type=portbindings.VIF_TYPE_OVS, vnic_type=portbindings.VNIC_NORMAL, cap_port_filter=False, status=constants.PORT_STATUS_DOWN) plugin = manager.NeutronManager.get_plugin() mock_network = {'id': 'net_id'} context = mock.Mock() new_router_id = 'new_router' attrs = {'device_id': new_router_id, portbindings.HOST_ID: host_id} with mock.patch.object(plugin, '_update_port_dict_binding'): with mock.patch.object(ml2_db, 'get_network_segments', return_value=[]): mech_context = driver_context.DvrPortContext( self, context, 'port', mock_network, binding) plugin._process_dvr_port_binding(mech_context, context, attrs) self.assertEqual(new_router_id, mech_context._binding.router_id) self.assertEqual(host_id, mech_context._binding.host)