Enforce autospec in xclarity tests
And remove corresponding filter from tox.ini Change-Id: I2fcca0c697970264b711f90000087991bd6125ac
This commit is contained in:
parent
874089f433
commit
c6c79d1437
@ -61,7 +61,7 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase):
|
||||
self.assertEqual(expected, driver.get_properties())
|
||||
|
||||
@mock.patch.object(management.XClarityManagement, 'get_boot_device',
|
||||
return_value='pxe')
|
||||
return_value='pxe', autospec=True)
|
||||
def test_set_boot_device(self, mock_get_boot_device,
|
||||
mock_get_xc_client):
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
@ -95,7 +95,8 @@ class XClarityManagementDriverTestCase(db_base.DbTestCase):
|
||||
@mock.patch.object(
|
||||
management.XClarityManagement,
|
||||
'get_boot_device',
|
||||
return_value={'boot_device': 'pxe', 'persistent': False})
|
||||
return_value={'boot_device': 'pxe', 'persistent': False},
|
||||
autospec=True)
|
||||
def test_get_boot_device(self, mock_get_boot_device, mock_get_xc_client):
|
||||
reference = {'boot_device': 'pxe', 'persistent': False}
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
|
@ -66,10 +66,10 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
|
||||
mock_validate_driver_info.assert_called_with(task.node)
|
||||
|
||||
@mock.patch.object(power.XClarityPower, 'get_power_state',
|
||||
return_value=STATE_POWER_ON)
|
||||
return_value=STATE_POWER_ON, autospec=True)
|
||||
def test_get_power_state(self, mock_get_power_state, mock_get_xc_client):
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
result = power.XClarityPower.get_power_state(task)
|
||||
result = power.XClarityPower.get_power_state(self, task)
|
||||
self.assertEqual(STATE_POWER_ON, result)
|
||||
|
||||
@mock.patch.object(common, 'translate_xclarity_power_state',
|
||||
@ -89,9 +89,9 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
|
||||
task)
|
||||
self.assertFalse(mock_translate_state.called)
|
||||
|
||||
@mock.patch.object(power.LOG, 'warning')
|
||||
@mock.patch.object(power.LOG, 'warning', autospec=True)
|
||||
@mock.patch.object(power.XClarityPower, 'get_power_state',
|
||||
return_value=states.POWER_ON)
|
||||
return_value=states.POWER_ON, autospec=True)
|
||||
def test_set_power(self, mock_set_power_state, mock_log,
|
||||
mock_get_xc_client):
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
@ -100,9 +100,9 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
|
||||
self.assertEqual(expected, states.POWER_ON)
|
||||
self.assertFalse(mock_log.called)
|
||||
|
||||
@mock.patch.object(power.LOG, 'warning')
|
||||
@mock.patch.object(power.LOG, 'warning', autospec=True)
|
||||
@mock.patch.object(power.XClarityPower, 'get_power_state',
|
||||
return_value=states.POWER_ON)
|
||||
return_value=states.POWER_ON, autospec=True)
|
||||
def test_set_power_timeout(self, mock_set_power_state, mock_log,
|
||||
mock_get_xc_client):
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
@ -126,19 +126,21 @@ class XClarityPowerDriverTestCase(db_base.DbTestCase):
|
||||
task.driver.power.set_power_state,
|
||||
task, states.POWER_OFF)
|
||||
|
||||
@mock.patch.object(power.LOG, 'warning')
|
||||
@mock.patch.object(power.XClarityPower, 'set_power_state')
|
||||
@mock.patch.object(power.LOG, 'warning', autospec=True)
|
||||
@mock.patch.object(power.XClarityPower, 'set_power_state', autospec=True)
|
||||
def test_reboot(self, mock_set_power_state, mock_log, mock_get_xc_client):
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
task.driver.power.reboot(task)
|
||||
mock_set_power_state.assert_called_with(task, states.REBOOT)
|
||||
mock_set_power_state.assert_called_with(
|
||||
mock.ANY, task, states.REBOOT)
|
||||
self.assertFalse(mock_log.called)
|
||||
|
||||
@mock.patch.object(power.LOG, 'warning')
|
||||
@mock.patch.object(power.XClarityPower, 'set_power_state')
|
||||
@mock.patch.object(power.LOG, 'warning', autospec=True)
|
||||
@mock.patch.object(power.XClarityPower, 'set_power_state', autospec=True)
|
||||
def test_reboot_timeout(self, mock_set_power_state, mock_log,
|
||||
mock_get_xc_client):
|
||||
with task_manager.acquire(self.context, self.node.uuid) as task:
|
||||
task.driver.power.reboot(task, timeout=55)
|
||||
mock_set_power_state.assert_called_with(task, states.REBOOT)
|
||||
mock_set_power_state.assert_called_with(
|
||||
mock.ANY, task, states.REBOOT)
|
||||
self.assertTrue(mock_log.called)
|
||||
|
1
tox.ini
1
tox.ini
@ -135,7 +135,6 @@ per-file-ignores =
|
||||
ironic/tests/unit/drivers/modules/test_console_utils.py:H210
|
||||
ironic/tests/unit/drivers/modules/ilo/*:H210
|
||||
ironic/tests/unit/drivers/modules/irmc/*:H210
|
||||
ironic/tests/unit/drivers/modules/xclarity/*:H210
|
||||
|
||||
[hacking]
|
||||
import_exceptions = testtools.matchers, ironic.common.i18n
|
||||
|
Loading…
x
Reference in New Issue
Block a user