Merge "Functional test for ip_availability"
This commit is contained in:
@@ -10,6 +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 json
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from openstackclient.tests.functional import base
|
from openstackclient.tests.functional import base
|
||||||
@@ -17,22 +18,19 @@ from openstackclient.tests.functional import base
|
|||||||
|
|
||||||
class IPAvailabilityTests(base.TestCase):
|
class IPAvailabilityTests(base.TestCase):
|
||||||
"""Functional tests for IP availability. """
|
"""Functional tests for IP availability. """
|
||||||
NAME = uuid.uuid4().hex
|
|
||||||
NETWORK_NAME = uuid.uuid4().hex
|
|
||||||
FIELDS = ['network_name']
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setUpClass(cls):
|
||||||
# Create a network for the subnet.
|
# Create a network for the subnet.
|
||||||
|
cls.NAME = uuid.uuid4().hex
|
||||||
|
cls.NETWORK_NAME = uuid.uuid4().hex
|
||||||
cls.openstack('network create ' + cls.NETWORK_NAME)
|
cls.openstack('network create ' + cls.NETWORK_NAME)
|
||||||
opts = cls.get_opts(['name'])
|
cmd_output = json.loads(cls.openstack(
|
||||||
raw_output = cls.openstack(
|
'subnet create -f json --network ' + cls.NETWORK_NAME +
|
||||||
'subnet create --network ' + cls.NETWORK_NAME +
|
|
||||||
' --subnet-range 10.10.10.0/24 ' +
|
' --subnet-range 10.10.10.0/24 ' +
|
||||||
cls.NAME + opts
|
cls.NAME
|
||||||
)
|
))
|
||||||
expected = cls.NAME + '\n'
|
cls.assertOutput(cls.NAME, cmd_output['name'])
|
||||||
cls.assertOutput(expected, raw_output)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def tearDownClass(cls):
|
||||||
@@ -42,12 +40,17 @@ class IPAvailabilityTests(base.TestCase):
|
|||||||
cls.assertOutput('', raw_network)
|
cls.assertOutput('', raw_network)
|
||||||
|
|
||||||
def test_ip_availability_list(self):
|
def test_ip_availability_list(self):
|
||||||
opts = ' -f csv -c "Network Name"'
|
"""Test ip availability list"""
|
||||||
raw_output = self.openstack('ip availability list' + opts)
|
cmd_output = json.loads(self.openstack(
|
||||||
self.assertIn(self.NETWORK_NAME, raw_output)
|
'ip availability list -f json'))
|
||||||
|
names = [x['Network Name'] for x in cmd_output]
|
||||||
|
self.assertIn(self.NETWORK_NAME, names)
|
||||||
|
|
||||||
def test_ip_availability_show(self):
|
def test_ip_availability_show(self):
|
||||||
opts = self.get_opts(self.FIELDS)
|
"""Test ip availability show"""
|
||||||
raw_output = self.openstack(
|
cmd_output = json.loads(self.openstack(
|
||||||
'ip availability show ' + self.NETWORK_NAME + opts)
|
'ip availability show -f json ' + self.NETWORK_NAME))
|
||||||
self.assertEqual(self.NETWORK_NAME + "\n", raw_output)
|
self.assertEqual(
|
||||||
|
self.NETWORK_NAME,
|
||||||
|
cmd_output['network_name'],
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user