'Verify that a task failed with the specified error message'

def _assert_failed(self, task_result, error_message):

    status = UserTaskStatus.objects.get(task_id=task_result.id)
    self.assertEqual(status.state, UserTaskStatus.FAILED)
    artifacts = UserTaskArtifact.objects.filter(status=status)
    self.assertEqual(len(artifacts), 1)
    error = artifacts[0]
    self.assertEqual(error.name, u'Error')
    self.assertEqual(error.text, error_message)
