Add FakeObject classes to fakes.py, update unit tests in identity V2.
Clean up fakes.py , use FakeCatalog, FakeProject, FakeService, FakeEndpoint, FakeRole classes instead, also update their unit tests. Change-Id: I510d175ec194165b0595ebd430e8cc596d363587 Partially-Implements: blueprint refactor-identity-unit-test
This commit is contained in:
parent
3c1aae9cf4
commit
000c253d76
@ -110,6 +110,8 @@ ENDPOINT = {
|
||||
'publicurl': endpoint_publicurl,
|
||||
'service_id': endpoint_service_id,
|
||||
}
|
||||
SERVICE_NAME = 'service-name-' + uuid.uuid4().hex
|
||||
SERVICE_ID = 'service-id-' + uuid.uuid4().hex
|
||||
|
||||
|
||||
def fake_auth_ref(fake_token, fake_service=None):
|
||||
@ -123,12 +125,12 @@ def fake_auth_ref(fake_token, fake_service=None):
|
||||
# Create a service catalog
|
||||
if fake_service:
|
||||
service = token.add_service(
|
||||
fake_service['type'],
|
||||
fake_service['name'],
|
||||
fake_service.type,
|
||||
fake_service.name,
|
||||
)
|
||||
# TODO(dtroyer): Add an 'id' element to KSA's _Service fixure
|
||||
service['id'] = fake_service['id']
|
||||
for e in fake_service['endpoints']:
|
||||
service['id'] = fake_service.id
|
||||
for e in fake_service.endpoints:
|
||||
# KSA's _Service fixture copies publicURL to internalURL and
|
||||
# adminURL if they do not exist. Soooo helpful...
|
||||
internal = e.get('internalURL', None)
|
||||
@ -224,3 +226,241 @@ class FakeExtension(object):
|
||||
info=copy.deepcopy(extension_info),
|
||||
loaded=True)
|
||||
return extension
|
||||
|
||||
|
||||
class FakeCatalog(object):
|
||||
"""Fake one or more catalog."""
|
||||
|
||||
@staticmethod
|
||||
def create_catalog(attrs=None):
|
||||
"""Create a fake catalog.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:return:
|
||||
A FakeResource object with id, name, type and so on.
|
||||
"""
|
||||
attrs = attrs or {}
|
||||
|
||||
# Set default attributes.
|
||||
catalog_info = {
|
||||
'id': SERVICE_ID,
|
||||
'type': 'compute',
|
||||
'name': 'supernova',
|
||||
'endpoints': [
|
||||
{
|
||||
'region': 'one',
|
||||
'publicURL': 'https://public.one.example.com',
|
||||
'internalURL': 'https://internal.one.example.com',
|
||||
'adminURL': 'https://admin.one.example.com',
|
||||
},
|
||||
{
|
||||
'region': 'two',
|
||||
'publicURL': 'https://public.two.example.com',
|
||||
'internalURL': 'https://internal.two.example.com',
|
||||
'adminURL': 'https://admin.two.example.com',
|
||||
},
|
||||
{
|
||||
'region': None,
|
||||
'publicURL': 'https://public.none.example.com',
|
||||
'internalURL': 'https://internal.none.example.com',
|
||||
'adminURL': 'https://admin.none.example.com',
|
||||
},
|
||||
],
|
||||
}
|
||||
# Overwrite default attributes.
|
||||
catalog_info.update(attrs)
|
||||
|
||||
catalog = fakes.FakeResource(
|
||||
info=copy.deepcopy(catalog_info),
|
||||
loaded=True)
|
||||
|
||||
return catalog
|
||||
|
||||
|
||||
class FakeProject(object):
|
||||
"""Fake one or more project."""
|
||||
|
||||
@staticmethod
|
||||
def create_one_project(attrs=None):
|
||||
"""Create a fake project.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:return:
|
||||
A FakeResource object, with id, name, and so on
|
||||
"""
|
||||
|
||||
attrs = attrs or {}
|
||||
|
||||
# set default attributes.
|
||||
project_info = {
|
||||
'id': 'project-id' + uuid.uuid4().hex,
|
||||
'name': 'project-name' + uuid.uuid4().hex,
|
||||
'description': 'project_description',
|
||||
'enabled': True,
|
||||
}
|
||||
project_info.update(attrs)
|
||||
|
||||
project = fakes.FakeResource(info=copy.deepcopy(project_info),
|
||||
loaded=True)
|
||||
return project
|
||||
|
||||
@staticmethod
|
||||
def create_projects(attrs=None, count=2):
|
||||
"""Create multiple fake projects.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:param int count:
|
||||
The number of projects to fake
|
||||
:return:
|
||||
A list of FakeResource objects faking the projects
|
||||
"""
|
||||
projects = []
|
||||
for i in range(0, count):
|
||||
projects.append(FakeProject.create_one_project(attrs))
|
||||
|
||||
return projects
|
||||
|
||||
|
||||
class FakeEndpoint(object):
|
||||
"""Fake one or more endpoint."""
|
||||
|
||||
@staticmethod
|
||||
def create_one_endpoint(attrs=None):
|
||||
"""Create a fake agent.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:return:
|
||||
A FakeResource object, with id, name, region, and so on
|
||||
"""
|
||||
|
||||
attrs = attrs or {}
|
||||
|
||||
# set default attributes.
|
||||
endpoint_info = {
|
||||
'service_name': SERVICE_NAME,
|
||||
'adminurl': 'http://endpoint_adminurl',
|
||||
'region': 'endpoint_region',
|
||||
'internalurl': 'http://endpoint_internalurl',
|
||||
'service_type': 'service_type',
|
||||
'id': 'endpoint-id-' + uuid.uuid4().hex,
|
||||
'publicurl': 'http://endpoint_publicurl',
|
||||
'service_id': SERVICE_ID,
|
||||
|
||||
}
|
||||
endpoint_info.update(attrs)
|
||||
|
||||
endpoint = fakes.FakeResource(info=copy.deepcopy(endpoint_info),
|
||||
loaded=True)
|
||||
return endpoint
|
||||
|
||||
@staticmethod
|
||||
def create_endpoints(attrs=None, count=2):
|
||||
"""Create multiple fake endpoints.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:param int count:
|
||||
The number of endpoints to fake
|
||||
:return:
|
||||
A list of FakeResource objects faking the endpoints
|
||||
"""
|
||||
endpoints = []
|
||||
for i in range(0, count):
|
||||
endpoints.append(FakeEndpoint.create_one_endpoint(attrs))
|
||||
|
||||
return endpoints
|
||||
|
||||
|
||||
class FakeService(object):
|
||||
"""Fake one or more service."""
|
||||
|
||||
@staticmethod
|
||||
def create_one_service(attrs=None):
|
||||
"""Create a fake service.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:return:
|
||||
A FakeResource object, with id, name, type, and so on
|
||||
"""
|
||||
|
||||
attrs = attrs or {}
|
||||
|
||||
# set default attributes.
|
||||
service_info = {
|
||||
'id': SERVICE_ID,
|
||||
'name': SERVICE_NAME,
|
||||
'description': 'service_description',
|
||||
'type': 'service_type',
|
||||
|
||||
}
|
||||
service_info.update(attrs)
|
||||
|
||||
service = fakes.FakeResource(info=copy.deepcopy(service_info),
|
||||
loaded=True)
|
||||
return service
|
||||
|
||||
@staticmethod
|
||||
def create_services(attrs=None, count=2):
|
||||
"""Create multiple fake services.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:param int count:
|
||||
The number of services to fake
|
||||
:return:
|
||||
A list of FakeResource objects faking the services
|
||||
"""
|
||||
services = []
|
||||
for i in range(0, count):
|
||||
services.append(FakeService.create_one_service(attrs))
|
||||
|
||||
return services
|
||||
|
||||
|
||||
class FakeRole(object):
|
||||
"""Fake one or more role."""
|
||||
|
||||
@staticmethod
|
||||
def create_one_role(attrs=None):
|
||||
"""Create a fake role.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:return:
|
||||
A FakeResource object, with id, name, and so on
|
||||
"""
|
||||
|
||||
attrs = attrs or {}
|
||||
|
||||
# set default attributes.
|
||||
role_info = {
|
||||
'id': 'role-id' + uuid.uuid4().hex,
|
||||
'name': 'role-name' + uuid.uuid4().hex,
|
||||
}
|
||||
role_info.update(attrs)
|
||||
|
||||
role = fakes.FakeResource(info=copy.deepcopy(role_info),
|
||||
loaded=True)
|
||||
return role
|
||||
|
||||
@staticmethod
|
||||
def create_roles(attrs=None, count=2):
|
||||
"""Create multiple fake roles.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:param int count:
|
||||
The number of roles to fake
|
||||
:return:
|
||||
A list of FakeResource objects faking the roles
|
||||
"""
|
||||
roles = []
|
||||
for i in range(0, count):
|
||||
roles.append(FakeRole.create_one_role(attrs))
|
||||
|
||||
return roles
|
||||
|
@ -20,38 +20,14 @@ from openstackclient.tests import utils
|
||||
|
||||
class TestCatalog(utils.TestCommand):
|
||||
|
||||
fake_service = {
|
||||
'id': 'qwertyuiop',
|
||||
'type': 'compute',
|
||||
'name': 'supernova',
|
||||
'endpoints': [
|
||||
{
|
||||
'region': 'one',
|
||||
'publicURL': 'https://public.one.example.com',
|
||||
'internalURL': 'https://internal.one.example.com',
|
||||
'adminURL': 'https://admin.one.example.com',
|
||||
},
|
||||
{
|
||||
'region': 'two',
|
||||
'publicURL': 'https://public.two.example.com',
|
||||
'internalURL': 'https://internal.two.example.com',
|
||||
'adminURL': 'https://admin.two.example.com',
|
||||
},
|
||||
{
|
||||
'region': None,
|
||||
'publicURL': 'https://public.none.example.com',
|
||||
'internalURL': 'https://internal.none.example.com',
|
||||
'adminURL': 'https://admin.none.example.com',
|
||||
},
|
||||
],
|
||||
}
|
||||
service_catalog = identity_fakes.FakeCatalog.create_catalog()
|
||||
|
||||
def setUp(self):
|
||||
super(TestCatalog, self).setUp()
|
||||
|
||||
self.sc_mock = mock.MagicMock()
|
||||
self.sc_mock.service_catalog.catalog.return_value = [
|
||||
self.fake_service,
|
||||
self.service_catalog,
|
||||
]
|
||||
|
||||
self.auth_mock = mock.MagicMock()
|
||||
@ -77,7 +53,7 @@ class TestCatalogList(TestCatalog):
|
||||
def test_catalog_list(self):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.TOKEN,
|
||||
fake_service=self.fake_service,
|
||||
fake_service=self.service_catalog,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
@ -108,7 +84,7 @@ class TestCatalogList(TestCatalog):
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_catalog_list_with_endpoint_url(self):
|
||||
fake_service = {
|
||||
attr = {
|
||||
'id': 'qwertyuiop',
|
||||
'type': 'compute',
|
||||
'name': 'supernova',
|
||||
@ -124,9 +100,10 @@ class TestCatalogList(TestCatalog):
|
||||
},
|
||||
],
|
||||
}
|
||||
service_catalog = identity_fakes.FakeCatalog.create_catalog(attr)
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.TOKEN,
|
||||
fake_service=fake_service,
|
||||
fake_service=service_catalog,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
@ -162,7 +139,7 @@ class TestCatalogShow(TestCatalog):
|
||||
def test_catalog_show(self):
|
||||
auth_ref = identity_fakes.fake_auth_ref(
|
||||
identity_fakes.UNSCOPED_TOKEN,
|
||||
fake_service=self.fake_service,
|
||||
fake_service=self.service_catalog,
|
||||
)
|
||||
self.ar_mock = mock.PropertyMock(return_value=auth_ref)
|
||||
type(self.app.client_manager).auth_ref = self.ar_mock
|
||||
@ -192,7 +169,7 @@ class TestCatalogShow(TestCatalog):
|
||||
'<none>\n publicURL: https://public.none.example.com\n '
|
||||
'internalURL: https://internal.none.example.com\n '
|
||||
'adminURL: https://admin.none.example.com\n',
|
||||
'qwertyuiop',
|
||||
self.service_catalog.id,
|
||||
'supernova',
|
||||
'compute',
|
||||
)
|
||||
|
@ -11,15 +11,15 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import copy
|
||||
|
||||
from openstackclient.identity.v2_0 import endpoint
|
||||
from openstackclient.tests import fakes
|
||||
from openstackclient.tests.identity.v2_0 import fakes as identity_fakes
|
||||
|
||||
|
||||
class TestEndpoint(identity_fakes.TestIdentityv2):
|
||||
|
||||
fake_endpoint = identity_fakes.FakeEndpoint.create_one_endpoint()
|
||||
fake_service = identity_fakes.FakeService.create_one_service()
|
||||
|
||||
def setUp(self):
|
||||
super(TestEndpoint, self).setUp()
|
||||
|
||||
@ -37,35 +37,27 @@ class TestEndpointCreate(TestEndpoint):
|
||||
def setUp(self):
|
||||
super(TestEndpointCreate, self).setUp()
|
||||
|
||||
self.endpoints_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.ENDPOINT),
|
||||
loaded=True,
|
||||
)
|
||||
self.endpoints_mock.create.return_value = self.fake_endpoint
|
||||
|
||||
self.services_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.SERVICE),
|
||||
loaded=True,
|
||||
)
|
||||
self.services_mock.get.return_value = self.fake_service
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = endpoint.CreateEndpoint(self.app, None)
|
||||
|
||||
def test_endpoint_create(self):
|
||||
arglist = [
|
||||
'--publicurl', identity_fakes.endpoint_publicurl,
|
||||
'--internalurl', identity_fakes.endpoint_internalurl,
|
||||
'--adminurl', identity_fakes.endpoint_adminurl,
|
||||
'--region', identity_fakes.endpoint_region,
|
||||
identity_fakes.endpoint_name,
|
||||
'--publicurl', self.fake_endpoint.publicurl,
|
||||
'--internalurl', self.fake_endpoint.internalurl,
|
||||
'--adminurl', self.fake_endpoint.adminurl,
|
||||
'--region', self.fake_endpoint.region,
|
||||
self.fake_service.id,
|
||||
]
|
||||
verifylist = [
|
||||
('adminurl', identity_fakes.endpoint_adminurl),
|
||||
('internalurl', identity_fakes.endpoint_internalurl),
|
||||
('publicurl', identity_fakes.endpoint_publicurl),
|
||||
('region', identity_fakes.endpoint_region),
|
||||
('service', identity_fakes.service_name),
|
||||
('adminurl', self.fake_endpoint.adminurl),
|
||||
('internalurl', self.fake_endpoint.internalurl),
|
||||
('publicurl', self.fake_endpoint.publicurl),
|
||||
('region', self.fake_endpoint.region),
|
||||
('service', self.fake_service.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -77,25 +69,25 @@ class TestEndpointCreate(TestEndpoint):
|
||||
# EndpointManager.create(region, service_id, publicurl, adminurl,
|
||||
# internalurl)
|
||||
self.endpoints_mock.create.assert_called_with(
|
||||
identity_fakes.endpoint_region,
|
||||
identity_fakes.service_id,
|
||||
identity_fakes.endpoint_publicurl,
|
||||
identity_fakes.endpoint_adminurl,
|
||||
identity_fakes.endpoint_internalurl,
|
||||
self.fake_endpoint.region,
|
||||
self.fake_service.id,
|
||||
self.fake_endpoint.publicurl,
|
||||
self.fake_endpoint.adminurl,
|
||||
self.fake_endpoint.internalurl,
|
||||
)
|
||||
|
||||
collist = ('adminurl', 'id', 'internalurl', 'publicurl',
|
||||
'region', 'service_id', 'service_name', 'service_type')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.endpoint_adminurl,
|
||||
identity_fakes.endpoint_id,
|
||||
identity_fakes.endpoint_internalurl,
|
||||
identity_fakes.endpoint_publicurl,
|
||||
identity_fakes.endpoint_region,
|
||||
identity_fakes.service_id,
|
||||
identity_fakes.service_name,
|
||||
identity_fakes.service_type,
|
||||
self.fake_endpoint.adminurl,
|
||||
self.fake_endpoint.id,
|
||||
self.fake_endpoint.internalurl,
|
||||
self.fake_endpoint.publicurl,
|
||||
self.fake_endpoint.region,
|
||||
self.fake_endpoint.service_id,
|
||||
self.fake_endpoint.service_name,
|
||||
self.fake_endpoint.service_type,
|
||||
)
|
||||
|
||||
self.assertEqual(datalist, data)
|
||||
@ -106,17 +98,9 @@ class TestEndpointDelete(TestEndpoint):
|
||||
def setUp(self):
|
||||
super(TestEndpointDelete, self).setUp()
|
||||
|
||||
self.endpoints_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.ENDPOINT),
|
||||
loaded=True,
|
||||
)
|
||||
self.endpoints_mock.get.return_value = self.fake_endpoint
|
||||
|
||||
self.services_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.SERVICE),
|
||||
loaded=True,
|
||||
)
|
||||
self.services_mock.get.return_value = self.fake_service
|
||||
|
||||
self.endpoints_mock.delete.return_value = None
|
||||
|
||||
@ -125,17 +109,17 @@ class TestEndpointDelete(TestEndpoint):
|
||||
|
||||
def test_endpoint_delete_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.endpoint_id,
|
||||
self.fake_endpoint.id,
|
||||
]
|
||||
verifylist = [
|
||||
('endpoint', identity_fakes.endpoint_id),
|
||||
('endpoint', self.fake_endpoint.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.endpoints_mock.delete.assert_called_with(
|
||||
identity_fakes.endpoint_id,
|
||||
self.fake_endpoint.id,
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@ -145,19 +129,9 @@ class TestEndpointList(TestEndpoint):
|
||||
def setUp(self):
|
||||
super(TestEndpointList, self).setUp()
|
||||
|
||||
self.endpoints_mock.list.return_value = [
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.ENDPOINT),
|
||||
loaded=True,
|
||||
),
|
||||
]
|
||||
self.endpoints_mock.list.return_value = [self.fake_endpoint]
|
||||
|
||||
self.services_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.SERVICE),
|
||||
loaded=True,
|
||||
)
|
||||
self.services_mock.get.return_value = self.fake_service
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = endpoint.ListEndpoint(self.app, None)
|
||||
@ -177,10 +151,10 @@ class TestEndpointList(TestEndpoint):
|
||||
collist = ('ID', 'Region', 'Service Name', 'Service Type')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = ((
|
||||
identity_fakes.endpoint_id,
|
||||
identity_fakes.endpoint_region,
|
||||
identity_fakes.service_name,
|
||||
identity_fakes.service_type,
|
||||
self.fake_endpoint.id,
|
||||
self.fake_endpoint.region,
|
||||
self.fake_endpoint.service_name,
|
||||
self.fake_endpoint.service_type,
|
||||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -204,13 +178,13 @@ class TestEndpointList(TestEndpoint):
|
||||
'PublicURL', 'AdminURL', 'InternalURL')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = ((
|
||||
identity_fakes.endpoint_id,
|
||||
identity_fakes.endpoint_region,
|
||||
identity_fakes.service_name,
|
||||
identity_fakes.service_type,
|
||||
identity_fakes.endpoint_publicurl,
|
||||
identity_fakes.endpoint_adminurl,
|
||||
identity_fakes.endpoint_internalurl,
|
||||
self.fake_endpoint.id,
|
||||
self.fake_endpoint.region,
|
||||
self.fake_endpoint.service_name,
|
||||
self.fake_endpoint.service_type,
|
||||
self.fake_endpoint.publicurl,
|
||||
self.fake_endpoint.adminurl,
|
||||
self.fake_endpoint.internalurl,
|
||||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -220,29 +194,19 @@ class TestEndpointShow(TestEndpoint):
|
||||
def setUp(self):
|
||||
super(TestEndpointShow, self).setUp()
|
||||
|
||||
self.endpoints_mock.list.return_value = [
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.ENDPOINT),
|
||||
loaded=True,
|
||||
),
|
||||
]
|
||||
self.endpoints_mock.list.return_value = [self.fake_endpoint]
|
||||
|
||||
self.services_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.SERVICE),
|
||||
loaded=True,
|
||||
)
|
||||
self.services_mock.get.return_value = self.fake_service
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = endpoint.ShowEndpoint(self.app, None)
|
||||
|
||||
def test_endpoint_show(self):
|
||||
arglist = [
|
||||
identity_fakes.endpoint_name,
|
||||
self.fake_endpoint.id,
|
||||
]
|
||||
verifylist = [
|
||||
('endpoint_or_service', identity_fakes.endpoint_name),
|
||||
('endpoint_or_service', self.fake_endpoint.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -255,20 +219,20 @@ class TestEndpointShow(TestEndpoint):
|
||||
self.endpoints_mock.list.assert_called_with()
|
||||
# ServiceManager.get(name)
|
||||
self.services_mock.get.assert_called_with(
|
||||
identity_fakes.service_name,
|
||||
self.fake_endpoint.service_id,
|
||||
)
|
||||
|
||||
collist = ('adminurl', 'id', 'internalurl', 'publicurl',
|
||||
'region', 'service_id', 'service_name', 'service_type')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.endpoint_adminurl,
|
||||
identity_fakes.endpoint_id,
|
||||
identity_fakes.endpoint_internalurl,
|
||||
identity_fakes.endpoint_publicurl,
|
||||
identity_fakes.endpoint_region,
|
||||
identity_fakes.service_id,
|
||||
identity_fakes.service_name,
|
||||
identity_fakes.service_type,
|
||||
self.fake_endpoint.adminurl,
|
||||
self.fake_endpoint.id,
|
||||
self.fake_endpoint.internalurl,
|
||||
self.fake_endpoint.publicurl,
|
||||
self.fake_endpoint.region,
|
||||
self.fake_endpoint.service_id,
|
||||
self.fake_endpoint.service_name,
|
||||
self.fake_endpoint.service_type,
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
@ -13,18 +13,30 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import copy
|
||||
|
||||
from keystoneauth1 import exceptions as ks_exc
|
||||
from osc_lib import exceptions
|
||||
|
||||
from openstackclient.identity.v2_0 import project
|
||||
from openstackclient.tests import fakes
|
||||
from openstackclient.tests.identity.v2_0 import fakes as identity_fakes
|
||||
|
||||
|
||||
class TestProject(identity_fakes.TestIdentityv2):
|
||||
|
||||
fake_project = identity_fakes.FakeProject.create_one_project()
|
||||
|
||||
columns = (
|
||||
'description',
|
||||
'enabled',
|
||||
'id',
|
||||
'name',
|
||||
)
|
||||
datalist = (
|
||||
fake_project.description,
|
||||
True,
|
||||
fake_project.id,
|
||||
fake_project.name,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestProject, self).setUp()
|
||||
|
||||
@ -35,39 +47,22 @@ class TestProject(identity_fakes.TestIdentityv2):
|
||||
|
||||
class TestProjectCreate(TestProject):
|
||||
|
||||
columns = (
|
||||
'description',
|
||||
'enabled',
|
||||
'id',
|
||||
'name',
|
||||
)
|
||||
datalist = (
|
||||
identity_fakes.project_description,
|
||||
True,
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestProjectCreate, self).setUp()
|
||||
|
||||
self.projects_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.create.return_value = self.fake_project
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = project.CreateProject(self.app, None)
|
||||
|
||||
def test_project_create_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -82,7 +77,7 @@ class TestProjectCreate(TestProject):
|
||||
'enabled': True,
|
||||
}
|
||||
self.projects_mock.create.assert_called_with(
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
**kwargs
|
||||
)
|
||||
self.assertEqual(self.columns, columns)
|
||||
@ -91,11 +86,11 @@ class TestProjectCreate(TestProject):
|
||||
def test_project_create_description(self):
|
||||
arglist = [
|
||||
'--description', 'new desc',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('description', 'new desc'),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -110,7 +105,7 @@ class TestProjectCreate(TestProject):
|
||||
'enabled': True,
|
||||
}
|
||||
self.projects_mock.create.assert_called_with(
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@ -120,12 +115,12 @@ class TestProjectCreate(TestProject):
|
||||
def test_project_create_enable(self):
|
||||
arglist = [
|
||||
'--enable',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', True),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -140,7 +135,7 @@ class TestProjectCreate(TestProject):
|
||||
'enabled': True,
|
||||
}
|
||||
self.projects_mock.create.assert_called_with(
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@ -150,12 +145,12 @@ class TestProjectCreate(TestProject):
|
||||
def test_project_create_disable(self):
|
||||
arglist = [
|
||||
'--disable',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', False),
|
||||
('disable', True),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -170,7 +165,7 @@ class TestProjectCreate(TestProject):
|
||||
'enabled': False,
|
||||
}
|
||||
self.projects_mock.create.assert_called_with(
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@ -181,11 +176,11 @@ class TestProjectCreate(TestProject):
|
||||
arglist = [
|
||||
'--property', 'fee=fi',
|
||||
'--property', 'fo=fum',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'fee': 'fi', 'fo': 'fum'}),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -202,7 +197,7 @@ class TestProjectCreate(TestProject):
|
||||
'fo': 'fum',
|
||||
}
|
||||
self.projects_mock.create.assert_called_with(
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@ -216,19 +211,15 @@ class TestProjectCreate(TestProject):
|
||||
# need to make this throw an exception...
|
||||
self.projects_mock.create.side_effect = _raise_conflict
|
||||
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.get.return_value = self.fake_project
|
||||
|
||||
arglist = [
|
||||
'--or-show',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('name', identity_fakes.project_name),
|
||||
('or_show', True),
|
||||
('name', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -238,7 +229,7 @@ class TestProjectCreate(TestProject):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
# ProjectManager.create(name, description, enabled)
|
||||
self.projects_mock.get.assert_called_with(identity_fakes.project_name)
|
||||
self.projects_mock.get.assert_called_with(self.fake_project.name)
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
@ -246,7 +237,7 @@ class TestProjectCreate(TestProject):
|
||||
'enabled': True,
|
||||
}
|
||||
self.projects_mock.create.assert_called_with(
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@ -256,11 +247,11 @@ class TestProjectCreate(TestProject):
|
||||
def test_project_create_or_show_not_exists(self):
|
||||
arglist = [
|
||||
'--or-show',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('name', identity_fakes.project_name),
|
||||
('or_show', True),
|
||||
('name', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -275,7 +266,7 @@ class TestProjectCreate(TestProject):
|
||||
'enabled': True,
|
||||
}
|
||||
self.projects_mock.create.assert_called_with(
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
@ -289,11 +280,7 @@ class TestProjectDelete(TestProject):
|
||||
super(TestProjectDelete, self).setUp()
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.get.return_value = self.fake_project
|
||||
self.projects_mock.delete.return_value = None
|
||||
|
||||
# Get the command object to test
|
||||
@ -301,17 +288,17 @@ class TestProjectDelete(TestProject):
|
||||
|
||||
def test_project_delete_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.project_id,
|
||||
self.fake_project.id,
|
||||
]
|
||||
verifylist = [
|
||||
('projects', [identity_fakes.project_id]),
|
||||
('projects', [self.fake_project.id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.projects_mock.delete.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_project.id,
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
@ -321,13 +308,7 @@ class TestProjectList(TestProject):
|
||||
def setUp(self):
|
||||
super(TestProjectList, self).setUp()
|
||||
|
||||
self.projects_mock.list.return_value = [
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
),
|
||||
]
|
||||
self.projects_mock.list.return_value = [self.fake_project]
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = project.ListProject(self.app, None)
|
||||
@ -346,8 +327,8 @@ class TestProjectList(TestProject):
|
||||
collist = ('ID', 'Name')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = ((
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.id,
|
||||
self.fake_project.name,
|
||||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
@ -369,9 +350,9 @@ class TestProjectList(TestProject):
|
||||
collist = ('ID', 'Name', 'Description', 'Enabled')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = ((
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
identity_fakes.project_description,
|
||||
self.fake_project.id,
|
||||
self.fake_project.name,
|
||||
self.fake_project.description,
|
||||
True,
|
||||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
@ -382,26 +363,18 @@ class TestProjectSet(TestProject):
|
||||
def setUp(self):
|
||||
super(TestProjectSet, self).setUp()
|
||||
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.update.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.get.return_value = self.fake_project
|
||||
self.projects_mock.update.return_value = self.fake_project
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = project.SetProject(self.app, None)
|
||||
|
||||
def test_project_set_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.fake_project.name),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
]
|
||||
@ -433,14 +406,14 @@ class TestProjectSet(TestProject):
|
||||
|
||||
def test_project_set_name(self):
|
||||
arglist = [
|
||||
'--name', 'qwerty',
|
||||
identity_fakes.project_name,
|
||||
'--name', self.fake_project.name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('name', 'qwerty'),
|
||||
('name', self.fake_project.name),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -448,26 +421,26 @@ class TestProjectSet(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': identity_fakes.project_description,
|
||||
'description': self.fake_project.description,
|
||||
'enabled': True,
|
||||
'tenant_name': 'qwerty',
|
||||
'tenant_name': self.fake_project.name,
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_project_set_description(self):
|
||||
arglist = [
|
||||
'--description', 'new desc',
|
||||
identity_fakes.project_name,
|
||||
'--description', self.fake_project.description,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('description', 'new desc'),
|
||||
('description', self.fake_project.description),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -475,12 +448,12 @@ class TestProjectSet(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': 'new desc',
|
||||
'description': self.fake_project.description,
|
||||
'enabled': True,
|
||||
'tenant_name': identity_fakes.project_name,
|
||||
'tenant_name': self.fake_project.name,
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -488,12 +461,12 @@ class TestProjectSet(TestProject):
|
||||
def test_project_set_enable(self):
|
||||
arglist = [
|
||||
'--enable',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', True),
|
||||
('disable', False),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -501,12 +474,12 @@ class TestProjectSet(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': identity_fakes.project_description,
|
||||
'description': self.fake_project.description,
|
||||
'enabled': True,
|
||||
'tenant_name': identity_fakes.project_name,
|
||||
'tenant_name': self.fake_project.name,
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -514,12 +487,12 @@ class TestProjectSet(TestProject):
|
||||
def test_project_set_disable(self):
|
||||
arglist = [
|
||||
'--disable',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', False),
|
||||
('disable', True),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -527,12 +500,12 @@ class TestProjectSet(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': identity_fakes.project_description,
|
||||
'description': self.fake_project.description,
|
||||
'enabled': False,
|
||||
'tenant_name': identity_fakes.project_name,
|
||||
'tenant_name': self.fake_project.name,
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -541,11 +514,11 @@ class TestProjectSet(TestProject):
|
||||
arglist = [
|
||||
'--property', 'fee=fi',
|
||||
'--property', 'fo=fum',
|
||||
identity_fakes.project_name,
|
||||
self.fake_project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'fee': 'fi', 'fo': 'fum'}),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.fake_project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -553,14 +526,14 @@ class TestProjectSet(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': identity_fakes.project_description,
|
||||
'description': self.fake_project.description,
|
||||
'enabled': True,
|
||||
'tenant_name': identity_fakes.project_name,
|
||||
'tenant_name': self.fake_project.name,
|
||||
'fee': 'fi',
|
||||
'fo': 'fum',
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -568,24 +541,22 @@ class TestProjectSet(TestProject):
|
||||
|
||||
class TestProjectShow(TestProject):
|
||||
|
||||
fake_proj_show = identity_fakes.FakeProject.create_one_project()
|
||||
|
||||
def setUp(self):
|
||||
super(TestProjectShow, self).setUp()
|
||||
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.get.return_value = self.fake_proj_show
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = project.ShowProject(self.app, None)
|
||||
|
||||
def test_project_show(self):
|
||||
arglist = [
|
||||
identity_fakes.project_id,
|
||||
self.fake_proj_show.id,
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_id),
|
||||
('project', self.fake_proj_show.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -594,16 +565,16 @@ class TestProjectShow(TestProject):
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.projects_mock.get.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_proj_show.id,
|
||||
)
|
||||
|
||||
collist = ('description', 'enabled', 'id', 'name', 'properties')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.project_description,
|
||||
self.fake_proj_show.description,
|
||||
True,
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
self.fake_proj_show.id,
|
||||
self.fake_proj_show.name,
|
||||
'',
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
@ -611,26 +582,23 @@ class TestProjectShow(TestProject):
|
||||
|
||||
class TestProjectUnset(TestProject):
|
||||
|
||||
attr = {'fee': 'fi', 'fo': 'fum'}
|
||||
fake_proj = identity_fakes.FakeProject.create_one_project(attr)
|
||||
|
||||
def setUp(self):
|
||||
super(TestProjectUnset, self).setUp()
|
||||
|
||||
project_dict = {'fee': 'fi', 'fo': 'fum'}
|
||||
project_dict.update(identity_fakes.PROJECT)
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(project_dict),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.get.return_value = self.fake_proj
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = project.UnsetProject(self.app, None)
|
||||
|
||||
def test_project_unset_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.project_name,
|
||||
self.fake_proj.name,
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.fake_proj.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -642,7 +610,7 @@ class TestProjectUnset(TestProject):
|
||||
arglist = [
|
||||
'--property', 'fee',
|
||||
'--property', 'fo',
|
||||
identity_fakes.project_name,
|
||||
self.fake_proj.name,
|
||||
]
|
||||
verifylist = [
|
||||
('property', ['fee', 'fo']),
|
||||
@ -652,16 +620,16 @@ class TestProjectUnset(TestProject):
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'description': identity_fakes.project_description,
|
||||
'description': self.fake_proj.description,
|
||||
'enabled': True,
|
||||
'fee': None,
|
||||
'fo': None,
|
||||
'id': identity_fakes.project_id,
|
||||
'name': identity_fakes.project_name,
|
||||
'id': self.fake_proj.id,
|
||||
'name': self.fake_proj.name,
|
||||
}
|
||||
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.fake_proj.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
@ -26,12 +26,14 @@ from openstackclient.tests.identity.v2_0 import fakes as identity_fakes
|
||||
|
||||
class TestRole(identity_fakes.TestIdentityv2):
|
||||
|
||||
fake_service = copy.deepcopy(identity_fakes.SERVICE)
|
||||
fake_service['endpoints'] = [
|
||||
attr = {}
|
||||
attr['endpoints'] = [
|
||||
{
|
||||
'publicURL': identity_fakes.ENDPOINT['publicurl'],
|
||||
},
|
||||
]
|
||||
fake_service = identity_fakes.FakeService.create_one_service(attr)
|
||||
fake_role = identity_fakes.FakeRole.create_one_role()
|
||||
|
||||
def setUp(self):
|
||||
super(TestRole, self).setUp()
|
||||
@ -508,21 +510,17 @@ class TestRoleShow(TestRole):
|
||||
def setUp(self):
|
||||
super(TestRoleShow, self).setUp()
|
||||
|
||||
self.roles_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.ROLE),
|
||||
loaded=True,
|
||||
)
|
||||
self.roles_mock.get.return_value = self.fake_role
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = role.ShowRole(self.app, None)
|
||||
|
||||
def test_service_show(self):
|
||||
arglist = [
|
||||
identity_fakes.role_name,
|
||||
self.fake_role.name,
|
||||
]
|
||||
verifylist = [
|
||||
('role', identity_fakes.role_name),
|
||||
('role', self.fake_role.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -533,13 +531,13 @@ class TestRoleShow(TestRole):
|
||||
|
||||
# RoleManager.get(role)
|
||||
self.roles_mock.get.assert_called_with(
|
||||
identity_fakes.role_name,
|
||||
self.fake_role.name,
|
||||
)
|
||||
|
||||
collist = ('id', 'name')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.role_id,
|
||||
identity_fakes.role_name,
|
||||
self.fake_role.id,
|
||||
self.fake_role.name,
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user