def _test_servers_update_addresses(self, router_enabled=True):
        tenant_id = self.request.user.tenant_id

        servers = copy.deepcopy(self.servers.list())
        server_ids = [server.id for server in servers]
        server_ports = [p for p in self.api_ports.list()
                        if p['device_id'] in server_ids]
        server_port_ids = [p['id'] for p in server_ports]
        if router_enabled:
            assoc_fips = [fip for fip in self.api_q_floating_ips.list()
                          if fip['port_id'] <= server_port_ids]
        server_network_ids = [p['network_id'] for p in server_ports]
        server_networks = [net for net in self.api_networks.list()
                           if net['id'] in server_network_ids]

        self.qclient.list_ports(device_id=server_ids) \
            .AndReturn({'ports': server_ports})
        if router_enabled:
            self.qclient.list_floatingips(tenant_id=tenant_id,
                                          port_id=server_port_ids) \
                .AndReturn({'floatingips': assoc_fips})
            self.qclient.list_ports(tenant_id=tenant_id) \
                .AndReturn({'ports': self.api_ports.list()})
        self.qclient.list_networks(id=server_network_ids) \
            .AndReturn({'networks': server_networks})
        self.qclient.list_subnets() \
            .AndReturn({'subnets': self.api_subnets.list()})
        self.mox.ReplayAll()

        api.network.servers_update_addresses(self.request, servers)

        self.assertEqual(self.servers.count(), len(servers))
        self.assertEqual([server.id for server in self.servers.list()],
                         [server.id for server in servers])

        no_fip_expected = not router_enabled

        # server[0] has one fixed IP and one floating IP
        # if router ext isenabled.
        self._check_server_address(servers[0], no_fip_expected)
        # The expected is also calculated, we examine the result manually once.
        addrs = servers[0].addresses['net1']
        if router_enabled:
            self.assertEqual(2, len(addrs))
            self.assertEqual('fixed', addrs[0]['OS-EXT-IPS:type'])
            self.assertEqual('floating', addrs[1]['OS-EXT-IPS:type'])
        else:
            self.assertEqual(1, len(addrs))
            self.assertEqual('fixed', addrs[0]['OS-EXT-IPS:type'])

        # server[1] has one fixed IP.
        self._check_server_address(servers[1], no_fip_expected)
        # manual check.
        addrs = servers[1].addresses['net2']
        self.assertEqual(1, len(addrs))
        self.assertEqual('fixed', addrs[0]['OS-EXT-IPS:type'])

        # server[2] has no corresponding ports in neutron_data,
        # so it should be an empty dict.
        self.assertFalse(servers[2].addresses)
dataset/ETHPy150Open CiscoSystems/avos/openstack_dashboard/test/api_tests/network_tests.py/NetworkApiNeutronTests._test_servers_update_addresses/operator `in` -> `<=`