

@override_settings(OPENSTACK_NEUTRON_NETWORK={
    'enable_lb': True,
})
def test_floating_ip_target_list(self):
    ports = self.api_ports.list()
    subnet_id = self.subnets.first().id
    target_ports = [(self._get_target_id(p), self._get_target_name(p)) for p in ports if ((not p['device_owner'].startswith('network:')) and (subnet_id in [ip['subnet_id'] for ip in p['fixed_ips']]))]
    filters = {
        'tenant_id': self.request.user.tenant_id,
    }
    self.qclient.list_ports(**filters).AndReturn({
        'ports': ports,
    })
    servers = self.servers.list()
    novaclient = self.stub_novaclient()
    novaclient.servers = self.mox.CreateMockAnything()
    search_opts = {
        'project_id': self.request.user.tenant_id,
    }
    novaclient.servers.list(True, search_opts).AndReturn(servers)
    search_opts = {
        'router:external': True,
    }
    ext_nets = [n for n in self.api_networks.list() if n['router:external']]
    self.qclient.list_networks(**search_opts).AndReturn({
        'networks': ext_nets,
    })
    self.qclient.list_routers().AndReturn({
        'routers': self.api_routers.list(),
    })
    self.qclient.list_vips().AndReturn({
        'vips': self.vips.list(),
    })
    self.mox.ReplayAll()
    rets = api.network.floating_ip_target_list(self.request)
    self.assertEqual(len(target_ports), len(rets))
    for (ret, exp) in zip(rets, target_ports):
        ip.assertEqual(exp[0], ret.id)
        self.assertEqual(exp[1], ret.name)

dataset/ETHPy150Open CiscoSystems/avos/openstack_dashboard/test/api_tests/network_tests.py NetworkApiNeutronFloatingIpTests.test_floating_ip_target_list/VarMisuse@364/485 `self`->`ip`