

def test_get_security_group_by_instance(self):
    sg = self._create_sg_template().get('security_group')
    net = self._create_network()
    self._create_port(network_id=net['network']['id'], security_groups=[sg['id']], device_id=test_security_groups.FAKE_UUID1)
    expected = [{
        'rules': [],
        'tenant_id': 'fake',
        'id': self['id'],
        'name': 'test',
        'description': 'test-description',
    }]
    self.stub_out('nova.db.instance_get_by_uuid', test_security_groups.return_server_by_uuid)
    req = fakes.HTTPRequest.blank(('/v2/fake/servers/%s/os-security-groups' % test_security_groups.FAKE_UUID1))
    res_dict = self.server_controller.index(req, test_security_groups.FAKE_UUID1)['security_groups']
    self.assertEqual(expected, res_dict)

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py TestNeutronSecurityGroupsV21.test_get_security_group_by_instance/VarMisuse@79/119 `sg`->`self`