Ejemplo n.º 1
0
    def test_send_tasks(self, module_mock, send_mock):
        task = ProgressReportTask(self.func_mock)
        module_mock().get_courses.return_value = self.courses

        task.send_tasks()
        module_mock.assert_called_with()
        module_mock().get_courses.assert_called_once_with()
        send_mock.assert_has_calls([call(self.course1.id), call(self.course2.id)])
Ejemplo n.º 2
0
    def test_send_tasks(self, module_mock, send_mock):
        task = ProgressReportTask(self.func_mock)
        module_mock().get_courses.return_value = self.courses

        task.send_tasks()
        module_mock.assert_called_with()
        module_mock().get_courses.assert_called_once_with()
        send_mock.assert_has_calls([call(self.course1.id), call(self.course2.id)])
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        """Handle command options."""
        course_id = options['course_id']
        task_id = options['task_id']

        if course_id is not None:
            try:
                course_id = CourseLocator.from_string(course_id)
            except InvalidKeyError:
                raise CommandError("'{}' is an invalid course_id".format(course_id))
            if not modulestore().get_course(course_id):
                raise CommandError("The specified course does not exist.")

        if len(args) != 1:
            raise CommandError(
                'Required subcommand, update, list, status, revoke or clear_cache.')
        command = args[0]
        task = ProgressReportTask(update_table_task)

        if command == "status":
            if task_id is None:
                raise CommandError('"status" subcommand required task_id.')
            task.show_task_status(task_id)
        elif command == "list":
            task.show_task_list()
        elif command == "revoke":
            if task_id is None:
                raise CommandError('"revoke" subcommand required task_id.')
            task.revoke_task(task_id)
        elif command == "update":
            if course_id:
                task.send_task(course_id.to_deprecated_string())
            else:
                task.send_tasks()
        elif command == "clear_cache":
            if course_id is None:
                raise CommandError('"clear_cache" subcommand required course_id.')
            state = TaskState("pgreport.tasks.update_table_task", course_id)
            state.delete_task_state()
        else:
            raise CommandError('Invalid subcommand.')