'Test update of port IP.
Check that a configured IP 10.0.0.2 is replaced by 10.0.0.10.'

def test_update_port_update_ip(self):

    with self.subnet() as subnet:
        fixed_ip_data = [{'ip_address': '10.0.0.2', 'subnet_id': subnet['subnet']['id']}]
        with self.port(subnet=subnet, fixed_ips=fixed_ip_data) as port:
            ips = port['port']['fixed_ips']
            self.assertEqual(1, len(ips))
            self.assertEqual('10.0.0.2', ips[0]['ip_address'])
            self.assertEqual(ips[0]['subnet_id'], subnet['subnet']['id'])
            data = {'port': {'fixed_ips': [{'subnet_id': subnet['subnet']['id'], 'ip_address': '10.0.0.10'}]}}
            req = self.new_update_request('ports', data, port['port']['id'])
            res = self.deserialize(self.fmt, req.get_response(self.api))
            ips = res['port']['fixed_ips']
            self.assertEqual(1, len(ips))
            self.assertEqual('10.0.0.10', ips[0]['ip_address'])
            self.assertEqual(ips[0]['subnet_id'], subnet['subnet']['id'])
