Merge "Add parent project filter for listing projects"
This commit is contained in:
commit
4e812b673b
|
@ -157,6 +157,30 @@ class ProjectsTestCase(base.V3ClientTestCase, ProjectsTestMixin):
|
|||
self.assertIn(project_one.entity, projects)
|
||||
self.assertIn(project_two.entity, projects)
|
||||
|
||||
def test_list_subprojects(self):
|
||||
parent_project = fixtures.Project(self.client, self.test_domain.id)
|
||||
self.useFixture(parent_project)
|
||||
|
||||
child_project_one = fixtures.Project(self.client, self.test_domain.id,
|
||||
parent=parent_project.id)
|
||||
self.useFixture(child_project_one)
|
||||
|
||||
child_project_two = fixtures.Project(self.client, self.test_domain.id,
|
||||
parent=parent_project.id)
|
||||
self.useFixture(child_project_two)
|
||||
|
||||
projects = self.client.projects.list(parent=parent_project.id)
|
||||
|
||||
# All projects are valid
|
||||
for project in projects:
|
||||
self.check_project(project)
|
||||
|
||||
self.assertIn(child_project_one.entity, projects)
|
||||
self.assertIn(child_project_two.entity, projects)
|
||||
|
||||
# Parent project should not be included in the result
|
||||
self.assertNotIn(parent_project.entity, projects)
|
||||
|
||||
def test_update_project(self):
|
||||
project = fixtures.Project(self.client, self.test_domain.id)
|
||||
self.useFixture(project)
|
||||
|
|
|
@ -55,8 +55,7 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
|
|||
ref_list = [self.new_ref(), self.new_ref()]
|
||||
domain_id = uuid.uuid4().hex
|
||||
|
||||
self.stub_entity('GET', [self.collection_key],
|
||||
entity=ref_list)
|
||||
self.stub_entity('GET', [self.collection_key], entity=ref_list)
|
||||
|
||||
returned_list = self.manager.list(domain=domain_id)
|
||||
self.assertEqual(len(ref_list), len(returned_list))
|
||||
|
@ -64,6 +63,18 @@ class ProjectTests(utils.ClientTestCase, utils.CrudTests):
|
|||
|
||||
self.assertQueryStringIs('domain_id=%s' % domain_id)
|
||||
|
||||
def test_list_projects_for_parent(self):
|
||||
ref_list = [self.new_ref(), self.new_ref()]
|
||||
parent_id = uuid.uuid4().hex
|
||||
|
||||
self.stub_entity('GET', [self.collection_key], entity=ref_list)
|
||||
|
||||
returned_list = self.manager.list(parent=parent_id)
|
||||
self.assertEqual(len(ref_list), len(returned_list))
|
||||
[self.assertIsInstance(r, self.model) for r in returned_list]
|
||||
|
||||
self.assertQueryStringIs('parent_id=%s' % parent_id)
|
||||
|
||||
def test_create_with_parent(self):
|
||||
parent_ref = self.new_ref()
|
||||
parent_ref['parent_id'] = uuid.uuid4().hex
|
||||
|
|
|
@ -112,7 +112,7 @@ class ProjectManager(base.CrudManager):
|
|||
enabled=enabled,
|
||||
**kwargs)
|
||||
|
||||
def list(self, domain=None, user=None, **kwargs):
|
||||
def list(self, domain=None, user=None, parent=None, **kwargs):
|
||||
"""List projects.
|
||||
|
||||
:param domain: the domain of the projects to be filtered on.
|
||||
|
@ -120,6 +120,9 @@ class ProjectManager(base.CrudManager):
|
|||
:param user: filter in projects the specified user has role
|
||||
assignments on.
|
||||
:type user: str or :class:`keystoneclient.v3.users.User`
|
||||
:param parent: filter in projects the specified project is a parent
|
||||
for
|
||||
:type parent: str or :class:`keystoneclient.v3.projects.Project`
|
||||
:param kwargs: any other attribute provided will filter projects on.
|
||||
Project tags filter keyword: ``tags``, ``tags_any``,
|
||||
``not_tags``, and ``not_tags_any``. tag attribute type
|
||||
|
@ -134,6 +137,7 @@ class ProjectManager(base.CrudManager):
|
|||
projects = super(ProjectManager, self).list(
|
||||
base_url=base_url,
|
||||
domain_id=base.getid(domain),
|
||||
parent_id=base.getid(parent),
|
||||
fallback_to_auth=True,
|
||||
**kwargs)
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Now keystone client supports to list projects which belongs to the given
|
||||
parent project.
|
Loading…
Reference in New Issue