'Test port update with a new IPv6 SLAAC subnet in fixed IPs.'

def test_update_port_with_new_ipv6_slaac_subnet_in_fixed_ips(self):

    res = self._create_network(fmt=self.fmt, name='net', admin_state_up=True)
    network = self.deserialize(self.fmt, res)
    subnet_v4 = self._make_subnet(self.fmt, network, gateway='10.0.0.1', cidr='10.0.0.0/24', ip_version=4)
    subnet_v6 = self._make_v6_subnet(network, constants.IPV6_SLAAC)
    res = self._create_port(self.fmt, net_id=network['network']['id'])
    port = self.deserialize(self.fmt, res)
    self.assertEqual(2, len(port['port']['fixed_ips']))
    ips = [{'subnet_id': subnet_v4['subnet']['id']}, {'subnet_id': subnet_v6['subnet']['id'], 'delete_subnet': True}]
    data = {'port': {'fixed_ips': ips}}
    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(subnet_v4['subnet']['id'], ips[0]['subnet_id'])
    ips.append({'subnet_id': subnet_v6['subnet']['id']})
    data = {'port': {'fixed_ips': ips}}
    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(2, len(ips))
    self.assertEqual(set([subnet_v4['subnet']['id'], subnet_v6['subnet']['id']]), set([ip['subnet_id'] for ip in ips]))
