

def test_update_reserved_dhcp_port(self):
    port = {
        'port': {
            'network_id': 'foo_network_id',
            'device_owner': constants.DEVICE_OWNER_DHCP,
            'fixed_ips': [{
                'subnet_id': 'foo_subnet_id',
            }],
        },
    }
    expected_port = {
        'port': {
            'network_id': 'foo_network_id',
            'device_owner': constants.DEVICE_OWNER_DHCP,
            portbindings.HOST_ID: 'foo_host',
            'fixed_ips': [{
                'subnet_id': 'foo_subnet_id',
            }],
        },
        'id': 'foo_port_id',
    }

    def _fake_port_action(plugin, context, port, action):
        self.assertEqual(expected_port, port)
    self.plugin.get_port.return_value = {
        'device_id': utils.get_dhcp_agent_device_id('foo_network_id', 'foo_host'),
    }
    self.callbacks._port_action = _fake_port_action
    self.callbacks.update_dhcp_port(mock.Mock(), host='foo_host', port_id='foo_port_id', port=port)
    expected_port.plugin.get_port.return_value = {
        'device_id': 'other_id',
    }
    self.assertRaises(exceptions.DhcpPortInUse, self.callbacks.update_dhcp_port, mock.Mock(), host='foo_host', port_id='foo_port_id', port=port)

dataset/ETHPy150Open openstack/neutron/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py TestDhcpRpcCallback.test_update_reserved_dhcp_port/VarMisuse@182/316 `self`->`expected_port`