summaryrefslogtreecommitdiff
path: root/keystoneclient/tests
diff options
context:
space:
mode:
authorTakashi Kajinami <tkajinam@redhat.com>2019-08-19 10:42:42 +0900
committerTakashi Kajinami <tkajinam@redhat.com>2019-08-29 16:50:26 +0900
commit2d3ec6eb89574d442c357b2b8231367ba1ac24f6 (patch)
treef1f86f8f1a1a3571d062c07be350e17e2f01491f /keystoneclient/tests
parentf7e75f43d811c8e1028746b2574322afa53dbaac (diff)
downloadpython-keystoneclient-2d3ec6eb89574d442c357b2b8231367ba1ac24f6.tar.gz
Add parent project filter for listing projects
This patch introduces the interface into listing project, to specify parent_id to filter projects which has the given project as their parent[1]. [1] https://docs.openstack.org/api-ref/identity/v3/?expanded=list-projects-detail#list-projects Change-Id: If78030425468d4f99cba708540142871a2bf9190
Diffstat (limited to 'keystoneclient/tests')
-rw-r--r--keystoneclient/tests/functional/v3/test_projects.py24
-rw-r--r--keystoneclient/tests/unit/v3/test_projects.py15
2 files changed, 37 insertions, 2 deletions
diff --git a/keystoneclient/tests/functional/v3/test_projects.py b/keystoneclient/tests/functional/v3/test_projects.py
index c40da50..eec2745 100644
--- a/keystoneclient/tests/functional/v3/test_projects.py
+++ b/keystoneclient/tests/functional/v3/test_projects.py
@@ -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)
diff --git a/keystoneclient/tests/unit/v3/test_projects.py b/keystoneclient/tests/unit/v3/test_projects.py
index 2df8f05..99186f1 100644
--- a/keystoneclient/tests/unit/v3/test_projects.py
+++ b/keystoneclient/tests/unit/v3/test_projects.py
@@ -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