Merge "Fix --parents and --children options in project show"
This commit is contained in:
commit
1c76c70d71
@ -336,13 +336,18 @@ class ShowProject(command.ShowOne):
|
|||||||
project = utils.find_resource(
|
project = utils.find_resource(
|
||||||
identity_client.projects,
|
identity_client.projects,
|
||||||
project_str,
|
project_str,
|
||||||
domain_id=domain.id,
|
domain_id=domain.id)
|
||||||
parents_as_list=parsed_args.parents,
|
|
||||||
subtree_as_list=parsed_args.children)
|
|
||||||
else:
|
else:
|
||||||
project = utils.find_resource(
|
project = utils.find_resource(
|
||||||
identity_client.projects,
|
identity_client.projects,
|
||||||
project_str,
|
project_str)
|
||||||
|
|
||||||
|
if parsed_args.parents or parsed_args.children:
|
||||||
|
# NOTE(RuiChen): utils.find_resource() can't pass kwargs,
|
||||||
|
# if id query hit the result at first, so call
|
||||||
|
# identity manager.get() with kwargs directly.
|
||||||
|
project = identity_client.projects.get(
|
||||||
|
project.id,
|
||||||
parents_as_list=parsed_args.parents,
|
parents_as_list=parsed_args.parents,
|
||||||
subtree_as_list=parsed_args.children)
|
subtree_as_list=parsed_args.children)
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
from tempest.lib.common.utils import data_utils
|
from tempest.lib.common.utils import data_utils
|
||||||
|
|
||||||
from openstackclient.tests.functional.identity.v3 import common
|
from openstackclient.tests.functional.identity.v3 import common
|
||||||
@ -111,3 +113,14 @@ class ProjectTests(common.IdentityTests):
|
|||||||
'name': self.project_name})
|
'name': self.project_name})
|
||||||
items = self.parse_show(raw_output)
|
items = self.parse_show(raw_output)
|
||||||
self.assert_show_fields(items, self.PROJECT_FIELDS)
|
self.assert_show_fields(items, self.PROJECT_FIELDS)
|
||||||
|
|
||||||
|
def test_project_show_with_parents_children(self):
|
||||||
|
json_output = json.loads(self.openstack(
|
||||||
|
'project show '
|
||||||
|
'--parents --children -f json '
|
||||||
|
'--domain %(domain)s '
|
||||||
|
'%(name)s' % {'domain': self.domain_name,
|
||||||
|
'name': self.project_name}))
|
||||||
|
for attr_name in (self.PROJECT_FIELDS + ['parents', 'subtree']):
|
||||||
|
self.assertIn(attr_name, json_output)
|
||||||
|
self.assertEqual(self.project_name, json_output.get('name'))
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from mock import call
|
||||||
|
|
||||||
from osc_lib import exceptions
|
from osc_lib import exceptions
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
@ -763,8 +764,6 @@ class TestProjectShow(TestProject):
|
|||||||
|
|
||||||
def test_project_show(self):
|
def test_project_show(self):
|
||||||
|
|
||||||
self.projects_mock.get.side_effect = [Exception("Not found"),
|
|
||||||
self.project]
|
|
||||||
self.projects_mock.get.return_value = self.project
|
self.projects_mock.get.return_value = self.project
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
@ -790,11 +789,7 @@ class TestProjectShow(TestProject):
|
|||||||
# data to be shown.
|
# data to be shown.
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.projects_mock.get.assert_called_with(
|
self.projects_mock.get.assert_called_once_with(self.project.id)
|
||||||
self.project.id,
|
|
||||||
parents_as_list=False,
|
|
||||||
subtree_as_list=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
collist = (
|
collist = (
|
||||||
'description',
|
'description',
|
||||||
@ -824,8 +819,6 @@ class TestProjectShow(TestProject):
|
|||||||
'parents': [{'project': {'id': self.project.parent_id}}]
|
'parents': [{'project': {'id': self.project.parent_id}}]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.projects_mock.get.side_effect = [Exception("Not found"),
|
|
||||||
self.project]
|
|
||||||
self.projects_mock.get.return_value = self.project
|
self.projects_mock.get.return_value = self.project
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
@ -849,11 +842,12 @@ class TestProjectShow(TestProject):
|
|||||||
}
|
}
|
||||||
|
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
self.projects_mock.get.assert_called_with(
|
|
||||||
self.project.id,
|
self.projects_mock.get.assert_has_calls([call(self.project.id),
|
||||||
parents_as_list=True,
|
call(self.project.id,
|
||||||
subtree_as_list=False,
|
parents_as_list=True,
|
||||||
)
|
subtree_as_list=False,
|
||||||
|
)])
|
||||||
|
|
||||||
collist = (
|
collist = (
|
||||||
'description',
|
'description',
|
||||||
@ -885,8 +879,6 @@ class TestProjectShow(TestProject):
|
|||||||
'subtree': [{'project': {'id': 'children-id'}}]
|
'subtree': [{'project': {'id': 'children-id'}}]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.projects_mock.get.side_effect = [Exception("Not found"),
|
|
||||||
self.project]
|
|
||||||
self.projects_mock.get.return_value = self.project
|
self.projects_mock.get.return_value = self.project
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
@ -910,11 +902,11 @@ class TestProjectShow(TestProject):
|
|||||||
}
|
}
|
||||||
|
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
self.projects_mock.get.assert_called_with(
|
self.projects_mock.get.assert_has_calls([call(self.project.id),
|
||||||
self.project.id,
|
call(self.project.id,
|
||||||
parents_as_list=False,
|
parents_as_list=False,
|
||||||
subtree_as_list=True,
|
subtree_as_list=True,
|
||||||
)
|
)])
|
||||||
|
|
||||||
collist = (
|
collist = (
|
||||||
'description',
|
'description',
|
||||||
@ -947,8 +939,6 @@ class TestProjectShow(TestProject):
|
|||||||
'subtree': [{'project': {'id': 'children-id'}}]
|
'subtree': [{'project': {'id': 'children-id'}}]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
self.projects_mock.get.side_effect = [Exception("Not found"),
|
|
||||||
self.project]
|
|
||||||
self.projects_mock.get.return_value = self.project
|
self.projects_mock.get.return_value = self.project
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
@ -973,11 +963,11 @@ class TestProjectShow(TestProject):
|
|||||||
}
|
}
|
||||||
|
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
self.projects_mock.get.assert_called_with(
|
self.projects_mock.get.assert_has_calls([call(self.project.id),
|
||||||
self.project.id,
|
call(self.project.id,
|
||||||
parents_as_list=True,
|
parents_as_list=True,
|
||||||
subtree_as_list=True,
|
subtree_as_list=True,
|
||||||
)
|
)])
|
||||||
|
|
||||||
collist = (
|
collist = (
|
||||||
'description',
|
'description',
|
||||||
|
6
releasenotes/notes/bug-1499657-eeb260849febacf3.yaml
Normal file
6
releasenotes/notes/bug-1499657-eeb260849febacf3.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Options ``--parents`` and ``--children`` don't work in ``project show``
|
||||||
|
command, fix the issue.
|
||||||
|
[Bug `1499657 <https://bugs.launchpad.net/python-openstackclient/+bug/1499657>`_]
|
Loading…
x
Reference in New Issue
Block a user