'Run a task and check the number of emails processed.'

def _test_run_with_task(self, task_class, action_name, total, succeeded, failed=0, skipped=0, retried_nomax=0, retried_withmax=0):

    task_entry = self._create_input_entry()
    parent_status = self._run_task_with_mock_celery(task_class, task_entry.id, task_entry.task_id)
    self.assertEquals(parent_status.get('total'), total)
    self.assertEquals(parent_status.get('action_name'), action_name)
    entry = InstructorTask.objects.get(id=task_entry.id)
    status = json.loads(entry.task_output)
    self.assertEquals(status.get('attempted'), (succeeded + failed))
    self.assertEquals(status.get('succeeded'), succeeded)
    self.assertEquals(status.get('skipped'), skipped)
    self.assertEquals(status.get('failed'), failed)
    self.assertEquals(status.get('total'), total)
    self.assertEquals(status.get('action_name'), action_name)
    self.assertGreater(status.get('duration_ms'), 0)
    self.assertEquals(entry.task_state, SUCCESS)
    self._assert_single_subtask_status(entry, succeeded, failed, skipped, retried_nomax, retried_withmax)
    return entry
