diff options
| author | melanie witt <melwittt@gmail.com> | 2021-08-12 22:06:36 +0000 |
|---|---|---|
| committer | melanie witt <melwittt@gmail.com> | 2021-08-17 01:34:05 +0000 |
| commit | 12c93c6d5ff420f6a4a8833d33bad6ee7222e2f7 (patch) | |
| tree | 8d4dd42937ce8cf957470f02d0f2ec8030141c0c /openstackclient/tests/unit/compute | |
| parent | ed87f7949ef1ef580ed71b9820e16823c0466472 (diff) | |
| download | python-openstackclient-12c93c6d5ff420f6a4a8833d33bad6ee7222e2f7.tar.gz | |
Show "Forced Down" compute service status with --long
Currently, the unified client does not have the ability to show the
"Forced Down" field of a GET /os-services response in microversion 2.11
even though the legacy client can.
This adds a "Forced Down" column to the 'openstack compute service list
--long' command output when microversion 2.11 is used.
Story: 2009115
Task: 43011
Change-Id: I10bc2fedbf0e867a990227962b2b6e60f5681f69
Diffstat (limited to 'openstackclient/tests/unit/compute')
| -rw-r--r-- | openstackclient/tests/unit/compute/v2/fakes.py | 2 | ||||
| -rw-r--r-- | openstackclient/tests/unit/compute/v2/test_service.py | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/compute/v2/fakes.py b/openstackclient/tests/unit/compute/v2/fakes.py index 47457acb..05a14e16 100644 --- a/openstackclient/tests/unit/compute/v2/fakes.py +++ b/openstackclient/tests/unit/compute/v2/fakes.py @@ -722,6 +722,8 @@ class FakeService(object): 'state': 'state-' + uuid.uuid4().hex, 'updated_at': 'time-' + uuid.uuid4().hex, 'disabled_reason': 'earthquake', + # Introduced in API microversion 2.11 + 'forced_down': False, } # Overwrite default attributes. diff --git a/openstackclient/tests/unit/compute/v2/test_service.py b/openstackclient/tests/unit/compute/v2/test_service.py index 87e54747..c547c3a6 100644 --- a/openstackclient/tests/unit/compute/v2/test_service.py +++ b/openstackclient/tests/unit/compute/v2/test_service.py @@ -190,6 +190,38 @@ class TestServiceList(TestService): self.assertEqual(self.columns_long, columns) self.assertEqual(self.data_long, list(data)) + def test_service_list_with_long_option_2_11(self): + arglist = [ + '--host', self.service.host, + '--service', self.service.binary, + '--long' + ] + verifylist = [ + ('host', self.service.host), + ('service', self.service.binary), + ('long', True) + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + self.app.client_manager.compute.api_version = api_versions.APIVersion( + '2.11') + + # In base command class Lister in cliff, abstract method take_action() + # returns a tuple containing the column names and an iterable + # containing the data to be listed. + columns, data = self.cmd.take_action(parsed_args) + + self.service_mock.list.assert_called_with( + self.service.host, + self.service.binary, + ) + + # In 2.11 there is also a forced_down column. + columns_long = self.columns_long + ('Forced Down',) + data_long = [self.data_long[0] + (self.service.forced_down,)] + + self.assertEqual(columns_long, columns) + self.assertEqual(data_long, list(data)) + class TestServiceSet(TestService): |
