Deduplicate method in OSC functional tests
Move construct_cmd method to base of functional tests. Also fix typo in method name and refactor this method. Change-Id: I352e7a4bcf439d290d6c1a31145d285102743eca
This commit is contained in:
parent
27663efdd3
commit
b63321f8ea
ironicclient/tests/functional/osc/v1
@ -35,6 +35,10 @@ class TestCase(base.FunctionalTestBase):
|
||||
return ' -f {0} {1}'.format(output_format,
|
||||
' '.join(['-c ' + it for it in fields]))
|
||||
|
||||
@staticmethod
|
||||
def construct_cmd(*parts):
|
||||
return ' '.join(str(x) for x in parts)
|
||||
|
||||
def node_create(self, driver='fake', name=None, params=''):
|
||||
"""Create baremetal node and add cleanup.
|
||||
|
||||
|
@ -26,13 +26,6 @@ class BaremetalNodeCreateNegativeTests(base.TestCase):
|
||||
def setUp(self):
|
||||
super(BaremetalNodeCreateNegativeTests, self).setUp()
|
||||
|
||||
@staticmethod
|
||||
def constuct_cmd(base_cmd, argument, value):
|
||||
cmd = base_cmd
|
||||
if argument:
|
||||
cmd = '{0} {1} {2}'.format(cmd, argument, value)
|
||||
return cmd
|
||||
|
||||
@ddt.data(
|
||||
('--uuid', '', 'expected one argument'),
|
||||
('--uuid', '!@#$^*&%^', 'Expected a UUID'),
|
||||
@ -50,6 +43,6 @@ class BaremetalNodeCreateNegativeTests(base.TestCase):
|
||||
@ddt.unpack
|
||||
def test_baremetal_node_create(self, argument, value, ex_text):
|
||||
base_cmd = 'baremetal node create --driver fake'
|
||||
command = self.constuct_cmd(base_cmd, argument, value)
|
||||
command = self.construct_cmd(base_cmd, argument, value)
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
|
||||
self.openstack, command)
|
||||
|
@ -27,13 +27,6 @@ class BaremetalNodeNegativeTests(base.TestCase):
|
||||
super(BaremetalNodeNegativeTests, self).setUp()
|
||||
self.node = self.node_create()
|
||||
|
||||
@staticmethod
|
||||
def constuct_cmd(base_cmd, argument, value):
|
||||
cmd = base_cmd
|
||||
if argument:
|
||||
cmd = '{} {} {}'.format(cmd, argument, value)
|
||||
return cmd
|
||||
|
||||
@ddt.data(
|
||||
('', '', 'error: argument --driver is required'),
|
||||
('--driver', 'wrongdriver',
|
||||
@ -44,7 +37,7 @@ class BaremetalNodeNegativeTests(base.TestCase):
|
||||
def test_create_driver(self, argument, value, ex_text):
|
||||
"""Negative test for baremetal node driver options."""
|
||||
base_cmd = 'baremetal node create'
|
||||
command = self.constuct_cmd(base_cmd, argument, value)
|
||||
command = self.construct_cmd(base_cmd, argument, value)
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
|
||||
self.openstack, command)
|
||||
|
||||
@ -70,8 +63,8 @@ class BaremetalNodeNegativeTests(base.TestCase):
|
||||
def test_set_property(self, argument, value, ex_text):
|
||||
"""Negative test for baremetal node set command options."""
|
||||
base_cmd = 'baremetal node set'
|
||||
command = '{} {}'.format(
|
||||
self.constuct_cmd(base_cmd, argument, value), self.node['uuid'])
|
||||
command = self.construct_cmd(base_cmd, argument, value,
|
||||
self.node['uuid'])
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
|
||||
self.openstack, command)
|
||||
|
||||
@ -83,7 +76,7 @@ class BaremetalNodeNegativeTests(base.TestCase):
|
||||
def test_unset_property(self, argument, value, ex_text):
|
||||
"""Negative test for baremetal node unset command options."""
|
||||
base_cmd = 'baremetal node unset'
|
||||
command = '{} {}'.format(
|
||||
self.constuct_cmd(base_cmd, argument, value), self.node['uuid'])
|
||||
command = self.construct_cmd(base_cmd, argument, value,
|
||||
self.node['uuid'])
|
||||
six.assertRaisesRegex(self, exceptions.CommandFailed, ex_text,
|
||||
self.openstack, command)
|
||||
|
Loading…
x
Reference in New Issue
Block a user