def test_get_todo_list(self): user = UserNode(uid='test_get_todo_list').save() task1 = user.create_task('t1') task2 = user.create_task('t2') task3 = user.create_task('t3') self.assertEqual([], user.get_todo_list()) task1.status = STATUS.IN_PROGRESS task2.status = STATUS.IN_PROGRESS task3.status = STATUS.COMPLETED task1.save() task2.save() task3.save() step1_1 = StepInst(name='s1_1', status=STATUS.COMPLETED).save() step1_2 = StepInst(name='s1_2', status=STATUS.IN_PROGRESS).save() step2_1 = StepInst(name='s2_1', status=STATUS.READY_FOR_REVIEW).save() step2_2 = StepInst(name='s2_2', status=STATUS.SKIPPED).save() step3_1 = StepInst(name='s3_1', status=STATUS.IN_PROGRESS).save() step3_2 = StepInst(name='s3_2', status=STATUS.READY_FOR_REVIEW).save() task1.steps.connect(step1_1) task1.steps.connect(step1_2) task2.steps.connect(step2_1) task2.steps.connect(step2_2) task3.steps.connect(step3_1) task3.steps.connect(step3_2) todo_list = user.get_todo_list() todo_set = set(todo['task']['tid'] + todo['step']['sid'] for todo in todo_list) self.assertEqual(2, len(todo_set)) self.assertIn(task1.tid + step1_2.sid, todo_set) self.assertIn(task2.tid + step2_1.sid, todo_set)
def test_get_todo_list_with_role(self): user = UserNode(uid='test_get_todo_list_with_role').save() task = user.create_task('task', { 'status': STATUS.IN_PROGRESS, 'roles': ['teacher', 'student', 'parent'] }) step1 = StepInst(name='s1', status=STATUS.IN_PROGRESS, assignees=['student', 'parent'], reviewers=['student', 'teacher']).save() step2 = StepInst(name='s2', status=STATUS.READY_FOR_REVIEW, assignees=['student', 'parent'], reviewers=['student', 'teacher']).save() step3 = StepInst(name='s3', status=STATUS.IN_PROGRESS, assignees=['parent'], reviewers=['teacher']).save() step4 = StepInst(name='s4', status=STATUS.IN_PROGRESS, assignees=['parent'], reviewers=['teacher']).save() task.steps.connect(step1) task.steps.connect(step2) task.steps.connect(step3) task.steps.connect(step4) user.change_role(task, user, 'student') todo_list = user.get_todo_list() todo_set = set(todo['step']['sid'] for todo in todo_list) self.assertEqual(2, len(todo_set)) self.assertIn(step1.sid, todo_set) self.assertIn(step2.sid, todo_set)