Merge "Refactor unit tests for project and domain with fake classes in identityv3"
This commit is contained in:
commit
4ce7dd53e8
@ -15,6 +15,7 @@
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import uuid
|
||||
|
||||
from keystoneauth1 import access
|
||||
from keystoneauth1 import fixture
|
||||
@ -575,3 +576,66 @@ class TestOAuth1(utils.TestCommand):
|
||||
endpoint=fakes.AUTH_URL,
|
||||
token=fakes.AUTH_TOKEN
|
||||
)
|
||||
|
||||
|
||||
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-' + uuid.uuid4().hex,
|
||||
'enabled': True,
|
||||
'is_domain': False,
|
||||
'domain_id': 'domain-id-' + uuid.uuid4().hex,
|
||||
'parent_id': 'parent-id-' + uuid.uuid4().hex,
|
||||
'links': 'links-' + uuid.uuid4().hex,
|
||||
}
|
||||
project_info.update(attrs)
|
||||
|
||||
project = fakes.FakeResource(info=copy.deepcopy(project_info),
|
||||
loaded=True)
|
||||
return project
|
||||
|
||||
|
||||
class FakeDomain(object):
|
||||
"""Fake one or more domain."""
|
||||
|
||||
@staticmethod
|
||||
def create_one_domain(attrs=None):
|
||||
"""Create a fake domain.
|
||||
|
||||
:param Dictionary attrs:
|
||||
A dictionary with all attributes
|
||||
:return:
|
||||
A FakeResource object, with id, name, and so on
|
||||
"""
|
||||
|
||||
attrs = attrs or {}
|
||||
|
||||
# set default attributes.
|
||||
domain_info = {
|
||||
'id': 'domain-id-' + uuid.uuid4().hex,
|
||||
'name': 'domain-name-' + uuid.uuid4().hex,
|
||||
'description': 'domain-description-' + uuid.uuid4().hex,
|
||||
'enabled': True,
|
||||
'links': 'links-' + uuid.uuid4().hex,
|
||||
}
|
||||
domain_info.update(attrs)
|
||||
|
||||
domain = fakes.FakeResource(info=copy.deepcopy(domain_info),
|
||||
loaded=True)
|
||||
return domain
|
||||
|
@ -10,10 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
|
||||
from openstackclient.identity.v3 import domain
|
||||
from openstackclient.tests import fakes
|
||||
from openstackclient.tests.identity.v3 import fakes as identity_fakes
|
||||
|
||||
|
||||
@ -35,20 +32,17 @@ class TestDomainCreate(TestDomain):
|
||||
'id',
|
||||
'name',
|
||||
)
|
||||
datalist = (
|
||||
identity_fakes.domain_description,
|
||||
True,
|
||||
identity_fakes.domain_id,
|
||||
identity_fakes.domain_name,
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestDomainCreate, self).setUp()
|
||||
|
||||
self.domains_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
self.domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
self.domains_mock.create.return_value = self.domain
|
||||
self.datalist = (
|
||||
self.domain.description,
|
||||
True,
|
||||
self.domain.id,
|
||||
self.domain.name,
|
||||
)
|
||||
|
||||
# Get the command object to test
|
||||
@ -56,10 +50,10 @@ class TestDomainCreate(TestDomain):
|
||||
|
||||
def test_domain_create_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.domain_name,
|
||||
self.domain.name,
|
||||
]
|
||||
verifylist = [
|
||||
('name', identity_fakes.domain_name),
|
||||
('name', self.domain.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -70,7 +64,7 @@ class TestDomainCreate(TestDomain):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.domain_name,
|
||||
'name': self.domain.name,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
}
|
||||
@ -84,11 +78,11 @@ class TestDomainCreate(TestDomain):
|
||||
def test_domain_create_description(self):
|
||||
arglist = [
|
||||
'--description', 'new desc',
|
||||
identity_fakes.domain_name,
|
||||
self.domain.name,
|
||||
]
|
||||
verifylist = [
|
||||
('description', 'new desc'),
|
||||
('name', identity_fakes.domain_name),
|
||||
('name', self.domain.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -99,7 +93,7 @@ class TestDomainCreate(TestDomain):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.domain_name,
|
||||
'name': self.domain.name,
|
||||
'description': 'new desc',
|
||||
'enabled': True,
|
||||
}
|
||||
@ -113,11 +107,11 @@ class TestDomainCreate(TestDomain):
|
||||
def test_domain_create_enable(self):
|
||||
arglist = [
|
||||
'--enable',
|
||||
identity_fakes.domain_name,
|
||||
self.domain.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', True),
|
||||
('name', identity_fakes.domain_name),
|
||||
('name', self.domain.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -128,7 +122,7 @@ class TestDomainCreate(TestDomain):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.domain_name,
|
||||
'name': self.domain.name,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
}
|
||||
@ -142,11 +136,11 @@ class TestDomainCreate(TestDomain):
|
||||
def test_domain_create_disable(self):
|
||||
arglist = [
|
||||
'--disable',
|
||||
identity_fakes.domain_name,
|
||||
self.domain.name,
|
||||
]
|
||||
verifylist = [
|
||||
('disable', True),
|
||||
('name', identity_fakes.domain_name),
|
||||
('name', self.domain.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -157,7 +151,7 @@ class TestDomainCreate(TestDomain):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.domain_name,
|
||||
'name': self.domain.name,
|
||||
'description': None,
|
||||
'enabled': False,
|
||||
}
|
||||
@ -171,15 +165,13 @@ class TestDomainCreate(TestDomain):
|
||||
|
||||
class TestDomainDelete(TestDomain):
|
||||
|
||||
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
|
||||
def setUp(self):
|
||||
super(TestDomainDelete, self).setUp()
|
||||
|
||||
# This is the return value for utils.find_resource()
|
||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
)
|
||||
self.domains_mock.get.return_value = self.domain
|
||||
self.domains_mock.delete.return_value = None
|
||||
|
||||
# Get the command object to test
|
||||
@ -187,33 +179,29 @@ class TestDomainDelete(TestDomain):
|
||||
|
||||
def test_domain_delete(self):
|
||||
arglist = [
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.domain.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.domains_mock.delete.assert_called_with(
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestDomainList(TestDomain):
|
||||
|
||||
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
|
||||
def setUp(self):
|
||||
super(TestDomainList, self).setUp()
|
||||
|
||||
self.domains_mock.list.return_value = [
|
||||
fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
),
|
||||
]
|
||||
self.domains_mock.list.return_value = [self.domain]
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = domain.ListDomain(self.app, None)
|
||||
@ -232,40 +220,34 @@ class TestDomainList(TestDomain):
|
||||
collist = ('ID', 'Name', 'Enabled', 'Description')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = ((
|
||||
identity_fakes.domain_id,
|
||||
identity_fakes.domain_name,
|
||||
self.domain.id,
|
||||
self.domain.name,
|
||||
True,
|
||||
identity_fakes.domain_description,
|
||||
self.domain.description,
|
||||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
|
||||
class TestDomainSet(TestDomain):
|
||||
|
||||
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
|
||||
def setUp(self):
|
||||
super(TestDomainSet, self).setUp()
|
||||
|
||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
)
|
||||
self.domains_mock.get.return_value = self.domain
|
||||
|
||||
self.domains_mock.update.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
)
|
||||
self.domains_mock.update.return_value = self.domain
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = domain.SetDomain(self.app, None)
|
||||
|
||||
def test_domain_set_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.domain_name,
|
||||
self.domain.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_name),
|
||||
('domain', self.domain.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -277,11 +259,11 @@ class TestDomainSet(TestDomain):
|
||||
def test_domain_set_name(self):
|
||||
arglist = [
|
||||
'--name', 'qwerty',
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
]
|
||||
verifylist = [
|
||||
('name', 'qwerty'),
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.domain.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -292,7 +274,7 @@ class TestDomainSet(TestDomain):
|
||||
'name': 'qwerty',
|
||||
}
|
||||
self.domains_mock.update.assert_called_with(
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -300,11 +282,11 @@ class TestDomainSet(TestDomain):
|
||||
def test_domain_set_description(self):
|
||||
arglist = [
|
||||
'--description', 'new desc',
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
]
|
||||
verifylist = [
|
||||
('description', 'new desc'),
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.domain.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -315,7 +297,7 @@ class TestDomainSet(TestDomain):
|
||||
'description': 'new desc',
|
||||
}
|
||||
self.domains_mock.update.assert_called_with(
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -323,11 +305,11 @@ class TestDomainSet(TestDomain):
|
||||
def test_domain_set_enable(self):
|
||||
arglist = [
|
||||
'--enable',
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', True),
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.domain.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -338,7 +320,7 @@ class TestDomainSet(TestDomain):
|
||||
'enabled': True,
|
||||
}
|
||||
self.domains_mock.update.assert_called_with(
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -346,11 +328,11 @@ class TestDomainSet(TestDomain):
|
||||
def test_domain_set_disable(self):
|
||||
arglist = [
|
||||
'--disable',
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
]
|
||||
verifylist = [
|
||||
('disable', True),
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.domain.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -361,7 +343,7 @@ class TestDomainSet(TestDomain):
|
||||
'enabled': False,
|
||||
}
|
||||
self.domains_mock.update.assert_called_with(
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -372,21 +354,17 @@ class TestDomainShow(TestDomain):
|
||||
def setUp(self):
|
||||
super(TestDomainShow, self).setUp()
|
||||
|
||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
self.domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
self.domains_mock.get.return_value = self.domain
|
||||
# Get the command object to test
|
||||
self.cmd = domain.ShowDomain(self.app, None)
|
||||
|
||||
def test_domain_show(self):
|
||||
arglist = [
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.domain.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
self.app.client_manager.identity.tokens.get_token_data.return_value = \
|
||||
@ -405,15 +383,15 @@ class TestDomainShow(TestDomain):
|
||||
# data to be shown.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.domains_mock.get.assert_called_with(
|
||||
identity_fakes.domain_id,
|
||||
self.domain.id,
|
||||
)
|
||||
|
||||
collist = ('description', 'enabled', 'id', 'name')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.domain_description,
|
||||
self.domain.description,
|
||||
True,
|
||||
identity_fakes.domain_id,
|
||||
identity_fakes.domain_name,
|
||||
self.domain.id,
|
||||
self.domain.name,
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
@ -13,14 +13,12 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import copy
|
||||
import mock
|
||||
|
||||
from osc_lib import exceptions
|
||||
import testtools
|
||||
|
||||
from openstackclient.identity.v3 import project
|
||||
from openstackclient.tests import fakes
|
||||
from openstackclient.tests.identity.v3 import fakes as identity_fakes
|
||||
|
||||
|
||||
@ -40,48 +38,46 @@ class TestProject(identity_fakes.TestIdentityv3):
|
||||
|
||||
class TestProjectCreate(TestProject):
|
||||
|
||||
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
|
||||
columns = (
|
||||
'description',
|
||||
'domain_id',
|
||||
'enabled',
|
||||
'id',
|
||||
'name'
|
||||
)
|
||||
datalist = (
|
||||
identity_fakes.project_description,
|
||||
identity_fakes.domain_id,
|
||||
True,
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
'is_domain',
|
||||
'name',
|
||||
'parent_id',
|
||||
)
|
||||
|
||||
def setUp(self):
|
||||
super(TestProjectCreate, self).setUp()
|
||||
|
||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
self.project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={'domain_id': self.domain.id})
|
||||
self.domains_mock.get.return_value = self.domain
|
||||
self.projects_mock.create.return_value = self.project
|
||||
self.datalist = (
|
||||
self.project.description,
|
||||
self.project.domain_id,
|
||||
True,
|
||||
self.project.id,
|
||||
False,
|
||||
self.project.name,
|
||||
self.project.parent_id,
|
||||
)
|
||||
|
||||
self.projects_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
|
||||
# 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.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('parent', None),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -92,7 +88,7 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.project_name,
|
||||
'name': self.project.name,
|
||||
'domain': None,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
@ -104,27 +100,37 @@ class TestProjectCreate(TestProject):
|
||||
**kwargs
|
||||
)
|
||||
|
||||
collist = ('description', 'domain_id', 'enabled', 'id', 'name')
|
||||
collist = (
|
||||
'description',
|
||||
'domain_id',
|
||||
'enabled',
|
||||
'id',
|
||||
'is_domain',
|
||||
'name',
|
||||
'parent_id',
|
||||
)
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.project_description,
|
||||
identity_fakes.domain_id,
|
||||
self.project.description,
|
||||
self.project.domain_id,
|
||||
True,
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
self.project.id,
|
||||
False,
|
||||
self.project.name,
|
||||
self.project.parent_id,
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
def test_project_create_description(self):
|
||||
arglist = [
|
||||
'--description', 'new desc',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('description', 'new desc'),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
('parent', None),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -136,7 +142,7 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.project_name,
|
||||
'name': self.project.name,
|
||||
'domain': None,
|
||||
'description': 'new desc',
|
||||
'enabled': True,
|
||||
@ -153,14 +159,14 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
def test_project_create_domain(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_name,
|
||||
identity_fakes.project_name,
|
||||
'--domain', self.project.domain_id,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_name),
|
||||
('domain', self.project.domain_id),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
('parent', None),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -172,8 +178,8 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.project_name,
|
||||
'domain': identity_fakes.domain_id,
|
||||
'name': self.project.name,
|
||||
'domain': self.project.domain_id,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
'parent': None,
|
||||
@ -189,14 +195,14 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
def test_project_create_domain_no_perms(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_id,
|
||||
identity_fakes.project_name,
|
||||
'--domain', self.project.domain_id,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.project.domain_id),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
('parent', None),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -208,8 +214,8 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.project_name,
|
||||
'domain': identity_fakes.domain_id,
|
||||
'name': self.project.name,
|
||||
'domain': self.project.domain_id,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
'parent': None,
|
||||
@ -223,12 +229,12 @@ class TestProjectCreate(TestProject):
|
||||
def test_project_create_enable(self):
|
||||
arglist = [
|
||||
'--enable',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', True),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
('parent', None),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -240,7 +246,7 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.project_name,
|
||||
'name': self.project.name,
|
||||
'domain': None,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
@ -258,12 +264,12 @@ class TestProjectCreate(TestProject):
|
||||
def test_project_create_disable(self):
|
||||
arglist = [
|
||||
'--disable',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('enable', False),
|
||||
('disable', True),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
('parent', None),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -275,7 +281,7 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.project_name,
|
||||
'name': self.project.name,
|
||||
'domain': None,
|
||||
'description': None,
|
||||
'enabled': False,
|
||||
@ -294,11 +300,11 @@ class TestProjectCreate(TestProject):
|
||||
arglist = [
|
||||
'--property', 'fee=fi',
|
||||
'--property', 'fo=fum',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'fee': 'fi', 'fo': 'fum'}),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -309,7 +315,7 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
# Set expected values
|
||||
kwargs = {
|
||||
'name': identity_fakes.project_name,
|
||||
'name': self.project.name,
|
||||
'domain': None,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
@ -327,37 +333,32 @@ class TestProjectCreate(TestProject):
|
||||
self.assertEqual(self.datalist, data)
|
||||
|
||||
def test_project_create_parent(self):
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.projects_mock.create.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT_WITH_PARENT),
|
||||
loaded=True,
|
||||
)
|
||||
self.parent = identity_fakes.FakeProject.create_one_project()
|
||||
self.project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={'domain_id': self.domain.id, 'parent_id': self.parent.id})
|
||||
self.projects_mock.get.return_value = self.parent
|
||||
self.projects_mock.create.return_value = self.project
|
||||
|
||||
arglist = [
|
||||
'--domain', identity_fakes.PROJECT_WITH_PARENT['domain_id'],
|
||||
'--parent', identity_fakes.PROJECT['name'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['name'],
|
||||
'--domain', self.project.domain_id,
|
||||
'--parent', self.parent.name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.PROJECT_WITH_PARENT['domain_id']),
|
||||
('parent', identity_fakes.PROJECT['name']),
|
||||
('domain', self.project.domain_id),
|
||||
('parent', self.parent.name),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('name', identity_fakes.PROJECT_WITH_PARENT['name']),
|
||||
('name', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
kwargs = {
|
||||
'name': identity_fakes.PROJECT_WITH_PARENT['name'],
|
||||
'domain': identity_fakes.PROJECT_WITH_PARENT['domain_id'],
|
||||
'parent': identity_fakes.PROJECT['id'],
|
||||
'name': self.project.name,
|
||||
'domain': self.project.domain_id,
|
||||
'parent': self.parent.id,
|
||||
'description': None,
|
||||
'enabled': True,
|
||||
}
|
||||
@ -371,17 +372,19 @@ class TestProjectCreate(TestProject):
|
||||
'domain_id',
|
||||
'enabled',
|
||||
'id',
|
||||
'is_domain',
|
||||
'name',
|
||||
'parent_id',
|
||||
)
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.PROJECT_WITH_PARENT['description'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['domain_id'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['enabled'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['id'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['name'],
|
||||
identity_fakes.PROJECT['id'],
|
||||
self.project.description,
|
||||
self.project.domain_id,
|
||||
self.project.enabled,
|
||||
self.project.id,
|
||||
self.project.is_domain,
|
||||
self.project.name,
|
||||
self.parent.id,
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
@ -393,16 +396,16 @@ class TestProjectCreate(TestProject):
|
||||
'Invalid parent')
|
||||
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_name,
|
||||
'--domain', self.project.domain_id,
|
||||
'--parent', 'invalid',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_name),
|
||||
('domain', self.project.domain_id),
|
||||
('parent', 'invalid'),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('name', identity_fakes.project_name),
|
||||
('name', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -415,15 +418,13 @@ class TestProjectCreate(TestProject):
|
||||
|
||||
class TestProjectDelete(TestProject):
|
||||
|
||||
project = identity_fakes.FakeProject.create_one_project()
|
||||
|
||||
def setUp(self):
|
||||
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.project
|
||||
self.projects_mock.delete.return_value = None
|
||||
|
||||
# Get the command object to test
|
||||
@ -431,44 +432,42 @@ class TestProjectDelete(TestProject):
|
||||
|
||||
def test_project_delete_no_options(self):
|
||||
arglist = [
|
||||
identity_fakes.project_id,
|
||||
self.project.id,
|
||||
]
|
||||
verifylist = [
|
||||
('projects', [identity_fakes.project_id]),
|
||||
('projects', [self.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.project.id,
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
|
||||
class TestProjectList(TestProject):
|
||||
|
||||
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={'domain_id': domain.id})
|
||||
|
||||
columns = (
|
||||
'ID',
|
||||
'Name',
|
||||
)
|
||||
datalist = (
|
||||
(
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
project.id,
|
||||
project.name,
|
||||
),
|
||||
)
|
||||
|
||||
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.project]
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = project.ListProject(self.app, None)
|
||||
@ -505,27 +504,23 @@ class TestProjectList(TestProject):
|
||||
collist = ('ID', 'Name', 'Domain ID', 'Description', 'Enabled')
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = ((
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
identity_fakes.domain_id,
|
||||
identity_fakes.project_description,
|
||||
self.project.id,
|
||||
self.project.name,
|
||||
self.project.domain_id,
|
||||
self.project.description,
|
||||
True,
|
||||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
def test_project_list_domain(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_name,
|
||||
'--domain', self.project.domain_id,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_name),
|
||||
('domain', self.project.domain_id),
|
||||
]
|
||||
|
||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
)
|
||||
self.domains_mock.get.return_value = self.domain
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -534,17 +529,17 @@ class TestProjectList(TestProject):
|
||||
# containing the data to be listed.
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.projects_mock.list.assert_called_with(
|
||||
domain=identity_fakes.domain_id)
|
||||
domain=self.project.domain_id)
|
||||
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
|
||||
def test_project_list_domain_no_perms(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_id,
|
||||
'--domain', self.project.domain_id,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.project.domain_id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
mocker = mock.Mock()
|
||||
@ -554,42 +549,34 @@ class TestProjectList(TestProject):
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
self.projects_mock.list.assert_called_with(
|
||||
domain=identity_fakes.domain_id)
|
||||
domain=self.project.domain_id)
|
||||
self.assertEqual(self.columns, columns)
|
||||
self.assertEqual(self.datalist, tuple(data))
|
||||
|
||||
|
||||
class TestProjectSet(TestProject):
|
||||
|
||||
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={'domain_id': domain.id})
|
||||
|
||||
def setUp(self):
|
||||
super(TestProjectSet, self).setUp()
|
||||
|
||||
self.domains_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.DOMAIN),
|
||||
loaded=True,
|
||||
)
|
||||
self.domains_mock.get.return_value = self.domain
|
||||
|
||||
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.project
|
||||
self.projects_mock.update.return_value = self.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.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.project.name),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
]
|
||||
@ -602,15 +589,15 @@ class TestProjectSet(TestProject):
|
||||
def test_project_set_name(self):
|
||||
arglist = [
|
||||
'--name', 'qwerty',
|
||||
'--domain', identity_fakes.domain_id,
|
||||
identity_fakes.project_name,
|
||||
'--domain', self.project.domain_id,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('name', 'qwerty'),
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.project.domain_id),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -623,23 +610,23 @@ class TestProjectSet(TestProject):
|
||||
# ProjectManager.update(project, name=, domain=, description=,
|
||||
# enabled=, **kwargs)
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_project_set_description(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_id,
|
||||
'--domain', self.project.domain_id,
|
||||
'--description', 'new desc',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.project.domain_id),
|
||||
('description', 'new desc'),
|
||||
('enable', False),
|
||||
('disable', False),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -650,22 +637,22 @@ class TestProjectSet(TestProject):
|
||||
'description': 'new desc',
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_project_set_enable(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_id,
|
||||
'--domain', self.project.domain_id,
|
||||
'--enable',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.project.domain_id),
|
||||
('enable', True),
|
||||
('disable', False),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -676,22 +663,22 @@ class TestProjectSet(TestProject):
|
||||
'enabled': True,
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_project_set_disable(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_id,
|
||||
'--domain', self.project.domain_id,
|
||||
'--disable',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.project.domain_id),
|
||||
('enable', False),
|
||||
('disable', True),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -702,22 +689,22 @@ class TestProjectSet(TestProject):
|
||||
'enabled': False,
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_project_set_property(self):
|
||||
arglist = [
|
||||
'--domain', identity_fakes.domain_id,
|
||||
'--domain', self.project.domain_id,
|
||||
'--property', 'fee=fi',
|
||||
'--property', 'fo=fum',
|
||||
identity_fakes.project_name,
|
||||
self.project.name,
|
||||
]
|
||||
verifylist = [
|
||||
('domain', identity_fakes.domain_id),
|
||||
('domain', self.project.domain_id),
|
||||
('property', {'fee': 'fi', 'fo': 'fum'}),
|
||||
('project', identity_fakes.project_name),
|
||||
('project', self.project.name),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -729,7 +716,7 @@ class TestProjectSet(TestProject):
|
||||
'fo': 'fum',
|
||||
}
|
||||
self.projects_mock.update.assert_called_with(
|
||||
identity_fakes.project_id,
|
||||
self.project.id,
|
||||
**kwargs
|
||||
)
|
||||
self.assertIsNone(result)
|
||||
@ -737,14 +724,14 @@ class TestProjectSet(TestProject):
|
||||
|
||||
class TestProjectShow(TestProject):
|
||||
|
||||
domain = identity_fakes.FakeDomain.create_one_domain()
|
||||
|
||||
def setUp(self):
|
||||
super(TestProjectShow, self).setUp()
|
||||
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
copy.deepcopy(identity_fakes.PROJECT),
|
||||
loaded=True,
|
||||
)
|
||||
self.project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={'domain_id': self.domain.id})
|
||||
self.projects_mock.get.return_value = self.project
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = project.ShowProject(self.app, None)
|
||||
@ -753,10 +740,10 @@ class TestProjectShow(TestProject):
|
||||
def test_project_show(self):
|
||||
|
||||
arglist = [
|
||||
identity_fakes.project_id,
|
||||
self.project.id,
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_id),
|
||||
('project', self.project.id),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
@ -775,38 +762,48 @@ 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.project.id,
|
||||
parents_as_list=False,
|
||||
subtree_as_list=False,
|
||||
)
|
||||
|
||||
collist = ('description', 'domain_id', 'enabled', 'id', 'name')
|
||||
collist = (
|
||||
'description',
|
||||
'domain_id',
|
||||
'enabled',
|
||||
'id',
|
||||
'is_domain',
|
||||
'name',
|
||||
'parent_id',
|
||||
)
|
||||
self.assertEqual(collist, columns)
|
||||
datalist = (
|
||||
identity_fakes.project_description,
|
||||
identity_fakes.domain_id,
|
||||
self.project.description,
|
||||
self.project.domain_id,
|
||||
True,
|
||||
identity_fakes.project_id,
|
||||
identity_fakes.project_name,
|
||||
self.project.id,
|
||||
False,
|
||||
self.project.name,
|
||||
self.project.parent_id,
|
||||
)
|
||||
self.assertEqual(datalist, data)
|
||||
|
||||
@testtools.skip("skip until bug 1599333 is fixed")
|
||||
def test_project_show_parents(self):
|
||||
project = copy.deepcopy(identity_fakes.PROJECT_WITH_GRANDPARENT)
|
||||
project['parents'] = identity_fakes.grandparents
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
project,
|
||||
loaded=True,
|
||||
self.project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={
|
||||
'parent_id': self.project.parent_id,
|
||||
'parents': [{'project': {'id': self.project.parent_id}}]
|
||||
}
|
||||
)
|
||||
self.projects_mock.get.return_value = self.project
|
||||
|
||||
arglist = [
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['id'],
|
||||
self.project.id,
|
||||
'--parents',
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.PROJECT_WITH_GRANDPARENT['id']),
|
||||
('project', self.project.id),
|
||||
('parents', True),
|
||||
('children', False),
|
||||
]
|
||||
@ -823,7 +820,7 @@ class TestProjectShow(TestProject):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.projects_mock.get.assert_called_with(
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['id'],
|
||||
self.project.id,
|
||||
parents_as_list=True,
|
||||
subtree_as_list=False,
|
||||
)
|
||||
@ -833,38 +830,40 @@ class TestProjectShow(TestProject):
|
||||
'domain_id',
|
||||
'enabled',
|
||||
'id',
|
||||
'is_domain',
|
||||
'name',
|
||||
'parent_id',
|
||||
'parents',
|
||||
)
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['description'],
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['domain_id'],
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['enabled'],
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['id'],
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['name'],
|
||||
identity_fakes.PROJECT_WITH_GRANDPARENT['parent_id'],
|
||||
identity_fakes.ids_for_parents_and_grandparents,
|
||||
self.project.description,
|
||||
self.project.domain_id,
|
||||
self.project.enabled,
|
||||
self.project.id,
|
||||
self.project.is_domain,
|
||||
self.project.name,
|
||||
self.project.parent_id,
|
||||
[self.project.parent_id],
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
@testtools.skip("skip until bug 1599333 is fixed")
|
||||
def test_project_show_subtree(self):
|
||||
project = copy.deepcopy(identity_fakes.PROJECT_WITH_PARENT)
|
||||
project['subtree'] = identity_fakes.children
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
project,
|
||||
loaded=True,
|
||||
self.project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={
|
||||
'parent_id': self.project.parent_id,
|
||||
'subtree': [{'project': {'id': 'children-id'}}]
|
||||
}
|
||||
)
|
||||
self.projects_mock.get.return_value = self.project
|
||||
|
||||
arglist = [
|
||||
identity_fakes.PROJECT_WITH_PARENT['id'],
|
||||
self.project.id,
|
||||
'--children',
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.PROJECT_WITH_PARENT['id']),
|
||||
('project', self.project.id),
|
||||
('parents', False),
|
||||
('children', True),
|
||||
]
|
||||
@ -881,7 +880,7 @@ class TestProjectShow(TestProject):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.projects_mock.get.assert_called_with(
|
||||
identity_fakes.PROJECT_WITH_PARENT['id'],
|
||||
self.project.id,
|
||||
parents_as_list=False,
|
||||
subtree_as_list=True,
|
||||
)
|
||||
@ -891,40 +890,42 @@ class TestProjectShow(TestProject):
|
||||
'domain_id',
|
||||
'enabled',
|
||||
'id',
|
||||
'is_domain',
|
||||
'name',
|
||||
'parent_id',
|
||||
'subtree',
|
||||
)
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.PROJECT_WITH_PARENT['description'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['domain_id'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['enabled'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['id'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['name'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['parent_id'],
|
||||
identity_fakes.ids_for_children,
|
||||
self.project.description,
|
||||
self.project.domain_id,
|
||||
self.project.enabled,
|
||||
self.project.id,
|
||||
self.project.is_domain,
|
||||
self.project.name,
|
||||
self.project.parent_id,
|
||||
['children-id'],
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
||||
@testtools.skip("skip until bug 1599333 is fixed")
|
||||
def test_project_show_parents_and_children(self):
|
||||
project = copy.deepcopy(identity_fakes.PROJECT_WITH_PARENT)
|
||||
project['subtree'] = identity_fakes.children
|
||||
project['parents'] = identity_fakes.parents
|
||||
self.projects_mock.get.return_value = fakes.FakeResource(
|
||||
None,
|
||||
project,
|
||||
loaded=True,
|
||||
self.project = identity_fakes.FakeProject.create_one_project(
|
||||
attrs={
|
||||
'parent_id': self.project.parent_id,
|
||||
'parents': [{'project': {'id': self.project.parent_id}}],
|
||||
'subtree': [{'project': {'id': 'children-id'}}]
|
||||
}
|
||||
)
|
||||
self.projects_mock.get.return_value = self.project
|
||||
|
||||
arglist = [
|
||||
identity_fakes.PROJECT_WITH_PARENT['id'],
|
||||
self.project.id,
|
||||
'--parents',
|
||||
'--children',
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.PROJECT_WITH_PARENT['id']),
|
||||
('project', self.project.id),
|
||||
('parents', True),
|
||||
('children', True),
|
||||
]
|
||||
@ -941,7 +942,7 @@ class TestProjectShow(TestProject):
|
||||
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
self.projects_mock.get.assert_called_with(
|
||||
identity_fakes.PROJECT_WITH_PARENT['id'],
|
||||
self.project.id,
|
||||
parents_as_list=True,
|
||||
subtree_as_list=True,
|
||||
)
|
||||
@ -951,6 +952,7 @@ class TestProjectShow(TestProject):
|
||||
'domain_id',
|
||||
'enabled',
|
||||
'id',
|
||||
'is_domain',
|
||||
'name',
|
||||
'parent_id',
|
||||
'parents',
|
||||
@ -958,13 +960,14 @@ class TestProjectShow(TestProject):
|
||||
)
|
||||
self.assertEqual(columns, collist)
|
||||
datalist = (
|
||||
identity_fakes.PROJECT_WITH_PARENT['description'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['domain_id'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['enabled'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['id'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['name'],
|
||||
identity_fakes.PROJECT_WITH_PARENT['parent_id'],
|
||||
identity_fakes.ids_for_parents,
|
||||
identity_fakes.ids_for_children,
|
||||
self.project.description,
|
||||
self.project.domain_id,
|
||||
self.project.enabled,
|
||||
self.project.id,
|
||||
self.project.is_domain,
|
||||
self.project.name,
|
||||
self.project.parent_id,
|
||||
[self.project.parent_id],
|
||||
['children-id'],
|
||||
)
|
||||
self.assertEqual(data, datalist)
|
||||
|
Loading…
Reference in New Issue
Block a user