Merge "tests: Convert more functional tests to use 'parse_output'"
This commit is contained in:
commit
50015b9608
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from tempest.lib import exceptions as tempest_exc
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
@ -21,10 +19,11 @@ class ArgumentTests(base.TestCase):
|
||||
"""Functional tests for command line arguments"""
|
||||
|
||||
def test_default_auth_type(self):
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'configuration show -f json',
|
||||
cmd_output = self.openstack(
|
||||
'configuration show',
|
||||
cloud='',
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertIn(
|
||||
'auth_type',
|
||||
@ -36,10 +35,11 @@ class ArgumentTests(base.TestCase):
|
||||
)
|
||||
|
||||
def test_auth_type_none(self):
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'configuration show -f json',
|
||||
cmd_output = self.openstack(
|
||||
'configuration show',
|
||||
cloud=None,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertIn(
|
||||
'auth_type',
|
||||
@ -54,7 +54,7 @@ class ArgumentTests(base.TestCase):
|
||||
# Make sure token_endpoint is really gone
|
||||
try:
|
||||
self.openstack(
|
||||
'configuration show -f json --os-auth-type token_endpoint',
|
||||
'configuration show --os-auth-type token_endpoint',
|
||||
cloud=None,
|
||||
)
|
||||
except tempest_exc.CommandFailed as e:
|
||||
@ -64,10 +64,11 @@ class ArgumentTests(base.TestCase):
|
||||
self.fail('CommandFailed should be raised')
|
||||
|
||||
def test_auth_type_password_opt(self):
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'configuration show -f json --os-auth-type password',
|
||||
cmd_output = self.openstack(
|
||||
'configuration show --os-auth-type password',
|
||||
cloud=None,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertIn(
|
||||
'auth_type',
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
|
||||
|
||||
@ -19,8 +17,10 @@ class AvailabilityZoneTests(base.TestCase):
|
||||
"""Functional tests for availability zone. """
|
||||
|
||||
def test_availability_zone_list(self):
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'availability zone list -f json'))
|
||||
cmd_output = self.openstack(
|
||||
'availability zone list',
|
||||
parse_output=True,
|
||||
)
|
||||
zones = [x['Zone Name'] for x in cmd_output]
|
||||
self.assertIn(
|
||||
'internal',
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from openstackclient.common import configuration
|
||||
@ -30,9 +29,7 @@ class ConfigurationTests(base.TestCase):
|
||||
items = self.parse_listing(raw_output)
|
||||
self.assert_table_structure(items, BASIC_CONFIG_HEADERS)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'configuration show -f json'
|
||||
))
|
||||
cmd_output = self.openstack('configuration show', parse_output=True)
|
||||
self.assertEqual(
|
||||
configuration.REDACTED,
|
||||
cmd_output['auth.password']
|
||||
@ -43,18 +40,18 @@ class ConfigurationTests(base.TestCase):
|
||||
)
|
||||
|
||||
# Test show --mask
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'configuration show --mask -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'configuration show --mask', parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
configuration.REDACTED,
|
||||
cmd_output['auth.password']
|
||||
)
|
||||
|
||||
# Test show --unmask
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'configuration show --unmask -f json'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'configuration show --unmask', parse_output=True,
|
||||
)
|
||||
# If we are using os-client-config, this will not be set. Rather than
|
||||
# parse clouds.yaml to get the right value, just make sure
|
||||
# we are not getting redacted.
|
||||
@ -84,10 +81,11 @@ class ConfigurationTestsNoAuth(base.TestCase):
|
||||
items = self.parse_listing(raw_output)
|
||||
self.assert_table_structure(items, BASIC_CONFIG_HEADERS)
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'configuration show -f json',
|
||||
cmd_output = self.openstack(
|
||||
'configuration show',
|
||||
cloud=None,
|
||||
))
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertNotIn(
|
||||
'auth.password',
|
||||
cmd_output,
|
||||
|
@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from tempest.lib import exceptions as tempest_exc
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
@ -30,11 +28,11 @@ class ExtensionTests(base.TestCase):
|
||||
|
||||
def test_extension_list_compute(self):
|
||||
"""Test compute extension list"""
|
||||
json_output = json.loads(self.openstack(
|
||||
'extension list -f json ' +
|
||||
'--compute'
|
||||
))
|
||||
name_list = [item.get('Name') for item in json_output]
|
||||
output = self.openstack(
|
||||
'extension list --compute',
|
||||
parse_output=True,
|
||||
)
|
||||
name_list = [item.get('Name') for item in output]
|
||||
self.assertIn(
|
||||
'ImageSize',
|
||||
name_list,
|
||||
@ -42,11 +40,11 @@ class ExtensionTests(base.TestCase):
|
||||
|
||||
def test_extension_list_volume(self):
|
||||
"""Test volume extension list"""
|
||||
json_output = json.loads(self.openstack(
|
||||
'extension list -f json ' +
|
||||
'--volume'
|
||||
))
|
||||
name_list = [item.get('Name') for item in json_output]
|
||||
output = self.openstack(
|
||||
'extension list --volume',
|
||||
parse_output=True,
|
||||
)
|
||||
name_list = [item.get('Name') for item in output]
|
||||
self.assertIn(
|
||||
'TypesManage',
|
||||
name_list,
|
||||
@ -57,43 +55,29 @@ class ExtensionTests(base.TestCase):
|
||||
if not self.haz_network:
|
||||
self.skipTest("No Network service present")
|
||||
|
||||
json_output = json.loads(self.openstack(
|
||||
'extension list -f json ' +
|
||||
'--network'
|
||||
))
|
||||
name_list = [item.get('Name') for item in json_output]
|
||||
output = self.openstack(
|
||||
'extension list --network',
|
||||
parse_output=True,
|
||||
)
|
||||
name_list = [item.get('Name') for item in output]
|
||||
self.assertIn(
|
||||
'Default Subnetpools',
|
||||
name_list,
|
||||
)
|
||||
|
||||
# NOTE(dtroyer): Only network extensions are currently supported but
|
||||
# I am going to leave this here anyway as a reminder
|
||||
# fix that.
|
||||
# def test_extension_show_compute(self):
|
||||
# """Test compute extension show"""
|
||||
# json_output = json.loads(self.openstack(
|
||||
# 'extension show -f json ' +
|
||||
# 'ImageSize'
|
||||
# ))
|
||||
# self.assertEqual(
|
||||
# 'OS-EXT-IMG-SIZE',
|
||||
# json_output.get('Alias'),
|
||||
# )
|
||||
|
||||
def test_extension_show_network(self):
|
||||
"""Test network extension show"""
|
||||
if not self.haz_network:
|
||||
self.skipTest("No Network service present")
|
||||
|
||||
name = 'agent'
|
||||
json_output = json.loads(self.openstack(
|
||||
'extension show -f json ' +
|
||||
name
|
||||
))
|
||||
output = self.openstack(
|
||||
'extension show ' + name,
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
name,
|
||||
json_output.get('alias'),
|
||||
output.get('alias'),
|
||||
)
|
||||
|
||||
def test_extension_show_not_exist(self):
|
||||
|
@ -10,7 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from tempest.lib import exceptions
|
||||
@ -36,9 +35,10 @@ class QuotaTests(base.TestCase):
|
||||
|
||||
def test_quota_list_details_compute(self):
|
||||
expected_headers = ["Resource", "In Use", "Reserved", "Limit"]
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --detail --compute'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --detail --compute',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
resources = []
|
||||
for row in cmd_output:
|
||||
@ -52,9 +52,10 @@ class QuotaTests(base.TestCase):
|
||||
|
||||
def test_quota_list_details_network(self):
|
||||
expected_headers = ["Resource", "In Use", "Reserved", "Limit"]
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --detail --network'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --detail --network',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
resources = []
|
||||
for row in cmd_output:
|
||||
@ -70,9 +71,10 @@ class QuotaTests(base.TestCase):
|
||||
if not self.haz_network:
|
||||
self.skipTest("No Network service present")
|
||||
self.openstack('quota set --networks 40 ' + self.PROJECT_NAME)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --network'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --network',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertEqual(
|
||||
40,
|
||||
@ -81,9 +83,10 @@ class QuotaTests(base.TestCase):
|
||||
|
||||
def test_quota_list_compute_option(self):
|
||||
self.openstack('quota set --instances 30 ' + self.PROJECT_NAME)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --compute'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --compute',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertEqual(
|
||||
30,
|
||||
@ -92,9 +95,10 @@ class QuotaTests(base.TestCase):
|
||||
|
||||
def test_quota_list_volume_option(self):
|
||||
self.openstack('quota set --volumes 20 ' + self.PROJECT_NAME)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --volume'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --volume',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertEqual(
|
||||
20,
|
||||
@ -111,9 +115,10 @@ class QuotaTests(base.TestCase):
|
||||
network_option +
|
||||
self.PROJECT_NAME
|
||||
)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota show -f json ' + self.PROJECT_NAME
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota show ' + self.PROJECT_NAME,
|
||||
parse_output=True,
|
||||
)
|
||||
cmd_output = {x['Resource']: x['Limit'] for x in cmd_output}
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertEqual(
|
||||
@ -131,9 +136,10 @@ class QuotaTests(base.TestCase):
|
||||
)
|
||||
|
||||
# Check default quotas
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota show -f json --default'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota show --default',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
# We don't necessarily know the default quotas, we're checking the
|
||||
# returned attributes
|
||||
@ -148,9 +154,10 @@ class QuotaTests(base.TestCase):
|
||||
'quota set --key-pairs 33 --snapshots 43 ' +
|
||||
'--class default'
|
||||
)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota show -f json --class default'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota show --class default',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
cmd_output = {x['Resource']: x['Limit'] for x in cmd_output}
|
||||
self.assertEqual(
|
||||
@ -163,9 +170,10 @@ class QuotaTests(base.TestCase):
|
||||
)
|
||||
|
||||
# Check default quota class
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota show -f json --class'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota show --class',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
# We don't necessarily know the default quotas, we're checking the
|
||||
# returned attributes
|
||||
@ -182,16 +190,18 @@ class QuotaTests(base.TestCase):
|
||||
if not self.is_extension_enabled('quota-check-limit'):
|
||||
self.skipTest('No "quota-check-limit" extension present')
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --network'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --network',
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self._restore_quota_limit, 'network',
|
||||
cmd_output[0]['Networks'], self.PROJECT_NAME)
|
||||
|
||||
self.openstack('quota set --networks 40 ' + self.PROJECT_NAME)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --network'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --network',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertEqual(40, cmd_output[0]['Networks'])
|
||||
|
||||
@ -218,16 +228,18 @@ class QuotaTests(base.TestCase):
|
||||
if not self.is_extension_enabled('quota-check-limit'):
|
||||
self.skipTest('No "quota-check-limit" extension present')
|
||||
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --network'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --network',
|
||||
parse_output=True,
|
||||
)
|
||||
self.addCleanup(self._restore_quota_limit, 'network',
|
||||
cmd_output[0]['Networks'], self.PROJECT_NAME)
|
||||
|
||||
self.openstack('quota set --networks 40 ' + self.PROJECT_NAME)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --network'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --network',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertEqual(40, cmd_output[0]['Networks'])
|
||||
|
||||
@ -237,8 +249,9 @@ class QuotaTests(base.TestCase):
|
||||
(self.PROJECT_NAME, uuid.uuid4().hex))
|
||||
|
||||
self.openstack('quota set --networks 1 --force ' + self.PROJECT_NAME)
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'quota list -f json --network'
|
||||
))
|
||||
cmd_output = self.openstack(
|
||||
'quota list --network',
|
||||
parse_output=True,
|
||||
)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertEqual(1, cmd_output[0]['Networks'])
|
||||
|
@ -10,8 +10,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
from openstackclient.tests.functional import base
|
||||
|
||||
|
||||
@ -21,9 +19,7 @@ class VersionsTests(base.TestCase):
|
||||
def test_versions_show(self):
|
||||
# TODO(mordred) Make this better. The trick is knowing what in the
|
||||
# payload to test for.
|
||||
cmd_output = json.loads(self.openstack(
|
||||
'versions show -f json'
|
||||
))
|
||||
cmd_output = self.openstack('versions show', parse_output=True)
|
||||
self.assertIsNotNone(cmd_output)
|
||||
self.assertIn(
|
||||
"Region Name",
|
||||
|
Loading…
Reference in New Issue
Block a user