diff options
| author | Lewis Denny <ldenny@redhat.com> | 2020-08-20 20:18:42 +1000 |
|---|---|---|
| committer | Lewis Denny <ldenny@redhat.com> | 2020-08-21 14:57:29 +1000 |
| commit | ed6d8d941104c60f447de852582eb9388b9d2e73 (patch) | |
| tree | 4d36662dbb7ae418d31f0bc5c9b0439b4477af64 /openstackclient/tests/unit/compute/v2/fakes.py | |
| parent | 95cc05bdf6f62f14970a722d09010c4195951671 (diff) | |
| download | python-openstackclient-ed6d8d941104c60f447de852582eb9388b9d2e73.tar.gz | |
Add API check for server_groups.list
The policies parameter has been replaced with the
policy parameter since Nova API version 2.64[1]
This commit adds a check to make sure the correct parameter is used.
[1]https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id59
Change-Id: Ia37beb7790884d6d15bec45074f446e64af1a2aa
Story: #2008041
Task: #40703
Diffstat (limited to 'openstackclient/tests/unit/compute/v2/fakes.py')
| -rw-r--r-- | openstackclient/tests/unit/compute/v2/fakes.py | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/openstackclient/tests/unit/compute/v2/fakes.py b/openstackclient/tests/unit/compute/v2/fakes.py index 6e12f735..31430984 100644 --- a/openstackclient/tests/unit/compute/v2/fakes.py +++ b/openstackclient/tests/unit/compute/v2/fakes.py @@ -1244,7 +1244,7 @@ class FakeServerGroup(object): """Fake one server group""" @staticmethod - def create_one_server_group(attrs=None): + def _create_one_server_group(attrs=None): """Create a fake server group :param Dictionary attrs: @@ -1261,7 +1261,6 @@ class FakeServerGroup(object): 'members': [], 'metadata': {}, 'name': 'server-group-name-' + uuid.uuid4().hex, - 'policies': [], 'project_id': 'server-group-project-id-' + uuid.uuid4().hex, 'user_id': 'server-group-user-id-' + uuid.uuid4().hex, } @@ -1274,6 +1273,38 @@ class FakeServerGroup(object): loaded=True) return server_group + @staticmethod + def create_one_server_group(attrs=None): + """Create a fake server group + + :param Dictionary attrs: + A dictionary with all attributes + :return: + A FakeResource object, with id and other attributes + """ + if attrs is None: + attrs = {} + attrs.setdefault('policies', ['policy1', 'policy2']) + return FakeServerGroup._create_one_server_group(attrs) + + +class FakeServerGroupV264(object): + """Fake one server group fo API >= 2.64""" + + @staticmethod + def create_one_server_group(attrs=None): + """Create a fake server group + + :param Dictionary attrs: + A dictionary with all attributes + :return: + A FakeResource object, with id and other attributes + """ + if attrs is None: + attrs = {} + attrs.setdefault('policy', 'policy1') + return FakeServerGroup._create_one_server_group(attrs) + class FakeUsage(object): """Fake one or more usage.""" |
