summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit/identity/v3/fakes.py
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2017-03-17 13:28:49 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2017-03-21 10:39:42 +0800
commitef5a7caf85bd6169701371da67029457abdaf47f (patch)
tree7dcb3234daf13a0f9bb8f45c7e3e82f3408c17d9 /openstackclient/tests/unit/identity/v3/fakes.py
parent49e866174f2e24ce996cdb588c38b5b08daed5a0 (diff)
downloadpython-openstackclient-ef5a7caf85bd6169701371da67029457abdaf47f.tar.gz
Support to add/remove multi users for "group add/remove user"
Similar delete commands in OSC, we can also support add/remove multi users for one specified group, this review implement it. Change-Id: I8ccf99d4ee83a18778fa3ff5c0a42bc7c6ff21fb Implements: bp support-multi-add-remove
Diffstat (limited to 'openstackclient/tests/unit/identity/v3/fakes.py')
-rw-r--r--openstackclient/tests/unit/identity/v3/fakes.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/identity/v3/fakes.py b/openstackclient/tests/unit/identity/v3/fakes.py
index 01b5dede..139d90d5 100644
--- a/openstackclient/tests/unit/identity/v3/fakes.py
+++ b/openstackclient/tests/unit/identity/v3/fakes.py
@@ -770,6 +770,44 @@ class FakeUser(object):
loaded=True)
return user
+ @staticmethod
+ def create_users(attrs=None, count=2):
+ """Create multiple fake users.
+
+ :param Dictionary attrs:
+ A dictionary with all attributes
+ :param int count:
+ The number of users to fake
+ :return:
+ A list of FakeResource objects faking the users
+ """
+ users = []
+ for i in range(0, count):
+ user = FakeUser.create_one_user(attrs)
+ users.append(user)
+
+ return users
+
+ @staticmethod
+ def get_users(users=None, count=2):
+ """Get an iterable MagicMock object with a list of faked users.
+
+ If users list is provided, then initialize the Mock object with
+ the list. Otherwise create one.
+
+ :param List users:
+ A list of FakeResource objects faking users
+ :param Integer count:
+ The number of users to be faked
+ :return
+ An iterable Mock object with side_effect set to a list of faked
+ users
+ """
+ if users is None:
+ users = FakeUser.create_users(count)
+
+ return mock.Mock(side_effect=users)
+
class FakeGroup(object):
"""Fake one or more group."""