Merge "Fix "ip availability show" command"
This commit is contained in:
commit
8cf99c3866
@ -107,7 +107,9 @@ class ShowIPAvailability(command.ShowOne):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
obj = client.find_network_ip_availability(parsed_args.network,
|
network_id = client.find_network(parsed_args.network,
|
||||||
|
ignore_missing=False).id
|
||||||
|
obj = client.find_network_ip_availability(network_id,
|
||||||
ignore_missing=False)
|
ignore_missing=False)
|
||||||
display_columns, columns = _get_columns(obj)
|
display_columns, columns = _get_columns(obj)
|
||||||
data = utils.get_item_properties(obj, columns, formatters=_formatters)
|
data = utils.get_item_properties(obj, columns, formatters=_formatters)
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
# 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 testtools
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional import base
|
||||||
@ -47,7 +46,6 @@ class IPAvailabilityTests(base.TestCase):
|
|||||||
raw_output = self.openstack('ip availability list' + opts)
|
raw_output = self.openstack('ip availability list' + opts)
|
||||||
self.assertIn(self.NETWORK_NAME, raw_output)
|
self.assertIn(self.NETWORK_NAME, raw_output)
|
||||||
|
|
||||||
@testtools.skip('broken SDK testing')
|
|
||||||
def test_ip_availability_show(self):
|
def test_ip_availability_show(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
opts = self.get_opts(self.FIELDS)
|
||||||
raw_output = self.openstack(
|
raw_output = self.openstack(
|
||||||
|
@ -118,8 +118,10 @@ class TestListIPAvailability(TestIPAvailability):
|
|||||||
|
|
||||||
class TestShowIPAvailability(TestIPAvailability):
|
class TestShowIPAvailability(TestIPAvailability):
|
||||||
|
|
||||||
|
_network = network_fakes.FakeNetwork.create_one_network()
|
||||||
_ip_availability = \
|
_ip_availability = \
|
||||||
network_fakes.FakeIPAvailability.create_one_ip_availability()
|
network_fakes.FakeIPAvailability.create_one_ip_availability(
|
||||||
|
attrs={'network_id': _network.id})
|
||||||
|
|
||||||
columns = (
|
columns = (
|
||||||
'network_id',
|
'network_id',
|
||||||
@ -144,6 +146,8 @@ class TestShowIPAvailability(TestIPAvailability):
|
|||||||
|
|
||||||
self.network.find_network_ip_availability = mock.Mock(
|
self.network.find_network_ip_availability = mock.Mock(
|
||||||
return_value=self._ip_availability)
|
return_value=self._ip_availability)
|
||||||
|
self.network.find_network = mock.Mock(
|
||||||
|
return_value=self._network)
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = ip_availability.ShowIPAvailability(
|
self.cmd = ip_availability.ShowIPAvailability(
|
||||||
@ -166,8 +170,10 @@ class TestShowIPAvailability(TestIPAvailability):
|
|||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
self.network.find_network_ip_availability.assert_called_once_with(
|
self.network.find_network_ip_availability.assert_called_once_with(
|
||||||
|
self._ip_availability.network_id,
|
||||||
|
ignore_missing=False)
|
||||||
|
self.network.find_network.assert_called_once_with(
|
||||||
self._ip_availability.network_name,
|
self._ip_availability.network_name,
|
||||||
ignore_missing=False)
|
ignore_missing=False)
|
||||||
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
Loading…
Reference in New Issue
Block a user