diff options
| author | Stephen Finucane <sfinucan@redhat.com> | 2022-11-07 17:02:58 +0000 |
|---|---|---|
| committer | Stephen Finucane <sfinucan@redhat.com> | 2022-11-08 16:39:02 +0000 |
| commit | a244bb84e07617dad12dee91bbe63bdca3357b1e (patch) | |
| tree | da091e53cf870e8347546117d0b996b1fca595c8 /openstackclient/tests/functional/common | |
| parent | 681934a96aa8e35ae3babc89bfb2b56d2daea950 (diff) | |
| download | python-openstackclient-a244bb84e07617dad12dee91bbe63bdca3357b1e.tar.gz | |
tests: Move json decoding to base test class
We do this everywhere. Add a simple knob to simplify the pattern. Only
one use is migrated initially. The rest will be done separately.
Change-Id: Ic3b8958bd4fb1459a8ac3adaff216c2a26628491
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
Diffstat (limited to 'openstackclient/tests/functional/common')
| -rw-r--r-- | openstackclient/tests/functional/common/test_module.py | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/openstackclient/tests/functional/common/test_module.py b/openstackclient/tests/functional/common/test_module.py index 41aabb7f..967d3b49 100644 --- a/openstackclient/tests/functional/common/test_module.py +++ b/openstackclient/tests/functional/common/test_module.py @@ -11,9 +11,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# - -import json from openstackclient.tests.functional import base @@ -31,14 +28,14 @@ class ModuleTest(base.TestCase): def test_module_list(self): # Test module list - cmd_output = json.loads(self.openstack('module list -f json')) + cmd_output = self.openstack('module list', parse_output=True) for one_module in self.CLIENTS: self.assertIn(one_module, cmd_output.keys()) for one_module in self.LIBS: self.assertNotIn(one_module, cmd_output.keys()) # Test module list --all - cmd_output = json.loads(self.openstack('module list --all -f json')) + cmd_output = self.openstack('module list --all', parse_output=True) for one_module in self.CLIENTS + self.LIBS: self.assertIn(one_module, cmd_output.keys()) @@ -56,7 +53,7 @@ class CommandTest(base.TestCase): ] def test_command_list_no_option(self): - cmd_output = json.loads(self.openstack('command list -f json')) + cmd_output = self.openstack('command list', parse_output=True) group_names = [each.get('Command Group') for each in cmd_output] for one_group in self.GROUPS: self.assertIn(one_group, group_names) @@ -70,9 +67,10 @@ class CommandTest(base.TestCase): 'compute.v2' ] for each_input in input_groups: - cmd_output = json.loads(self.openstack( - 'command list --group %s -f json' % each_input - )) + cmd_output = self.openstack( + 'command list --group %s' % each_input, + parse_output=True, + ) group_names = [each.get('Command Group') for each in cmd_output] for each_name in group_names: self.assertIn(each_input, each_name) |
