Fix address scope list --share
Remove the 'shared' key from the attrs passed in to the SDK with 0.9.13. Also convert the functional tests to the JSON-style (that's how I found this). Closes-bug: 1659993 Change-Id: I614fbce967cdd07fe7360242547dbf52e7677939
This commit is contained in:
parent
ca763793cc
commit
4a12280999
@ -204,10 +204,8 @@ class ListAddressScope(command.Lister):
|
|||||||
if parsed_args.ip_version:
|
if parsed_args.ip_version:
|
||||||
attrs['ip_version'] = parsed_args.ip_version
|
attrs['ip_version'] = parsed_args.ip_version
|
||||||
if parsed_args.share:
|
if parsed_args.share:
|
||||||
attrs['shared'] = True
|
|
||||||
attrs['is_shared'] = True
|
attrs['is_shared'] = True
|
||||||
if parsed_args.no_share:
|
if parsed_args.no_share:
|
||||||
attrs['shared'] = False
|
|
||||||
attrs['is_shared'] = False
|
attrs['is_shared'] = False
|
||||||
if 'project' in parsed_args and parsed_args.project is not None:
|
if 'project' in parsed_args and parsed_args.project is not None:
|
||||||
identity_client = self.app.client_manager.identity
|
identity_client = self.app.client_manager.identity
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import re
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional import base
|
||||||
@ -24,36 +24,31 @@ class AddressScopeTests(base.TestCase):
|
|||||||
# has its own needs and there are collisions when running
|
# has its own needs and there are collisions when running
|
||||||
# tests in parallel.
|
# tests in parallel.
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
# Set up some regex for matching below
|
|
||||||
cls.re_name = re.compile("name\s+\|\s+([^|]+?)\s+\|")
|
|
||||||
cls.re_ip_version = re.compile("ip_version\s+\|\s+(\S+)")
|
|
||||||
cls.re_shared = re.compile("shared\s+\|\s+(\S+)")
|
|
||||||
|
|
||||||
def test_address_scope_delete(self):
|
def test_address_scope_delete(self):
|
||||||
"""Test create, delete multiple"""
|
"""Test create, delete multiple"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
raw_output = self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'address scope create ' + name1,
|
'address scope create -f json ' +
|
||||||
)
|
name1
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name1,
|
name1,
|
||||||
re.search(self.re_name, raw_output).group(1),
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
# Check the default values
|
# Check the default values
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'False',
|
False,
|
||||||
re.search(self.re_shared, raw_output).group(1),
|
cmd_output['shared'],
|
||||||
)
|
)
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
raw_output = self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'address scope create ' + name2,
|
'address scope create -f json ' +
|
||||||
)
|
name2
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name2,
|
name2,
|
||||||
re.search(self.re_name, raw_output).group(1),
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -64,72 +59,93 @@ class AddressScopeTests(base.TestCase):
|
|||||||
def test_address_scope_list(self):
|
def test_address_scope_list(self):
|
||||||
"""Test create defaults, list filters, delete"""
|
"""Test create defaults, list filters, delete"""
|
||||||
name1 = uuid.uuid4().hex
|
name1 = uuid.uuid4().hex
|
||||||
raw_output = self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'address scope create --ip-version 4 --share ' + name1,
|
'address scope create -f json ' +
|
||||||
)
|
'--ip-version 4 ' +
|
||||||
|
'--share ' +
|
||||||
|
name1
|
||||||
|
))
|
||||||
self.addCleanup(self.openstack, 'address scope delete ' + name1)
|
self.addCleanup(self.openstack, 'address scope delete ' + name1)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'4',
|
name1,
|
||||||
re.search(self.re_ip_version, raw_output).group(1),
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'True',
|
4,
|
||||||
re.search(self.re_shared, raw_output).group(1),
|
cmd_output['ip_version'],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
True,
|
||||||
|
cmd_output['shared'],
|
||||||
)
|
)
|
||||||
|
|
||||||
name2 = uuid.uuid4().hex
|
name2 = uuid.uuid4().hex
|
||||||
raw_output = self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'address scope create --ip-version 6 --no-share ' + name2,
|
'address scope create -f json ' +
|
||||||
)
|
'--ip-version 6 ' +
|
||||||
|
'--no-share ' +
|
||||||
|
name2
|
||||||
|
))
|
||||||
self.addCleanup(self.openstack, 'address scope delete ' + name2)
|
self.addCleanup(self.openstack, 'address scope delete ' + name2)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'6',
|
name2,
|
||||||
re.search(self.re_ip_version, raw_output).group(1),
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'False',
|
6,
|
||||||
re.search(self.re_shared, raw_output).group(1),
|
cmd_output['ip_version'],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
False,
|
||||||
|
cmd_output['shared'],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Test list
|
# Test list
|
||||||
raw_output = self.openstack('address scope list')
|
cmd_output = json.loads(self.openstack(
|
||||||
self.assertIsNotNone(re.search(name1 + "\s+\|\s+4", raw_output))
|
'address scope list -f json ',
|
||||||
self.assertIsNotNone(re.search(name2 + "\s+\|\s+6", raw_output))
|
))
|
||||||
|
col_data = [x["IP Version"] for x in cmd_output]
|
||||||
|
self.assertIn(4, col_data)
|
||||||
|
self.assertIn(6, col_data)
|
||||||
|
|
||||||
# Test list --share
|
# Test list --share
|
||||||
# TODO(dtroyer): returns 'HttpException: Bad Request'
|
cmd_output = json.loads(self.openstack(
|
||||||
# raw_output = self.openstack('address scope list --share')
|
'address scope list -f json --share',
|
||||||
# self.assertIsNotNone(re.search(name1 + "\s+\|\s+4", raw_output))
|
))
|
||||||
# self.assertIsNotNone(re.search(name2 + "\s+\|\s+6", raw_output))
|
col_data = [x["Shared"] for x in cmd_output]
|
||||||
|
self.assertIn(True, col_data)
|
||||||
|
self.assertNotIn(False, col_data)
|
||||||
|
|
||||||
# Test list --no-share
|
# Test list --no-share
|
||||||
# TODO(dtroyer): returns 'HttpException: Bad Request'
|
cmd_output = json.loads(self.openstack(
|
||||||
# raw_output = self.openstack('address scope list --no-share')
|
'address scope list -f json --no-share',
|
||||||
# self.assertIsNotNone(re.search(name1 + "\s+\|\s+4", raw_output))
|
))
|
||||||
# self.assertIsNotNone(re.search(name2 + "\s+\|\s+6", raw_output))
|
col_data = [x["Shared"] for x in cmd_output]
|
||||||
|
self.assertIn(False, col_data)
|
||||||
|
self.assertNotIn(True, col_data)
|
||||||
|
|
||||||
def test_address_scope_set(self):
|
def test_address_scope_set(self):
|
||||||
"""Tests create options, set, show, delete"""
|
"""Tests create options, set, show, delete"""
|
||||||
name = uuid.uuid4().hex
|
name = uuid.uuid4().hex
|
||||||
newname = name + "_"
|
newname = name + "_"
|
||||||
raw_output = self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'address scope create ' +
|
'address scope create -f json ' +
|
||||||
'--ip-version 4 ' +
|
'--ip-version 4 ' +
|
||||||
'--no-share ' +
|
'--no-share ' +
|
||||||
name,
|
name
|
||||||
)
|
))
|
||||||
self.addCleanup(self.openstack, 'address scope delete ' + newname)
|
self.addCleanup(self.openstack, 'address scope delete ' + newname)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
name,
|
name,
|
||||||
re.search(self.re_name, raw_output).group(1),
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'4',
|
4,
|
||||||
re.search(self.re_ip_version, raw_output).group(1),
|
cmd_output['ip_version'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'False',
|
False,
|
||||||
re.search(self.re_shared, raw_output).group(1),
|
cmd_output['shared'],
|
||||||
)
|
)
|
||||||
|
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
@ -140,16 +156,19 @@ class AddressScopeTests(base.TestCase):
|
|||||||
)
|
)
|
||||||
self.assertOutput('', raw_output)
|
self.assertOutput('', raw_output)
|
||||||
|
|
||||||
raw_output = self.openstack('address scope show ' + newname)
|
cmd_output = json.loads(self.openstack(
|
||||||
|
'address scope show -f json ' +
|
||||||
|
newname,
|
||||||
|
))
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
newname,
|
newname,
|
||||||
re.search(self.re_name, raw_output).group(1),
|
cmd_output['name'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'4',
|
4,
|
||||||
re.search(self.re_ip_version, raw_output).group(1),
|
cmd_output['ip_version'],
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'True',
|
True,
|
||||||
re.search(self.re_shared, raw_output).group(1),
|
cmd_output['shared'],
|
||||||
)
|
)
|
||||||
|
@ -352,7 +352,7 @@ class TestListAddressScope(TestAddressScope):
|
|||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.network.address_scopes.assert_called_once_with(
|
self.network.address_scopes.assert_called_once_with(
|
||||||
**{'shared': True, 'is_shared': True}
|
**{'is_shared': True}
|
||||||
)
|
)
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, list(data))
|
self.assertEqual(self.data, list(data))
|
||||||
@ -368,7 +368,7 @@ class TestListAddressScope(TestAddressScope):
|
|||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.network.address_scopes.assert_called_once_with(
|
self.network.address_scopes.assert_called_once_with(
|
||||||
**{'shared': False, 'is_shared': False}
|
**{'is_shared': False}
|
||||||
)
|
)
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, list(data))
|
self.assertEqual(self.data, list(data))
|
||||||
|
Loading…
Reference in New Issue
Block a user