'Compare counts with \'subtasks\' entry in InstructorTask table.'

def _assert_single_subtask_status(self, entry, succeeded, failed=0, skipped=0, retried_nomax=0, retried_withmax=0):

    subtask_info = json.loads(entry.subtasks)
    self.assertEquals(subtask_info.get('total'), 1)
    self.assertEquals(subtask_info.get('succeeded'), (1 if (succeeded > 0) else 0))
    self.assertEquals(subtask_info.get('failed'), (0 if (succeeded > 0) else 1))
    subtask_status_info = subtask_info.get('status')
    task_id_list = subtask_status_info.keys()
    self.assertEquals(len(task_id_list), 1)
    task_id = task_id_list[0]
    subtask_status = subtask_status_info.get(task_id)
    print 'Testing    subtask    status:    {}'.format(subtask_status)
    self.assertEquals(subtask_status.get('task_id'), task_id)
    self.assertEquals(subtask_status.get('attempted'), (succeeded + failed))
    self.assertEquals(subtask_status.get('succeeded'), succeeded)
    self.assertEquals(subtask_status.get('skipped'), skipped)
    self.assertEquals(subtask_status.get('failed'), failed)
    self.assertEquals(subtask_status.get('retried_nomax'), retried_nomax)
    self.assertEquals(subtask_status.get('retried_withmax'), retried_withmax)
    self.assertEquals(subtask_status.get('state'), (SUCCESS if (succeeded > 0) else FAILURE))
