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

def _test_run_with_task(self, task_class, action_name, expected_num_succeeded, expected_num_skipped=0, expected_attempted=0, expected_total=0):

    task_entry = self._create_input_entry()
    status = self._run_task_with_mock_celery(task_class, task_entry.id, task_entry.task_id)
    expected_attempted = (expected_attempted if expected_attempted else (expected_num_succeeded + expected_num_skipped))
    expected_total = (expected_total if expected_total else (expected_num_succeeded + expected_num_skipped))
    self.assertEquals(status.get('attempted'), expected_attempted)
    self.assertEquals(status.get('succeeded'), expected_num_succeeded)
    self.assertEquals(status.get('skipped'), expected_num_skipped)
    self.assertEquals(status.get('total'), expected_total)
    self.assertEquals(status.get('action_name'), action_name)
    self.assertGreater(status.get('duration_ms'), 0)
    entry = InstructorTask.objects.get(id=task_entry.id)
    self.assertEquals(json.loads(entry.task_output), status)
    self.assertEquals(entry.task_state, SUCCESS)
