Merge "Add unittests for exceptions.EmptyCatalog"
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import copy
|
||||||
|
|
||||||
from keystoneclient import access
|
from keystoneclient import access
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
|
||||||
@@ -48,3 +50,17 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
|
|
||||||
url = sc.url_for(service_type='image', endpoint_type='internalURL')
|
url = sc.url_for(service_type='image', endpoint_type='internalURL')
|
||||||
self.assertEquals(url, "https://image-internal.south.host/v1/")
|
self.assertEquals(url, "https://image-internal.south.host/v1/")
|
||||||
|
|
||||||
|
def test_service_catalog_empty(self):
|
||||||
|
# We need to do a copy.deepcopy here since
|
||||||
|
# dict(self.AUTH_RESPONSE_BODY) or self.AUTH_RESPONSE_BODY.copy() will
|
||||||
|
# only do a shadowcopy and sc_empty['token']['catalog'] will still be a
|
||||||
|
# reference to self.AUTH_RESPONSE_BODY so setting it to empty will fail
|
||||||
|
# the other tests that needs a service catalog.
|
||||||
|
sc_empty = copy.deepcopy(self.AUTH_RESPONSE_BODY)
|
||||||
|
sc_empty['access']['serviceCatalog'] = []
|
||||||
|
auth_ref = access.AccessInfo.factory(None, sc_empty)
|
||||||
|
self.assertRaises(exceptions.EmptyCatalog,
|
||||||
|
auth_ref.service_catalog.url_for,
|
||||||
|
service_type='image',
|
||||||
|
endpoint_type='internalURL')
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
import copy
|
||||||
|
|
||||||
from keystoneclient import access
|
from keystoneclient import access
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
|
||||||
@@ -53,3 +55,17 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
sc = auth_ref.service_catalog
|
sc = auth_ref.service_catalog
|
||||||
url = sc.url_for(service_type='image', endpoint_type='internal')
|
url = sc.url_for(service_type='image', endpoint_type='internal')
|
||||||
self.assertEquals(url, "http://glance.south.host/glanceapi/internal")
|
self.assertEquals(url, "http://glance.south.host/glanceapi/internal")
|
||||||
|
|
||||||
|
def test_service_catalog_empty(self):
|
||||||
|
# We need to do a copy.deepcopy here since
|
||||||
|
# dict(self.AUTH_RESPONSE_BODY) or self.AUTH_RESPONSE_BODY.copy() will
|
||||||
|
# only do a shadowcopy and sc_empty['token']['catalog'] will still be a
|
||||||
|
# reference to self.AUTH_RESPONSE_BODY so setting it to empty will fail
|
||||||
|
# the other tests that needs a service catalog.
|
||||||
|
sc_empty = copy.deepcopy(self.AUTH_RESPONSE_BODY)
|
||||||
|
sc_empty['token']['catalog'] = []
|
||||||
|
auth_ref = access.AccessInfo.factory(self.RESPONSE, sc_empty)
|
||||||
|
self.assertRaises(exceptions.EmptyCatalog,
|
||||||
|
auth_ref.service_catalog.url_for,
|
||||||
|
service_type='image',
|
||||||
|
endpoint_type='internalURL')
|
||||||
|
Reference in New Issue
Block a user