'Test wait_for_task_completion failed.'

@patch('time.sleep')
def test_wait_for_task_completion_fail(self, mock_time):

    module = Mock()
    try_one = dict(workOrderUserDefinedStatus='Failed')
    try_two = dict(workOrderUserDefinedStatus='Completed')
    module.client.api.get_task_by_id.side_effect = [try_one, try_two]
    result = cv_server_provision.wait_for_task_completion(module, '7')
    self.assertTrue(result)
    self.assertEqual(module.client.api.get_task_by_id.call_count, 2)
    text = 'Task    7    has    reported    status    Failed.    Please    consult    the    CVP    admins    for    more    information.'
    module.fail_json.assert_called_with(msg=text)
    self.assertEqual(mock_time.call_count, 1)
