Fix variable 'url' referenced before assignment
Variable 'url' referenced before assignment in method url_for(), this fix it. Change-Id: I230cd16445af142f0eefea96ad19c6c78410f11b Closes-Bug: #1519428
This commit is contained in:
parent
8f0c042569
commit
09ca9f121c
|
@ -159,7 +159,7 @@ class ClientPlugin(object):
|
||||||
|
|
||||||
reg = self.context.region_name or cfg.CONF.region_name_for_services
|
reg = self.context.region_name or cfg.CONF.region_name_for_services
|
||||||
kwargs.setdefault('region_name', reg)
|
kwargs.setdefault('region_name', reg)
|
||||||
|
url = None
|
||||||
try:
|
try:
|
||||||
url = get_endpoint()
|
url = get_endpoint()
|
||||||
except exceptions.EmptyCatalog:
|
except exceptions.EmptyCatalog:
|
||||||
|
|
|
@ -303,6 +303,33 @@ class ClientPluginTest(common.HeatTestCase):
|
||||||
self.assertEqual('http://192.0.2.1/bar',
|
self.assertEqual('http://192.0.2.1/bar',
|
||||||
plugin.url_for(service_type='bar'))
|
plugin.url_for(service_type='bar'))
|
||||||
|
|
||||||
|
@mock.patch.object(v3, "Token", name="v3_token")
|
||||||
|
def test_endpoint_not_found(self, mock_v3):
|
||||||
|
class FakeKeystone(fakes.FakeKeystoneClient):
|
||||||
|
def __init__(self):
|
||||||
|
super(FakeKeystone, self).__init__()
|
||||||
|
self.client = self
|
||||||
|
self.version = 'v3'
|
||||||
|
|
||||||
|
self.stub_keystoneclient(fake_client=FakeKeystone())
|
||||||
|
con = mock.MagicMock(auth_token="1234", trust_id=None)
|
||||||
|
c = clients.Clients(con)
|
||||||
|
con.clients = c
|
||||||
|
|
||||||
|
con.auth_plugin = mock.Mock(name="auth_plugin")
|
||||||
|
get_endpoint_side_effects = [keystone_exc.EmptyCatalog(), None]
|
||||||
|
con.auth_plugin.get_endpoint = mock.Mock(
|
||||||
|
name="get_endpoint", side_effect=get_endpoint_side_effects)
|
||||||
|
|
||||||
|
mock_token_obj = mock.Mock()
|
||||||
|
mock_v3.return_value = mock_token_obj
|
||||||
|
mock_token_obj.get_auth_ref.return_value = {'no_catalog': 'without'}
|
||||||
|
|
||||||
|
plugin = FooClientsPlugin(con)
|
||||||
|
|
||||||
|
self.assertRaises(keystone_exc.EndpointNotFound,
|
||||||
|
plugin.url_for, service_type='nonexistent')
|
||||||
|
|
||||||
def test_abstract_create(self):
|
def test_abstract_create(self):
|
||||||
con = mock.Mock()
|
con = mock.Mock()
|
||||||
c = clients.Clients(con)
|
c = clients.Clients(con)
|
||||||
|
|
Loading…
Reference in New Issue