summaryrefslogtreecommitdiff
path: root/keystoneclient/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-03-18 03:59:43 +0000
committerGerrit Code Review <review@openstack.org>2015-03-18 03:59:43 +0000
commitcfad7da20e189b691cdc85cb3b18ccd7a004d9c8 (patch)
tree0489db95966d1d085e2623f48eaf4befa5c2a42f /keystoneclient/tests
parentfc1f5a7963adb3c39f48131af5117bfafa3b07e7 (diff)
parent14ace4a5ded0bd4005928b42a4f337639bd90799 (diff)
downloadpython-keystoneclient-cfad7da20e189b691cdc85cb3b18ccd7a004d9c8.tar.gz
Merge "Implements subtree_as_ids and parents_as_ids"
Diffstat (limited to 'keystoneclient/tests')
-rw-r--r--keystoneclient/tests/unit/v3/test_projects.py86
1 files changed, 86 insertions, 0 deletions
diff --git a/keystoneclient/tests/unit/v3/test_projects.py b/keystoneclient/tests/unit/v3/test_projects.py
index 5d08bb2..61a5ef1 100644
--- a/keystoneclient/tests/unit/v3/test_projects.py
+++ b/keystoneclient/tests/unit/v3/test_projects.py
@@ -144,6 +144,75 @@ class ProjectTests(utils.TestCase, utils.CrudTests):
return projects
+ def test_get_with_subtree_as_ids(self):
+ projects = self._create_projects_hierarchy()
+ ref = projects[0]
+
+ # We will query for projects[0] subtree, it should include projects[1]
+ # and projects[2] structured like the following:
+ # {
+ # projects[1]: {
+ # projects[2]: None
+ # }
+ # }
+ ref['subtree'] = {
+ projects[1]['id']: {
+ projects[2]['id']: None
+ }
+ }
+
+ self.stub_entity('GET', id=ref['id'], entity=ref)
+
+ returned = self.manager.get(ref['id'], subtree_as_ids=True)
+ self.assertQueryStringIs('subtree_as_ids')
+ self.assertDictEqual(ref['subtree'], returned.subtree)
+
+ def test_get_with_parents_as_ids(self):
+ projects = self._create_projects_hierarchy()
+ ref = projects[2]
+
+ # We will query for projects[2] parents, it should include projects[1]
+ # and projects[0] structured like the following:
+ # {
+ # projects[1]: {
+ # projects[0]: None
+ # }
+ # }
+ ref['parents'] = {
+ projects[1]['id']: {
+ projects[0]['id']: None
+ }
+ }
+
+ self.stub_entity('GET', id=ref['id'], entity=ref)
+
+ returned = self.manager.get(ref['id'], parents_as_ids=True)
+ self.assertQueryStringIs('parents_as_ids')
+ self.assertDictEqual(ref['parents'], returned.parents)
+
+ def test_get_with_parents_as_ids_and_subtree_as_ids(self):
+ ref = self.new_ref()
+ projects = self._create_projects_hierarchy()
+ ref = projects[1]
+
+ # We will query for projects[1] subtree and parents. The subtree should
+ # include projects[2] and the parents should include projects[2].
+ ref['parents'] = {
+ projects[0]['id']: None
+ }
+ ref['subtree'] = {
+ projects[2]['id']: None
+ }
+
+ self.stub_entity('GET', id=ref['id'], entity=ref)
+
+ returned = self.manager.get(ref['id'],
+ parents_as_ids=True,
+ subtree_as_ids=True)
+ self.assertQueryStringIs('subtree_as_ids&parents_as_ids')
+ self.assertDictEqual(ref['parents'], returned.parents)
+ self.assertDictEqual(ref['subtree'], returned.subtree)
+
def test_get_with_subtree_as_list(self):
projects = self._create_projects_hierarchy()
ref = projects[0]
@@ -213,6 +282,23 @@ class ProjectTests(utils.TestCase, utils.CrudTests):
projects[2][attr],
'Expected different %s' % attr)
+ def test_get_with_invalid_parameters_combination(self):
+ # subtree_as_list and subtree_as_ids can not be included at the
+ # same time in the call.
+ self.assertRaises(exceptions.ValidationError,
+ self.manager.get,
+ project=uuid.uuid4().hex,
+ subtree_as_list=True,
+ subtree_as_ids=True)
+
+ # parents_as_list and parents_as_ids can not be included at the
+ # same time in the call.
+ self.assertRaises(exceptions.ValidationError,
+ self.manager.get,
+ project=uuid.uuid4().hex,
+ parents_as_list=True,
+ parents_as_ids=True)
+
def test_update_with_parent_project(self):
ref = self.new_ref()
ref['parent_id'] = uuid.uuid4().hex