diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-08-04 15:46:50 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-08-04 19:30:02 +0800 |
| commit | f58be9d4ddc4d395e209015e8735f6cb4258a566 (patch) | |
| tree | 9126c054abc8a21d1da802cfd30c313aa91f9f2c /openstackclient/tests/identity/v3/fakes.py | |
| parent | 06ea24725b1331fcf840a64f558e2d1f15a3c8c6 (diff) | |
| download | python-openstackclient-f58be9d4ddc4d395e209015e8735f6cb4258a566.tar.gz | |
Add unit tests for group commands in identity v3
Add unit tests for commands below in identity v3:
group create
group delete
group show
group set
group add user
group remove user
group contains user
Change-Id: I02f3b49e93582245a2749492bba1dfc4c5e0258d
Diffstat (limited to 'openstackclient/tests/identity/v3/fakes.py')
| -rw-r--r-- | openstackclient/tests/identity/v3/fakes.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/openstackclient/tests/identity/v3/fakes.py b/openstackclient/tests/identity/v3/fakes.py index 50e901c9..8c138f7b 100644 --- a/openstackclient/tests/identity/v3/fakes.py +++ b/openstackclient/tests/identity/v3/fakes.py @@ -769,6 +769,44 @@ class FakeGroup(object): loaded=True) return group + @staticmethod + def create_groups(attrs=None, count=2): + """Create multiple fake groups. + + :param Dictionary attrs: + A dictionary with all attributes + :param int count: + The number of groups to fake + :return: + A list of FakeResource objects faking the groups + """ + groups = [] + for i in range(0, count): + group = FakeGroup.create_one_group(attrs) + groups.append(group) + + return groups + + @staticmethod + def get_groups(groups=None, count=2): + """Get an iterable MagicMock object with a list of faked groups. + + If groups list is provided, then initialize the Mock object with + the list. Otherwise create one. + + :param List groups: + A list of FakeResource objects faking groups + :param Integer count: + The number of groups to be faked + :return + An iterable Mock object with side_effect set to a list of faked + groups + """ + if groups is None: + groups = FakeGroup.create_groups(count) + + return mock.MagicMock(side_effect=groups) + class FakeEndpoint(object): """Fake one or more endpoint.""" |
