'Ensure that the [clients_keystone] section is the preferred source.
Ensure that the [clients_keystone] section of the configuration is
the preferred source when the context does not have the auth_uri.'

def test_keystone_v3_endpoint_in_clients_keystone_config(self):

    cfg.CONF.set_override('auth_uri', 'http://xyz', group='clients_keystone')
    policy_check = 'heat.common.policy.Enforcer.check_is_admin'
    with mock.patch(policy_check) as pc:
        pc.return_value = False
        with mock.patch('keystoneauth1.discover.Discover') as discover:
            class MockDiscover(object, ):
                def url_for(self, endpoint):
                    return 'http://xyz/v3'
            discover.return_value = MockDiscover()
            ctx = context.RequestContext(auth_url=None)
            self.assertEqual(ctx.keystone_v3_endpoint, 'http://xyz/v3')
