

def test_server_update_security_groups(self):
    cur_sg_ids = [self.api_q_secgroups.first()['id']]
    new_sg_ids = [sg['id'] for sg in self.api_q_secgroups.list()[:2]]
    (instance_id, instance_ports) = self._get_instance(cur_sg_ids)
    self.qclient.list_ports(device_id=instance_id).AndReturn({
        'ports': instance_ports,
    })
    for p in instance_ports:
        body = {
            'port': {
                'security_groups': new_sg_ids,
            },
        }
        self.qclient.update_port(p['id'], body=body).AndReturn({
            'port': p,
        })
    self.mox.ReplayAll()
    api.network.server_update_security_groups(self.request, instance_id, new_sg_ids)

dataset/ETHPy150Open CiscoSystems/avos/openstack_dashboard/test/api_tests/network_tests.py NetworkApiNeutronSecurityGroupTests.test_server_update_security_groups/original