

def test_show(self):

    def fake_get_instance_security_groups(inst, context, id):
        return [{
            'name': 'fake-2-0',
        }, {
            'name': 'fake-2-1',
        }]
    self.stubs.Set(neutron_driver.SecurityGroupAPI, 'get_instance_security_groups', fake_get_instance_security_groups)
    url = '/v2/fake/servers'
    image_uuid = 'c905cedb-7281-47e4-8a62-f26bc5fc4c77'
    req = fakes.HTTPRequest.blank('/v2/fake/os-security-groups')
    security_groups = [{
        'name': 'fake-2-0',
    }, {
        'name': 'fake-2-1',
    }]
    for security_group in security_groups:
        sg = test_security_groups.security_group_template(name=security_group['name'])
        self.controller.create(req, {
            'security_group': sg,
        })
    server = dict(name='server_test', imageRef=image_uuid, flavorRef=2, security_groups=security_groups)
    res = self._make_request(url, {
        'server': server,
    })
    self.assertEqual(res.status_int, 202)
    server = self._get_server(res.body)
    for (i, group) in enumerate(self._get_groups(server)):
        name = ('fake-2-%s' % i)
        self.assertEqual(group.get('name'), name)
    url = ('/v2/fake/servers/' + test_security_groups.UUID3)
    res = self._make_request(url)
    security_groups.assertEqual(res.status_int, 200)
    server = self._get_server(res.body)
    for (i, group) in enumerate(self._get_groups(server)):
        name = ('fake-2-%s' % i)
        self.assertEqual(group.get('name'), name)

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py TestNeutronSecurityGroupsOutputTest.test_show/VarMisuse@263/433 `self`->`security_groups`