Change assertTrue(isinstance()) by optimal assert
Some of tests use different method of assertTrue(isinstance(A, B)) or assertEqual(type(A), B). The correct way is to use assertIsInstance(A, B) provided by testtools. Change-Id: I8e95e10fac4748b115838b6b480f1085da73f28a Closes-bug: #1268480
This commit is contained in:
parent
55239c2199
commit
fac700c8e7
@ -67,8 +67,8 @@ class TestFlowExtension(test_base.BaseTestCase):
|
|||||||
result = self.agent_extension.start_flow(flow=FLOW_INFO)
|
result = self.agent_extension.start_flow(flow=FLOW_INFO)
|
||||||
result.join()
|
result.join()
|
||||||
self.assertEqual(base.AgentCommandStatus.FAILED, result.command_status)
|
self.assertEqual(base.AgentCommandStatus.FAILED, result.command_status)
|
||||||
self.assertTrue(isinstance(result.command_error,
|
self.assertIsInstance(result.command_error,
|
||||||
errors.CommandExecutionError))
|
errors.CommandExecutionError)
|
||||||
|
|
||||||
@mock.patch('time.sleep', autospec=True)
|
@mock.patch('time.sleep', autospec=True)
|
||||||
def test_sleep_flow_failed_on_second_command(self, sleep_mock):
|
def test_sleep_flow_failed_on_second_command(self, sleep_mock):
|
||||||
@ -76,8 +76,8 @@ class TestFlowExtension(test_base.BaseTestCase):
|
|||||||
result = self.agent_extension.start_flow(flow=FLOW_INFO[:4])
|
result = self.agent_extension.start_flow(flow=FLOW_INFO[:4])
|
||||||
result.join()
|
result.join()
|
||||||
self.assertEqual(base.AgentCommandStatus.FAILED, result.command_status)
|
self.assertEqual(base.AgentCommandStatus.FAILED, result.command_status)
|
||||||
self.assertTrue(isinstance(result.command_error,
|
self.assertIsInstance(result.command_error,
|
||||||
errors.CommandExecutionError))
|
errors.CommandExecutionError)
|
||||||
self.assertEqual(2, sleep_mock.call_count)
|
self.assertEqual(2, sleep_mock.call_count)
|
||||||
|
|
||||||
def test_validate_exts_success(self):
|
def test_validate_exts_success(self):
|
||||||
|
@ -159,7 +159,7 @@ class TestBaseAgent(test_base.BaseTestCase):
|
|||||||
self.agent.started_at = started_at
|
self.agent.started_at = started_at
|
||||||
|
|
||||||
status = self.agent.get_status()
|
status = self.agent.get_status()
|
||||||
self.assertTrue(isinstance(status, agent.IronicPythonAgentStatus))
|
self.assertIsInstance(status, agent.IronicPythonAgentStatus)
|
||||||
self.assertEqual(started_at, status.started_at)
|
self.assertEqual(started_at, status.started_at)
|
||||||
self.assertEqual(pkg_resources.get_distribution('ironic-python-agent')
|
self.assertEqual(pkg_resources.get_distribution('ironic-python-agent')
|
||||||
.version, status.version)
|
.version, status.version)
|
||||||
|
Loading…
Reference in New Issue
Block a user