Commit a9c548c3 by sanfordstudent Committed by GitHub

Merge pull request #13728 from edx/sstudent/hack-instructor-task

Sstudent/hack instructor task
parents e0b38661 54d34e83
...@@ -39,8 +39,8 @@ from django.core.urlresolvers import reverse ...@@ -39,8 +39,8 @@ from django.core.urlresolvers import reverse
from bulk_email.models import CourseEmail, Optout from bulk_email.models import CourseEmail, Optout
from courseware.courses import get_course from courseware.courses import get_course
from openedx.core.lib.courses import course_image_url from openedx.core.lib.courses import course_image_url
from instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from instructor_task.subtasks import ( from lms.djangoapps.instructor_task.subtasks import (
SubtaskStatus, SubtaskStatus,
queue_subtasks_for_query, queue_subtasks_for_query,
check_subtask_is_valid, check_subtask_is_valid,
......
...@@ -21,7 +21,7 @@ from bulk_email.tasks import _get_source_address, _get_course_email_context ...@@ -21,7 +21,7 @@ from bulk_email.tasks import _get_source_address, _get_course_email_context
from openedx.core.djangoapps.course_groups.models import CourseCohort from openedx.core.djangoapps.course_groups.models import CourseCohort
from openedx.core.djangoapps.course_groups.cohorts import add_user_to_cohort from openedx.core.djangoapps.course_groups.cohorts import add_user_to_cohort
from courseware.tests.factories import StaffFactory, InstructorFactory from courseware.tests.factories import StaffFactory, InstructorFactory
from instructor_task.subtasks import update_subtask_status from lms.djangoapps.instructor_task.subtasks import update_subtask_status
from student.roles import CourseStaffRole from student.roles import CourseStaffRole
from student.models import CourseEnrollment from student.models import CourseEnrollment
from student.tests.factories import CourseEnrollmentFactory, UserFactory from student.tests.factories import CourseEnrollmentFactory, UserFactory
......
...@@ -16,8 +16,8 @@ from smtplib import SMTPDataError, SMTPServerDisconnected, SMTPConnectError ...@@ -16,8 +16,8 @@ from smtplib import SMTPDataError, SMTPServerDisconnected, SMTPConnectError
from bulk_email.models import CourseEmail, SEND_TO_MYSELF, BulkEmailFlag from bulk_email.models import CourseEmail, SEND_TO_MYSELF, BulkEmailFlag
from bulk_email.tasks import perform_delegate_email_batches, send_course_email from bulk_email.tasks import perform_delegate_email_batches, send_course_email
from instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from instructor_task.subtasks import ( from lms.djangoapps.instructor_task.subtasks import (
initialize_subtask_info, initialize_subtask_info,
SubtaskStatus, SubtaskStatus,
check_subtask_is_valid, check_subtask_is_valid,
...@@ -344,7 +344,7 @@ class TestEmailErrors(ModuleStoreTestCase): ...@@ -344,7 +344,7 @@ class TestEmailErrors(ModuleStoreTestCase):
bogus_email_id = 1001 bogus_email_id = 1001
to_list = ['test@test.com'] to_list = ['test@test.com']
global_email_context = {'course_title': 'dummy course'} global_email_context = {'course_title': 'dummy course'}
with patch('instructor_task.subtasks.InstructorTask.save') as mock_task_save: with patch('lms.djangoapps.instructor_task.subtasks.InstructorTask.save') as mock_task_save:
mock_task_save.side_effect = DatabaseError mock_task_save.side_effect = DatabaseError
with self.assertRaises(DatabaseError): with self.assertRaises(DatabaseError):
send_course_email(entry_id, bogus_email_id, to_list, global_email_context, subtask_status.to_dict()) send_course_email(entry_id, bogus_email_id, to_list, global_email_context, subtask_status.to_dict())
......
...@@ -35,11 +35,11 @@ from xmodule.modulestore.tests.factories import CourseFactory ...@@ -35,11 +35,11 @@ from xmodule.modulestore.tests.factories import CourseFactory
from bulk_email.models import CourseEmail, Optout, SEND_TO_MYSELF, SEND_TO_STAFF, SEND_TO_LEARNERS from bulk_email.models import CourseEmail, Optout, SEND_TO_MYSELF, SEND_TO_STAFF, SEND_TO_LEARNERS
from bulk_email.tasks import _get_course_email_context from bulk_email.tasks import _get_course_email_context
from instructor_task.tasks import send_bulk_course_email from lms.djangoapps.instructor_task.tasks import send_bulk_course_email
from instructor_task.subtasks import update_subtask_status, SubtaskStatus from lms.djangoapps.instructor_task.subtasks import update_subtask_status, SubtaskStatus
from instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from instructor_task.tests.test_base import InstructorTaskCourseTestCase from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskCourseTestCase
from instructor_task.tests.factories import InstructorTaskFactory from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
......
...@@ -66,7 +66,7 @@ from openedx.core.djangoapps.signals.signals import COURSE_CERT_AWARDED ...@@ -66,7 +66,7 @@ from openedx.core.djangoapps.signals.signals import COURSE_CERT_AWARDED
from badges.events.course_complete import course_badge_check from badges.events.course_complete import course_badge_check
from badges.events.course_meta import completion_check, course_group_check from badges.events.course_meta import completion_check, course_group_check
from config_models.models import ConfigurationModel from config_models.models import ConfigurationModel
from instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from util.milestones_helpers import fulfill_course_milestone, is_prerequisite_courses_enabled from util.milestones_helpers import fulfill_course_milestone, is_prerequisite_courses_enabled
from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, NoneToEmptyManager from openedx.core.djangoapps.xmodule_django.models import CourseKeyField, NoneToEmptyManager
......
...@@ -24,7 +24,7 @@ from certificates.tests.factories import ( ...@@ -24,7 +24,7 @@ from certificates.tests.factories import (
CertificateInvalidationFactory, CertificateInvalidationFactory,
GeneratedCertificateFactory GeneratedCertificateFactory
) )
from instructor_task.tests.factories import InstructorTaskFactory from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
from student.tests.factories import AdminFactory, UserFactory from student.tests.factories import AdminFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
......
...@@ -22,7 +22,7 @@ from django.utils.translation import ugettext as _ ...@@ -22,7 +22,7 @@ from django.utils.translation import ugettext as _
from certificates import api from certificates import api
from certificates.models import CertificateInvalidation from certificates.models import CertificateInvalidation
from courseware.access import has_access from courseware.access import has_access
from instructor_task.api import generate_certificates_for_students from lms.djangoapps.instructor_task.api import generate_certificates_for_students
from opaque_keys import InvalidKeyError from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
......
...@@ -58,12 +58,12 @@ from xmodule.fields import Date ...@@ -58,12 +58,12 @@ from xmodule.fields import Date
from courseware.models import StudentFieldOverride from courseware.models import StudentFieldOverride
import instructor_task.api import lms.djangoapps.instructor_task.api
import lms.djangoapps.instructor.views.api import lms.djangoapps.instructor.views.api
from lms.djangoapps.instructor.views.api import require_finance_admin from lms.djangoapps.instructor.views.api import require_finance_admin
from lms.djangoapps.instructor.tests.utils import FakeContentTask, FakeEmail, FakeEmailInfo from lms.djangoapps.instructor.tests.utils import FakeContentTask, FakeEmail, FakeEmailInfo
from lms.djangoapps.instructor.views.api import _split_input_list, common_exceptions_400, generate_unique_password from lms.djangoapps.instructor.views.api import _split_input_list, common_exceptions_400, generate_unique_password
from instructor_task.api_helper import AlreadyRunningError from lms.djangoapps.instructor_task.api_helper import AlreadyRunningError
from certificates.tests.factories import GeneratedCertificateFactory from certificates.tests.factories import GeneratedCertificateFactory
from certificates.models import CertificateStatuses from certificates.models import CertificateStatuses
...@@ -86,37 +86,37 @@ REPORTS_DATA = ( ...@@ -86,37 +86,37 @@ REPORTS_DATA = (
{ {
'report_type': 'grade', 'report_type': 'grade',
'instructor_api_endpoint': 'calculate_grades_csv', 'instructor_api_endpoint': 'calculate_grades_csv',
'task_api_endpoint': 'instructor_task.api.submit_calculate_grades_csv', 'task_api_endpoint': 'lms.djangoapps.instructor_task.api.submit_calculate_grades_csv',
'extra_instructor_api_kwargs': {} 'extra_instructor_api_kwargs': {}
}, },
{ {
'report_type': 'enrolled learner profile', 'report_type': 'enrolled learner profile',
'instructor_api_endpoint': 'get_students_features', 'instructor_api_endpoint': 'get_students_features',
'task_api_endpoint': 'instructor_task.api.submit_calculate_students_features_csv', 'task_api_endpoint': 'lms.djangoapps.instructor_task.api.submit_calculate_students_features_csv',
'extra_instructor_api_kwargs': {'csv': '/csv'} 'extra_instructor_api_kwargs': {'csv': '/csv'}
}, },
{ {
'report_type': 'detailed enrollment', 'report_type': 'detailed enrollment',
'instructor_api_endpoint': 'get_enrollment_report', 'instructor_api_endpoint': 'get_enrollment_report',
'task_api_endpoint': 'instructor_task.api.submit_detailed_enrollment_features_csv', 'task_api_endpoint': 'lms.djangoapps.instructor_task.api.submit_detailed_enrollment_features_csv',
'extra_instructor_api_kwargs': {} 'extra_instructor_api_kwargs': {}
}, },
{ {
'report_type': 'enrollment', 'report_type': 'enrollment',
'instructor_api_endpoint': 'get_students_who_may_enroll', 'instructor_api_endpoint': 'get_students_who_may_enroll',
'task_api_endpoint': 'instructor_task.api.submit_calculate_may_enroll_csv', 'task_api_endpoint': 'lms.djangoapps.instructor_task.api.submit_calculate_may_enroll_csv',
'extra_instructor_api_kwargs': {}, 'extra_instructor_api_kwargs': {},
}, },
{ {
'report_type': 'proctored exam results', 'report_type': 'proctored exam results',
'instructor_api_endpoint': 'get_proctored_exam_results', 'instructor_api_endpoint': 'get_proctored_exam_results',
'task_api_endpoint': 'instructor_task.api.submit_proctored_exam_results_report', 'task_api_endpoint': 'lms.djangoapps.instructor_task.api.submit_proctored_exam_results_report',
'extra_instructor_api_kwargs': {}, 'extra_instructor_api_kwargs': {},
}, },
{ {
'report_type': 'problem responses', 'report_type': 'problem responses',
'instructor_api_endpoint': 'get_problem_responses', 'instructor_api_endpoint': 'get_problem_responses',
'task_api_endpoint': 'instructor_task.api.submit_calculate_problem_responses_csv', 'task_api_endpoint': 'lms.djangoapps.instructor_task.api.submit_calculate_problem_responses_csv',
'extra_instructor_api_kwargs': {}, 'extra_instructor_api_kwargs': {},
} }
) )
...@@ -126,7 +126,7 @@ EXECUTIVE_SUMMARY_DATA = ( ...@@ -126,7 +126,7 @@ EXECUTIVE_SUMMARY_DATA = (
{ {
'report_type': 'executive summary', 'report_type': 'executive summary',
'instructor_api_endpoint': 'get_exec_summary_report', 'instructor_api_endpoint': 'get_exec_summary_report',
'task_api_endpoint': 'instructor_task.api.submit_executive_summary_report', 'task_api_endpoint': 'lms.djangoapps.instructor_task.api.submit_executive_summary_report',
'extra_instructor_api_kwargs': {} 'extra_instructor_api_kwargs': {}
}, },
) )
...@@ -2657,7 +2657,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -2657,7 +2657,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
kwargs={'course_id': unicode(self.course.id)} kwargs={'course_id': unicode(self.course.id)}
) )
with patch('instructor_task.api.submit_calculate_problem_responses_csv') as submit_task_function: with patch('lms.djangoapps.instructor_task.api.submit_calculate_problem_responses_csv') as submit_task_function:
error = AlreadyRunningError() error = AlreadyRunningError()
submit_task_function.side_effect = error submit_task_function.side_effect = error
response = self.client.post(url, {}) response = self.client.post(url, {})
...@@ -2737,7 +2737,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -2737,7 +2737,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
self.assertIn('status', res_json) self.assertIn('status', res_json)
self.assertNotIn('currently being created', res_json['status']) self.assertNotIn('currently being created', res_json['status'])
# CSV generation already in progress: # CSV generation already in progress:
with patch('instructor_task.api.submit_calculate_may_enroll_csv') as submit_task_function: with patch('lms.djangoapps.instructor_task.api.submit_calculate_may_enroll_csv') as submit_task_function:
error = AlreadyRunningError() error = AlreadyRunningError()
submit_task_function.side_effect = error submit_task_function.side_effect = error
response = self.client.post(url, {}) response = self.client.post(url, {})
...@@ -2760,7 +2760,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -2760,7 +2760,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
self.assertIn('status', res_json) self.assertIn('status', res_json)
self.assertNotIn('currently being created', res_json['status']) self.assertNotIn('currently being created', res_json['status'])
# CSV generation already in progress: # CSV generation already in progress:
with patch('instructor_task.api.submit_proctored_exam_results_report') as submit_task_function: with patch('lms.djangoapps.instructor_task.api.submit_proctored_exam_results_report') as submit_task_function:
error = AlreadyRunningError() error = AlreadyRunningError()
submit_task_function.side_effect = error submit_task_function.side_effect = error
response = self.client.post(url, {}) response = self.client.post(url, {})
...@@ -2974,7 +2974,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -2974,7 +2974,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
def test_list_report_downloads(self): def test_list_report_downloads(self):
url = reverse('list_report_downloads', kwargs={'course_id': self.course.id.to_deprecated_string()}) url = reverse('list_report_downloads', kwargs={'course_id': self.course.id.to_deprecated_string()})
with patch('instructor_task.models.DjangoStorageReportStore.links_for') as mock_links_for: with patch('lms.djangoapps.instructor_task.models.DjangoStorageReportStore.links_for') as mock_links_for:
mock_links_for.return_value = [ mock_links_for.return_value = [
('mock_file_name_1', 'https://1.mock.url'), ('mock_file_name_1', 'https://1.mock.url'),
('mock_file_name_2', 'https://2.mock.url'), ('mock_file_name_2', 'https://2.mock.url'),
...@@ -3064,7 +3064,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -3064,7 +3064,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
def test_get_ora2_responses_success(self): def test_get_ora2_responses_success(self):
url = reverse('export_ora2_data', kwargs={'course_id': unicode(self.course.id)}) url = reverse('export_ora2_data', kwargs={'course_id': unicode(self.course.id)})
with patch('instructor_task.api.submit_export_ora2_data') as mock_submit_ora2_task: with patch('lms.djangoapps.instructor_task.api.submit_export_ora2_data') as mock_submit_ora2_task:
mock_submit_ora2_task.return_value = True mock_submit_ora2_task.return_value = True
response = self.client.post(url, {}) response = self.client.post(url, {})
success_status = "The ORA data report is being generated." success_status = "The ORA data report is being generated."
...@@ -3073,7 +3073,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment ...@@ -3073,7 +3073,7 @@ class TestInstructorAPILevelsDataDump(SharedModuleStoreTestCase, LoginEnrollment
def test_get_ora2_responses_already_running(self): def test_get_ora2_responses_already_running(self):
url = reverse('export_ora2_data', kwargs={'course_id': unicode(self.course.id)}) url = reverse('export_ora2_data', kwargs={'course_id': unicode(self.course.id)})
with patch('instructor_task.api.submit_export_ora2_data') as mock_submit_ora2_task: with patch('lms.djangoapps.instructor_task.api.submit_export_ora2_data') as mock_submit_ora2_task:
mock_submit_ora2_task.side_effect = AlreadyRunningError() mock_submit_ora2_task.side_effect = AlreadyRunningError()
response = self.client.post(url, {}) response = self.client.post(url, {})
already_running_status = "An ORA data report generation task is already in progress." already_running_status = "An ORA data report generation task is already in progress."
...@@ -3170,7 +3170,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes ...@@ -3170,7 +3170,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes
) )
# mock out the function which should be called to execute the action. # mock out the function which should be called to execute the action.
@patch.object(instructor_task.api, 'submit_reset_problem_attempts_for_all_students') @patch.object(lms.djangoapps.instructor_task.api, 'submit_reset_problem_attempts_for_all_students')
def test_reset_student_attempts_all(self, act): def test_reset_student_attempts_all(self, act):
""" Test reset all student attempts. """ """ Test reset all student attempts. """
url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()})
...@@ -3220,7 +3220,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes ...@@ -3220,7 +3220,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes
}) })
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
@patch.object(instructor_task.api, 'submit_rescore_problem_for_student') @patch.object(lms.djangoapps.instructor_task.api, 'submit_rescore_problem_for_student')
def test_rescore_problem_single(self, act): def test_rescore_problem_single(self, act):
""" Test rescoring of a single student. """ """ Test rescoring of a single student. """
url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()}) url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()})
...@@ -3231,7 +3231,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes ...@@ -3231,7 +3231,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertTrue(act.called) self.assertTrue(act.called)
@patch.object(instructor_task.api, 'submit_rescore_problem_for_student') @patch.object(lms.djangoapps.instructor_task.api, 'submit_rescore_problem_for_student')
def test_rescore_problem_single_from_uname(self, act): def test_rescore_problem_single_from_uname(self, act):
""" Test rescoring of a single student. """ """ Test rescoring of a single student. """
url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()}) url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()})
...@@ -3242,7 +3242,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes ...@@ -3242,7 +3242,7 @@ class TestInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginEnrollmentTes
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertTrue(act.called) self.assertTrue(act.called)
@patch.object(instructor_task.api, 'submit_rescore_problem_for_all_students') @patch.object(lms.djangoapps.instructor_task.api, 'submit_rescore_problem_for_all_students')
def test_rescore_problem_all(self, act): def test_rescore_problem_all(self, act):
""" Test rescoring for all students. """ """ Test rescoring for all students. """
url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()}) url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()})
...@@ -3395,7 +3395,7 @@ class TestEntranceExamInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginE ...@@ -3395,7 +3395,7 @@ class TestEntranceExamInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginE
) )
# mock out the function which should be called to execute the action. # mock out the function which should be called to execute the action.
@patch.object(instructor_task.api, 'submit_reset_problem_attempts_in_entrance_exam') @patch.object(lms.djangoapps.instructor_task.api, 'submit_reset_problem_attempts_in_entrance_exam')
def test_reset_entrance_exam_all_student_attempts(self, act): def test_reset_entrance_exam_all_student_attempts(self, act):
""" Test reset all student attempts for entrance exam. """ """ Test reset all student attempts for entrance exam. """
url = reverse('reset_student_attempts_for_entrance_exam', url = reverse('reset_student_attempts_for_entrance_exam',
...@@ -3451,7 +3451,7 @@ class TestEntranceExamInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginE ...@@ -3451,7 +3451,7 @@ class TestEntranceExamInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginE
}) })
self.assertEqual(response.status_code, 400) self.assertEqual(response.status_code, 400)
@patch.object(instructor_task.api, 'submit_rescore_entrance_exam_for_student') @patch.object(lms.djangoapps.instructor_task.api, 'submit_rescore_entrance_exam_for_student')
def test_rescore_entrance_exam_single_student(self, act): def test_rescore_entrance_exam_single_student(self, act):
""" Test re-scoring of entrance exam for single student. """ """ Test re-scoring of entrance exam for single student. """
url = reverse('rescore_entrance_exam', kwargs={'course_id': unicode(self.course.id)}) url = reverse('rescore_entrance_exam', kwargs={'course_id': unicode(self.course.id)})
...@@ -3728,7 +3728,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC ...@@ -3728,7 +3728,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC
self.tasks = [self.FakeTask(mock_factory.mock_get_task_completion_info) for _ in xrange(7)] self.tasks = [self.FakeTask(mock_factory.mock_get_task_completion_info) for _ in xrange(7)]
self.tasks[-1].make_invalid_output() self.tasks[-1].make_invalid_output()
@patch.object(instructor_task.api, 'get_running_instructor_tasks') @patch.object(lms.djangoapps.instructor_task.api, 'get_running_instructor_tasks')
def test_list_instructor_tasks_running(self, act): def test_list_instructor_tasks_running(self, act):
""" Test list of all running tasks. """ """ Test list of all running tasks. """
act.return_value = self.tasks act.return_value = self.tasks
...@@ -3749,7 +3749,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC ...@@ -3749,7 +3749,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC
self.assertDictEqual(exp_task, act_task) self.assertDictEqual(exp_task, act_task)
self.assertEqual(actual_tasks, expected_tasks) self.assertEqual(actual_tasks, expected_tasks)
@patch.object(instructor_task.api, 'get_instructor_task_history') @patch.object(lms.djangoapps.instructor_task.api, 'get_instructor_task_history')
def test_list_background_email_tasks(self, act): def test_list_background_email_tasks(self, act):
"""Test list of background email tasks.""" """Test list of background email tasks."""
act.return_value = self.tasks act.return_value = self.tasks
...@@ -3770,7 +3770,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC ...@@ -3770,7 +3770,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC
self.assertDictEqual(exp_task, act_task) self.assertDictEqual(exp_task, act_task)
self.assertEqual(actual_tasks, expected_tasks) self.assertEqual(actual_tasks, expected_tasks)
@patch.object(instructor_task.api, 'get_instructor_task_history') @patch.object(lms.djangoapps.instructor_task.api, 'get_instructor_task_history')
def test_list_instructor_tasks_problem(self, act): def test_list_instructor_tasks_problem(self, act):
""" Test list task history for problem. """ """ Test list task history for problem. """
act.return_value = self.tasks act.return_value = self.tasks
...@@ -3793,7 +3793,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC ...@@ -3793,7 +3793,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC
self.assertDictEqual(exp_task, act_task) self.assertDictEqual(exp_task, act_task)
self.assertEqual(actual_tasks, expected_tasks) self.assertEqual(actual_tasks, expected_tasks)
@patch.object(instructor_task.api, 'get_instructor_task_history') @patch.object(lms.djangoapps.instructor_task.api, 'get_instructor_task_history')
def test_list_instructor_tasks_problem_student(self, act): def test_list_instructor_tasks_problem_student(self, act):
""" Test list task history for problem AND student. """ """ Test list task history for problem AND student. """
act.return_value = self.tasks act.return_value = self.tasks
...@@ -3820,7 +3820,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC ...@@ -3820,7 +3820,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC
@attr(shard=1) @attr(shard=1)
@patch.object(instructor_task.api, 'get_instructor_task_history', autospec=True) @patch.object(lms.djangoapps.instructor_task.api, 'get_instructor_task_history', autospec=True)
class TestInstructorEmailContentList(SharedModuleStoreTestCase, LoginEnrollmentTestCase): class TestInstructorEmailContentList(SharedModuleStoreTestCase, LoginEnrollmentTestCase):
""" """
Test the instructor email content history endpoint. Test the instructor email content history endpoint.
...@@ -4954,7 +4954,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase): ...@@ -4954,7 +4954,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase):
response = self.call_add_users_to_cohorts('') response = self.call_add_users_to_cohorts('')
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 403)
@patch('lms.djangoapps.instructor.views.api.instructor_task.api.submit_cohort_students') @patch('lms.djangoapps.instructor.views.api.lms.djangoapps.instructor_task.api.submit_cohort_students')
@patch('lms.djangoapps.instructor.views.api.store_uploaded_file') @patch('lms.djangoapps.instructor.views.api.store_uploaded_file')
def test_success_username(self, mock_store_upload, mock_cohort_task): def test_success_username(self, mock_store_upload, mock_cohort_task):
""" """
...@@ -4965,7 +4965,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase): ...@@ -4965,7 +4965,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase):
'username,cohort\nfoo_username,bar_cohort', mock_store_upload, mock_cohort_task 'username,cohort\nfoo_username,bar_cohort', mock_store_upload, mock_cohort_task
) )
@patch('lms.djangoapps.instructor.views.api.instructor_task.api.submit_cohort_students') @patch('lms.djangoapps.instructor.views.api.lms.djangoapps.instructor_task.api.submit_cohort_students')
@patch('lms.djangoapps.instructor.views.api.store_uploaded_file') @patch('lms.djangoapps.instructor.views.api.store_uploaded_file')
def test_success_email(self, mock_store_upload, mock_cohort_task): def test_success_email(self, mock_store_upload, mock_cohort_task):
""" """
...@@ -4976,7 +4976,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase): ...@@ -4976,7 +4976,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase):
'email,cohort\nfoo_email,bar_cohort', mock_store_upload, mock_cohort_task 'email,cohort\nfoo_email,bar_cohort', mock_store_upload, mock_cohort_task
) )
@patch('lms.djangoapps.instructor.views.api.instructor_task.api.submit_cohort_students') @patch('lms.djangoapps.instructor.views.api.lms.djangoapps.instructor_task.api.submit_cohort_students')
@patch('lms.djangoapps.instructor.views.api.store_uploaded_file') @patch('lms.djangoapps.instructor.views.api.store_uploaded_file')
def test_success_username_and_email(self, mock_store_upload, mock_cohort_task): def test_success_username_and_email(self, mock_store_upload, mock_cohort_task):
""" """
...@@ -4987,7 +4987,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase): ...@@ -4987,7 +4987,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase):
'username,email,cohort\nfoo_username,bar_email,baz_cohort', mock_store_upload, mock_cohort_task 'username,email,cohort\nfoo_username,bar_email,baz_cohort', mock_store_upload, mock_cohort_task
) )
@patch('lms.djangoapps.instructor.views.api.instructor_task.api.submit_cohort_students') @patch('lms.djangoapps.instructor.views.api.lms.djangoapps.instructor_task.api.submit_cohort_students')
@patch('lms.djangoapps.instructor.views.api.store_uploaded_file') @patch('lms.djangoapps.instructor.views.api.store_uploaded_file')
def test_success_carriage_return(self, mock_store_upload, mock_cohort_task): def test_success_carriage_return(self, mock_store_upload, mock_cohort_task):
""" """
...@@ -4998,7 +4998,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase): ...@@ -4998,7 +4998,7 @@ class TestBulkCohorting(SharedModuleStoreTestCase):
'username,email,cohort\rfoo_username,bar_email,baz_cohort', mock_store_upload, mock_cohort_task 'username,email,cohort\rfoo_username,bar_email,baz_cohort', mock_store_upload, mock_cohort_task
) )
@patch('lms.djangoapps.instructor.views.api.instructor_task.api.submit_cohort_students') @patch('lms.djangoapps.instructor.views.api.lms.djangoapps.instructor_task.api.submit_cohort_students')
@patch('lms.djangoapps.instructor.views.api.store_uploaded_file') @patch('lms.djangoapps.instructor.views.api.store_uploaded_file')
def test_success_carriage_return_line_feed(self, mock_store_upload, mock_cohort_task): def test_success_carriage_return_line_feed(self, mock_store_upload, mock_cohort_task):
""" """
......
...@@ -65,9 +65,9 @@ from student.models import ( ...@@ -65,9 +65,9 @@ from student.models import (
ENROLLED_TO_ENROLLED, ENROLLED_TO_UNENROLLED, UNENROLLED_TO_ENROLLED, ENROLLED_TO_ENROLLED, ENROLLED_TO_UNENROLLED, UNENROLLED_TO_ENROLLED,
UNENROLLED_TO_UNENROLLED, ALLOWEDTOENROLL_TO_UNENROLLED, DEFAULT_TRANSITION_STATE UNENROLLED_TO_UNENROLLED, ALLOWEDTOENROLL_TO_UNENROLLED, DEFAULT_TRANSITION_STATE
) )
import instructor_task.api import lms.djangoapps.instructor_task.api
from instructor_task.api_helper import AlreadyRunningError from lms.djangoapps.instructor_task.api_helper import AlreadyRunningError
from instructor_task.models import ReportStore from lms.djangoapps.instructor_task.models import ReportStore
import lms.djangoapps.instructor.enrollment as enrollment import lms.djangoapps.instructor.enrollment as enrollment
from lms.djangoapps.instructor.enrollment import ( from lms.djangoapps.instructor.enrollment import (
get_user_email_language, get_user_email_language,
...@@ -967,7 +967,7 @@ def get_problem_responses(request, course_id): ...@@ -967,7 +967,7 @@ def get_problem_responses(request, course_id):
return JsonResponseBadRequest(_("Could not find problem with this location.")) return JsonResponseBadRequest(_("Could not find problem with this location."))
try: try:
instructor_task.api.submit_calculate_problem_responses_csv(request, course_key, problem_location) lms.djangoapps.instructor_task.api.submit_calculate_problem_responses_csv(request, course_key, problem_location)
success_status = _( success_status = _(
"The problem responses report is being created." "The problem responses report is being created."
" To view the status of the report, see Pending Tasks below." " To view the status of the report, see Pending Tasks below."
...@@ -1261,7 +1261,11 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red ...@@ -1261,7 +1261,11 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red
return JsonResponse(response_payload) return JsonResponse(response_payload)
else: else:
try: try:
instructor_task.api.submit_calculate_students_features_csv(request, course_key, query_features) lms.djangoapps.instructor_task.api.submit_calculate_students_features_csv(
request,
course_key,
query_features
)
success_status = _("The enrolled learner profile report is being created." success_status = _("The enrolled learner profile report is being created."
" To view the status of the report, see Pending Tasks below.") " To view the status of the report, see Pending Tasks below.")
return JsonResponse({"status": success_status}) return JsonResponse({"status": success_status})
...@@ -1290,7 +1294,7 @@ def get_students_who_may_enroll(request, course_id): ...@@ -1290,7 +1294,7 @@ def get_students_who_may_enroll(request, course_id):
course_key = CourseKey.from_string(course_id) course_key = CourseKey.from_string(course_id)
query_features = ['email'] query_features = ['email']
try: try:
instructor_task.api.submit_calculate_may_enroll_csv(request, course_key, query_features) lms.djangoapps.instructor_task.api.submit_calculate_may_enroll_csv(request, course_key, query_features)
success_status = _( success_status = _(
"The enrollment report is being created. This report contains" "The enrollment report is being created. This report contains"
" information about learners who can enroll in the course." " information about learners who can enroll in the course."
...@@ -1345,7 +1349,7 @@ def add_users_to_cohorts(request, course_id): ...@@ -1345,7 +1349,7 @@ def add_users_to_cohorts(request, course_id):
validator=validator validator=validator
) )
# The task will assume the default file storage. # The task will assume the default file storage.
instructor_task.api.submit_cohort_students(request, course_key, filename) lms.djangoapps.instructor_task.api.submit_cohort_students(request, course_key, filename)
except (FileValidationException, PermissionDenied) as err: except (FileValidationException, PermissionDenied) as err:
return JsonResponse({"error": unicode(err)}, status=400) return JsonResponse({"error": unicode(err)}, status=400)
...@@ -1393,7 +1397,7 @@ def get_enrollment_report(request, course_id): ...@@ -1393,7 +1397,7 @@ def get_enrollment_report(request, course_id):
""" """
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
try: try:
instructor_task.api.submit_detailed_enrollment_features_csv(request, course_key) lms.djangoapps.instructor_task.api.submit_detailed_enrollment_features_csv(request, course_key)
success_status = _("The detailed enrollment report is being created." success_status = _("The detailed enrollment report is being created."
" To view the status of the report, see Pending Tasks below.") " To view the status of the report, see Pending Tasks below.")
return JsonResponse({"status": success_status}) return JsonResponse({"status": success_status})
...@@ -1418,7 +1422,7 @@ def get_exec_summary_report(request, course_id): ...@@ -1418,7 +1422,7 @@ def get_exec_summary_report(request, course_id):
""" """
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
try: try:
instructor_task.api.submit_executive_summary_report(request, course_key) lms.djangoapps.instructor_task.api.submit_executive_summary_report(request, course_key)
status_response = _("The executive summary report is being created." status_response = _("The executive summary report is being created."
" To view the status of the report, see Pending Tasks below.") " To view the status of the report, see Pending Tasks below.")
except AlreadyRunningError: except AlreadyRunningError:
...@@ -1443,7 +1447,7 @@ def get_course_survey_results(request, course_id): ...@@ -1443,7 +1447,7 @@ def get_course_survey_results(request, course_id):
""" """
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
try: try:
instructor_task.api.submit_course_survey_report(request, course_key) lms.djangoapps.instructor_task.api.submit_course_survey_report(request, course_key)
status_response = _("The survey report is being created." status_response = _("The survey report is being created."
" To view the status of the report, see Pending Tasks below.") " To view the status of the report, see Pending Tasks below.")
except AlreadyRunningError: except AlreadyRunningError:
...@@ -1479,7 +1483,7 @@ def get_proctored_exam_results(request, course_id): ...@@ -1479,7 +1483,7 @@ def get_proctored_exam_results(request, course_id):
course_key = CourseKey.from_string(course_id) course_key = CourseKey.from_string(course_id)
try: try:
instructor_task.api.submit_proctored_exam_results_report(request, course_key, query_features) lms.djangoapps.instructor_task.api.submit_proctored_exam_results_report(request, course_key, query_features)
status_response = _("The proctored exam results report is being created." status_response = _("The proctored exam results report is being created."
" To view the status of the report, see Pending Tasks below.") " To view the status of the report, see Pending Tasks below.")
except AlreadyRunningError: except AlreadyRunningError:
...@@ -1978,7 +1982,7 @@ def reset_student_attempts(request, course_id): ...@@ -1978,7 +1982,7 @@ def reset_student_attempts(request, course_id):
return HttpResponse(error_msg, status=500) return HttpResponse(error_msg, status=500)
response_payload['student'] = student_identifier response_payload['student'] = student_identifier
elif all_students: elif all_students:
instructor_task.api.submit_reset_problem_attempts_for_all_students(request, module_state_key) lms.djangoapps.instructor_task.api.submit_reset_problem_attempts_for_all_students(request, module_state_key)
response_payload['task'] = 'created' response_payload['task'] = 'created'
response_payload['student'] = 'All Students' response_payload['student'] = 'All Students'
else: else:
...@@ -2044,9 +2048,17 @@ def reset_student_attempts_for_entrance_exam(request, course_id): # pylint: dis ...@@ -2044,9 +2048,17 @@ def reset_student_attempts_for_entrance_exam(request, course_id): # pylint: dis
try: try:
entrance_exam_key = course_id.make_usage_key_from_deprecated_string(course.entrance_exam_id) entrance_exam_key = course_id.make_usage_key_from_deprecated_string(course.entrance_exam_id)
if delete_module: if delete_module:
instructor_task.api.submit_delete_entrance_exam_state_for_student(request, entrance_exam_key, student) lms.djangoapps.instructor_task.api.submit_delete_entrance_exam_state_for_student(
request,
entrance_exam_key,
student
)
else: else:
instructor_task.api.submit_reset_problem_attempts_in_entrance_exam(request, entrance_exam_key, student) lms.djangoapps.instructor_task.api.submit_reset_problem_attempts_in_entrance_exam(
request,
entrance_exam_key,
student
)
except InvalidKeyError: except InvalidKeyError:
return HttpResponseBadRequest(_("Course has no valid entrance exam section.")) return HttpResponseBadRequest(_("Course has no valid entrance exam section."))
...@@ -2100,10 +2112,10 @@ def rescore_problem(request, course_id): ...@@ -2100,10 +2112,10 @@ def rescore_problem(request, course_id):
if student: if student:
response_payload['student'] = student_identifier response_payload['student'] = student_identifier
instructor_task.api.submit_rescore_problem_for_student(request, module_state_key, student) lms.djangoapps.instructor_task.api.submit_rescore_problem_for_student(request, module_state_key, student)
response_payload['task'] = 'created' response_payload['task'] = 'created'
elif all_students: elif all_students:
instructor_task.api.submit_rescore_problem_for_all_students(request, module_state_key) lms.djangoapps.instructor_task.api.submit_rescore_problem_for_all_students(request, module_state_key)
response_payload['task'] = 'created' response_payload['task'] = 'created'
else: else:
return HttpResponseBadRequest() return HttpResponseBadRequest()
...@@ -2160,7 +2172,7 @@ def rescore_entrance_exam(request, course_id): ...@@ -2160,7 +2172,7 @@ def rescore_entrance_exam(request, course_id):
response_payload['student'] = student_identifier response_payload['student'] = student_identifier
else: else:
response_payload['student'] = _("All Students") response_payload['student'] = _("All Students")
instructor_task.api.submit_rescore_entrance_exam_for_student(request, entrance_exam_key, student) lms.djangoapps.instructor_task.api.submit_rescore_entrance_exam_for_student(request, entrance_exam_key, student)
response_payload['task'] = 'created' response_payload['task'] = 'created'
return JsonResponse(response_payload) return JsonResponse(response_payload)
...@@ -2176,7 +2188,10 @@ def list_background_email_tasks(request, course_id): # pylint: disable=unused-a ...@@ -2176,7 +2188,10 @@ def list_background_email_tasks(request, course_id): # pylint: disable=unused-a
course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
task_type = 'bulk_course_email' task_type = 'bulk_course_email'
# Specifying for the history of a single task type # Specifying for the history of a single task type
tasks = instructor_task.api.get_instructor_task_history(course_id, task_type=task_type) tasks = lms.djangoapps.instructor_task.api.get_instructor_task_history(
course_id,
task_type=task_type
)
response_payload = { response_payload = {
'tasks': map(extract_task_features, tasks), 'tasks': map(extract_task_features, tasks),
...@@ -2195,7 +2210,7 @@ def list_email_content(request, course_id): # pylint: disable=unused-argument ...@@ -2195,7 +2210,7 @@ def list_email_content(request, course_id): # pylint: disable=unused-argument
course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
task_type = 'bulk_course_email' task_type = 'bulk_course_email'
# First get tasks list of bulk emails sent # First get tasks list of bulk emails sent
emails = instructor_task.api.get_instructor_task_history(course_id, task_type=task_type) emails = lms.djangoapps.instructor_task.api.get_instructor_task_history(course_id, task_type=task_type)
response_payload = { response_payload = {
'emails': map(extract_email_features, emails), 'emails': map(extract_email_features, emails),
...@@ -2235,13 +2250,13 @@ def list_instructor_tasks(request, course_id): ...@@ -2235,13 +2250,13 @@ def list_instructor_tasks(request, course_id):
return HttpResponseBadRequest() return HttpResponseBadRequest()
if student: if student:
# Specifying for a single student's history on this problem # Specifying for a single student's history on this problem
tasks = instructor_task.api.get_instructor_task_history(course_id, module_state_key, student) tasks = lms.djangoapps.instructor_task.api.get_instructor_task_history(course_id, module_state_key, student)
else: else:
# Specifying for single problem's history # Specifying for single problem's history
tasks = instructor_task.api.get_instructor_task_history(course_id, module_state_key) tasks = lms.djangoapps.instructor_task.api.get_instructor_task_history(course_id, module_state_key)
else: else:
# If no problem or student, just get currently running tasks # If no problem or student, just get currently running tasks
tasks = instructor_task.api.get_running_instructor_tasks(course_id) tasks = lms.djangoapps.instructor_task.api.get_running_instructor_tasks(course_id)
response_payload = { response_payload = {
'tasks': map(extract_task_features, tasks), 'tasks': map(extract_task_features, tasks),
...@@ -2273,10 +2288,17 @@ def list_entrance_exam_instructor_tasks(request, course_id): # pylint: disable= ...@@ -2273,10 +2288,17 @@ def list_entrance_exam_instructor_tasks(request, course_id): # pylint: disable=
return HttpResponseBadRequest(_("Course has no valid entrance exam section.")) return HttpResponseBadRequest(_("Course has no valid entrance exam section."))
if student: if student:
# Specifying for a single student's entrance exam history # Specifying for a single student's entrance exam history
tasks = instructor_task.api.get_entrance_exam_instructor_task_history(course_id, entrance_exam_key, student) tasks = lms.djangoapps.instructor_task.api.get_entrance_exam_instructor_task_history(
course_id,
entrance_exam_key,
student
)
else: else:
# Specifying for all student's entrance exam history # Specifying for all student's entrance exam history
tasks = instructor_task.api.get_entrance_exam_instructor_task_history(course_id, entrance_exam_key) tasks = lms.djangoapps.instructor_task.api.get_entrance_exam_instructor_task_history(
course_id,
entrance_exam_key
)
response_payload = { response_payload = {
'tasks': map(extract_task_features, tasks), 'tasks': map(extract_task_features, tasks),
...@@ -2336,7 +2358,7 @@ def export_ora2_data(request, course_id): ...@@ -2336,7 +2358,7 @@ def export_ora2_data(request, course_id):
""" """
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
try: try:
instructor_task.api.submit_export_ora2_data(request, course_key) lms.djangoapps.instructor_task.api.submit_export_ora2_data(request, course_key)
success_status = _("The ORA data report is being generated.") success_status = _("The ORA data report is being generated.")
return JsonResponse({"status": success_status}) return JsonResponse({"status": success_status})
...@@ -2362,7 +2384,7 @@ def calculate_grades_csv(request, course_id): ...@@ -2362,7 +2384,7 @@ def calculate_grades_csv(request, course_id):
""" """
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
try: try:
instructor_task.api.submit_calculate_grades_csv(request, course_key) lms.djangoapps.instructor_task.api.submit_calculate_grades_csv(request, course_key)
success_status = _("The grade report is being created." success_status = _("The grade report is being created."
" To view the status of the report, see Pending Tasks below.") " To view the status of the report, see Pending Tasks below.")
return JsonResponse({"status": success_status}) return JsonResponse({"status": success_status})
...@@ -2388,7 +2410,7 @@ def problem_grade_report(request, course_id): ...@@ -2388,7 +2410,7 @@ def problem_grade_report(request, course_id):
""" """
course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
try: try:
instructor_task.api.submit_problem_grade_report(request, course_key) lms.djangoapps.instructor_task.api.submit_problem_grade_report(request, course_key)
success_status = _("The problem grade report is being created." success_status = _("The problem grade report is being created."
" To view the status of the report, see Pending Tasks below.") " To view the status of the report, see Pending Tasks below.")
return JsonResponse({"status": success_status}) return JsonResponse({"status": success_status})
...@@ -2513,7 +2535,7 @@ def send_email(request, course_id): ...@@ -2513,7 +2535,7 @@ def send_email(request, course_id):
return HttpResponseBadRequest(repr(err)) return HttpResponseBadRequest(repr(err))
# Submit the task, so that the correct InstructorTask object gets created (for monitoring purposes) # Submit the task, so that the correct InstructorTask object gets created (for monitoring purposes)
instructor_task.api.submit_bulk_course_email(request, course_id, email.id) lms.djangoapps.instructor_task.api.submit_bulk_course_email(request, course_id, email.id)
response_payload = { response_payload = {
'course_id': course_id.to_deprecated_string(), 'course_id': course_id.to_deprecated_string(),
...@@ -2799,7 +2821,7 @@ def start_certificate_generation(request, course_id): ...@@ -2799,7 +2821,7 @@ def start_certificate_generation(request, course_id):
Start generating certificates for all students enrolled in given course. Start generating certificates for all students enrolled in given course.
""" """
course_key = CourseKey.from_string(course_id) course_key = CourseKey.from_string(course_id)
task = instructor_task.api.generate_certificates_for_students(request, course_key) task = lms.djangoapps.instructor_task.api.generate_certificates_for_students(request, course_key)
message = _('Certificate generation task for all students of this course has been started. ' message = _('Certificate generation task for all students of this course has been started. '
'You can view the status of the generation task in the "Pending Tasks" section.') 'You can view the status of the generation task in the "Pending Tasks" section.')
response_payload = { response_payload = {
...@@ -2835,7 +2857,7 @@ def start_certificate_regeneration(request, course_id): ...@@ -2835,7 +2857,7 @@ def start_certificate_regeneration(request, course_id):
status=400 status=400
) )
try: try:
instructor_task.api.regenerate_certificates(request, course_key, certificates_statuses) lms.djangoapps.instructor_task.api.regenerate_certificates(request, course_key, certificates_statuses)
except AlreadyRunningError as error: except AlreadyRunningError as error:
return JsonResponse({'message': error.message}, status=400) return JsonResponse({'message': error.message}, status=400)
...@@ -3054,7 +3076,7 @@ def generate_certificate_exceptions(request, course_id, generate_for=None): ...@@ -3054,7 +3076,7 @@ def generate_certificate_exceptions(request, course_id, generate_for=None):
status=400 status=400
) )
instructor_task.api.generate_certificates_for_students(request, course_key, student_set=students) lms.djangoapps.instructor_task.api.generate_certificates_for_students(request, course_key, student_set=students)
response_payload = { response_payload = {
'success': True, 'success': True,
...@@ -3263,7 +3285,7 @@ def re_validate_certificate(request, course_key, generated_certificate): ...@@ -3263,7 +3285,7 @@ def re_validate_certificate(request, course_key, generated_certificate):
# We need to generate certificate only for a single student here # We need to generate certificate only for a single student here
student = certificate_invalidation.generated_certificate.user student = certificate_invalidation.generated_certificate.user
instructor_task.api.generate_certificates_for_students( lms.djangoapps.instructor_task.api.generate_certificates_for_students(
request, course_key, student_set="specific_student", specific_student_id=student.id request, course_key, student_set="specific_student", specific_student_id=student.id
) )
......
...@@ -8,7 +8,7 @@ from util.date_utils import get_default_time_display ...@@ -8,7 +8,7 @@ from util.date_utils import get_default_time_display
from bulk_email.models import CourseEmail from bulk_email.models import CourseEmail
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.utils.translation import ungettext from django.utils.translation import ungettext
from instructor_task.views import get_task_completion_info from lms.djangoapps.instructor_task.views import get_task_completion_info
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -13,8 +13,8 @@ from celery.states import READY_STATES ...@@ -13,8 +13,8 @@ from celery.states import READY_STATES
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from instructor_task.tasks import ( from lms.djangoapps.instructor_task.tasks import (
rescore_problem, rescore_problem,
reset_problem_attempts, reset_problem_attempts,
delete_problem_state, delete_problem_state,
...@@ -35,7 +35,7 @@ from instructor_task.tasks import ( ...@@ -35,7 +35,7 @@ from instructor_task.tasks import (
from certificates.models import CertificateGenerationHistory from certificates.models import CertificateGenerationHistory
from instructor_task.api_helper import ( from lms.djangoapps.instructor_task.api_helper import (
check_arguments_for_rescoring, check_arguments_for_rescoring,
encode_problem_and_student_input, encode_problem_and_student_input,
encode_entrance_exam_and_student_input, encode_entrance_exam_and_student_input,
......
...@@ -19,7 +19,7 @@ from courseware.courses import get_problems_in_section ...@@ -19,7 +19,7 @@ from courseware.courses import get_problems_in_section
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.keys import UsageKey
from instructor_task.models import InstructorTask, PROGRESS from lms.djangoapps.instructor_task.models import InstructorTask, PROGRESS
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -14,7 +14,7 @@ import dogstats_wrapper as dog_stats_api ...@@ -14,7 +14,7 @@ import dogstats_wrapper as dog_stats_api
from django.db import transaction, DatabaseError from django.db import transaction, DatabaseError
from django.core.cache import cache from django.core.cache import cache
from instructor_task.models import InstructorTask, PROGRESS, QUEUING from lms.djangoapps.instructor_task.models import InstructorTask, PROGRESS, QUEUING
from util.db import outer_atomic from util.db import outer_atomic
TASK_LOG = logging.getLogger('edx.celery.task') TASK_LOG = logging.getLogger('edx.celery.task')
......
...@@ -27,7 +27,7 @@ from django.utils.translation import ugettext_noop ...@@ -27,7 +27,7 @@ from django.utils.translation import ugettext_noop
from celery import task from celery import task
from bulk_email.tasks import perform_delegate_email_batches from bulk_email.tasks import perform_delegate_email_batches
from instructor_task.tasks_helper import ( from lms.djangoapps.instructor_task.tasks_helper import (
run_main_task, run_main_task,
BaseInstructorTask, BaseInstructorTask,
perform_module_state_update, perform_module_state_update,
......
...@@ -58,7 +58,7 @@ from instructor_analytics.basic import ( ...@@ -58,7 +58,7 @@ from instructor_analytics.basic import (
) )
from instructor_analytics.csvs import format_dictlist from instructor_analytics.csvs import format_dictlist
from openassessment.data import OraAggregateData from openassessment.data import OraAggregateData
from instructor_task.models import ReportStore, InstructorTask, PROGRESS from lms.djangoapps.instructor_task.models import ReportStore, InstructorTask, PROGRESS
from lms.djangoapps.lms_xblock.runtime import LmsPartitionService from lms.djangoapps.lms_xblock.runtime import LmsPartitionService
from openedx.core.djangoapps.course_groups.cohorts import get_cohort from openedx.core.djangoapps.course_groups.cohorts import get_cohort
from openedx.core.djangoapps.course_groups.models import CourseUserGroup from openedx.core.djangoapps.course_groups.models import CourseUserGroup
......
...@@ -3,7 +3,7 @@ import json ...@@ -3,7 +3,7 @@ import json
import factory import factory
from factory.django import DjangoModelFactory from factory.django import DjangoModelFactory
from student.tests.factories import UserFactory as StudentUserFactory from student.tests.factories import UserFactory as StudentUserFactory
from instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from celery.states import PENDING from celery.states import PENDING
from opaque_keys.edx.locations import SlashSeparatedCourseKey from opaque_keys.edx.locations import SlashSeparatedCourseKey
......
...@@ -7,7 +7,7 @@ from bulk_email.models import CourseEmail, SEND_TO_MYSELF, SEND_TO_STAFF, SEND_T ...@@ -7,7 +7,7 @@ from bulk_email.models import CourseEmail, SEND_TO_MYSELF, SEND_TO_STAFF, SEND_T
from courseware.tests.factories import UserFactory from courseware.tests.factories import UserFactory
from xmodule.modulestore.exceptions import ItemNotFoundError from xmodule.modulestore.exceptions import ItemNotFoundError
from instructor_task.api import ( from lms.djangoapps.instructor_task.api import (
get_running_instructor_tasks, get_running_instructor_tasks,
get_instructor_task_history, get_instructor_task_history,
submit_rescore_problem_for_all_students, submit_rescore_problem_for_all_students,
...@@ -28,10 +28,10 @@ from instructor_task.api import ( ...@@ -28,10 +28,10 @@ from instructor_task.api import (
SpecificStudentIdMissingError, SpecificStudentIdMissingError,
) )
from instructor_task.api_helper import AlreadyRunningError from lms.djangoapps.instructor_task.api_helper import AlreadyRunningError
from instructor_task.models import InstructorTask, PROGRESS from lms.djangoapps.instructor_task.models import InstructorTask, PROGRESS
from instructor_task.tasks import export_ora2_data from lms.djangoapps.instructor_task.tasks import export_ora2_data
from instructor_task.tests.test_base import ( from lms.djangoapps.instructor_task.tests.test_base import (
InstructorTaskTestCase, InstructorTaskTestCase,
InstructorTaskCourseTestCase, InstructorTaskCourseTestCase,
InstructorTaskModuleTestCase, InstructorTaskModuleTestCase,
...@@ -273,7 +273,7 @@ class InstructorTaskCourseSubmitTest(TestReportMixin, InstructorTaskCourseTestCa ...@@ -273,7 +273,7 @@ class InstructorTaskCourseSubmitTest(TestReportMixin, InstructorTaskCourseTestCa
def test_submit_ora2_request_task(self): def test_submit_ora2_request_task(self):
request = self.create_task_request(self.instructor) request = self.create_task_request(self.instructor)
with patch('instructor_task.api.submit_task') as mock_submit_task: with patch('lms.djangoapps.instructor_task.api.submit_task') as mock_submit_task:
mock_submit_task.return_value = MagicMock() mock_submit_task.return_value = MagicMock()
submit_export_ora2_data(request, self.course.id) submit_export_ora2_data(request, self.course.id)
......
...@@ -26,10 +26,10 @@ from xmodule.modulestore.django import modulestore ...@@ -26,10 +26,10 @@ from xmodule.modulestore.django import modulestore
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from instructor_task.api_helper import encode_problem_and_student_input from lms.djangoapps.instructor_task.api_helper import encode_problem_and_student_input
from instructor_task.models import PROGRESS, QUEUING, ReportStore from lms.djangoapps.instructor_task.models import PROGRESS, QUEUING, ReportStore
from instructor_task.tests.factories import InstructorTaskFactory from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from instructor_task.views import instructor_task_status from lms.djangoapps.instructor_task.views import instructor_task_status
TEST_COURSE_ORG = 'edx' TEST_COURSE_ORG = 'edx'
......
...@@ -25,13 +25,15 @@ from xmodule.modulestore import ModuleStoreEnum ...@@ -25,13 +25,15 @@ from xmodule.modulestore import ModuleStoreEnum
from courseware.model_data import StudentModule from courseware.model_data import StudentModule
from instructor_task.api import (submit_rescore_problem_for_all_students, from lms.djangoapps.instructor_task.api import (
submit_rescore_problem_for_all_students,
submit_rescore_problem_for_student, submit_rescore_problem_for_student,
submit_reset_problem_attempts_for_all_students, submit_reset_problem_attempts_for_all_students,
submit_delete_problem_state_for_all_students) submit_delete_problem_state_for_all_students
from instructor_task.models import InstructorTask )
from instructor_task.tasks_helper import upload_grades_csv from lms.djangoapps.instructor_task.models import InstructorTask
from instructor_task.tests.test_base import ( from lms.djangoapps.instructor_task.tasks_helper import upload_grades_csv
from lms.djangoapps.instructor_task.tests.test_base import (
InstructorTaskModuleTestCase, InstructorTaskModuleTestCase,
TestReportMixin, TestReportMixin,
OPTION_1, OPTION_1,
...@@ -571,7 +573,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent, ...@@ -571,7 +573,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent,
self.submit_student_answer(self.student_a.username, problem_a_url, [OPTION_1, OPTION_1]) self.submit_student_answer(self.student_a.username, problem_a_url, [OPTION_1, OPTION_1])
self.submit_student_answer(self.student_b.username, problem_b_url, [OPTION_1, OPTION_2]) self.submit_student_answer(self.student_b.username, problem_b_url, [OPTION_1, OPTION_2])
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_grades_csv(None, None, self.course.id, None, 'graded') result = upload_grades_csv(None, None, self.course.id, None, 'graded')
self.verify_csv_task_success(result) self.verify_csv_task_success(result)
self.verify_grades_in_csv( self.verify_grades_in_csv(
...@@ -594,7 +596,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent, ...@@ -594,7 +596,7 @@ class TestGradeReportConditionalContent(TestReportMixin, TestConditionalContent,
self.submit_student_answer(self.student_a.username, problem_a_url, [OPTION_1, OPTION_1]) self.submit_student_answer(self.student_a.username, problem_a_url, [OPTION_1, OPTION_1])
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_grades_csv(None, None, self.course.id, None, 'graded') result = upload_grades_csv(None, None, self.course.id, None, 'graded')
self.verify_csv_task_success(result) self.verify_csv_task_success(result)
self.verify_grades_in_csv( self.verify_grades_in_csv(
......
...@@ -11,8 +11,8 @@ from django.test import SimpleTestCase, override_settings, TestCase ...@@ -11,8 +11,8 @@ from django.test import SimpleTestCase, override_settings, TestCase
from mock import patch from mock import patch
from common.test.utils import MockS3Mixin from common.test.utils import MockS3Mixin
from instructor_task.models import ReportStore from lms.djangoapps.instructor_task.models import ReportStore
from instructor_task.tests.test_base import TestReportMixin from lms.djangoapps.instructor_task.tests.test_base import TestReportMixin
from opaque_keys.edx.locator import CourseLocator from opaque_keys.edx.locator import CourseLocator
......
...@@ -7,9 +7,9 @@ from mock import Mock, patch ...@@ -7,9 +7,9 @@ from mock import Mock, patch
from student.models import CourseEnrollment from student.models import CourseEnrollment
from instructor_task.subtasks import queue_subtasks_for_query from lms.djangoapps.instructor_task.subtasks import queue_subtasks_for_query
from instructor_task.tests.factories import InstructorTaskFactory from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from instructor_task.tests.test_base import InstructorTaskCourseTestCase from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskCourseTestCase
class TestSubtasks(InstructorTaskCourseTestCase): class TestSubtasks(InstructorTaskCourseTestCase):
...@@ -45,7 +45,7 @@ class TestSubtasks(InstructorTaskCourseTestCase): ...@@ -45,7 +45,7 @@ class TestSubtasks(InstructorTaskCourseTestCase):
self._enroll_students_in_course(self.course.id, extra_count) self._enroll_students_in_course(self.course.id, extra_count)
return {} return {}
with patch('instructor_task.subtasks.initialize_subtask_info') as mock_initialize_subtask_info: with patch('lms.djangoapps.instructor_task.subtasks.initialize_subtask_info') as mock_initialize_subtask_info:
mock_initialize_subtask_info.side_effect = initialize_subtask_info mock_initialize_subtask_info.side_effect = initialize_subtask_info
queue_subtasks_for_query( queue_subtasks_for_query(
entry=instructor_task, entry=instructor_task,
......
...@@ -22,17 +22,17 @@ from courseware.models import StudentModule ...@@ -22,17 +22,17 @@ from courseware.models import StudentModule
from courseware.tests.factories import StudentModuleFactory from courseware.tests.factories import StudentModuleFactory
from student.tests.factories import UserFactory, CourseEnrollmentFactory from student.tests.factories import UserFactory, CourseEnrollmentFactory
from instructor_task.models import InstructorTask from lms.djangoapps.instructor_task.models import InstructorTask
from instructor_task.tests.test_base import InstructorTaskModuleTestCase from lms.djangoapps.instructor_task.tests.test_base import InstructorTaskModuleTestCase
from instructor_task.tests.factories import InstructorTaskFactory from lms.djangoapps.instructor_task.tests.factories import InstructorTaskFactory
from instructor_task.tasks import ( from lms.djangoapps.instructor_task.tasks import (
rescore_problem, rescore_problem,
reset_problem_attempts, reset_problem_attempts,
delete_problem_state, delete_problem_state,
generate_certificates, generate_certificates,
export_ora2_data, export_ora2_data,
) )
from instructor_task.tasks_helper import ( from lms.djangoapps.instructor_task.tasks_helper import (
UpdateProblemModuleStateError, UpdateProblemModuleStateError,
upload_ora2_data, upload_ora2_data,
) )
...@@ -87,7 +87,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase): ...@@ -87,7 +87,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
self.current_task.update_state.side_effect = TestTaskFailure(expected_failure_message) self.current_task.update_state.side_effect = TestTaskFailure(expected_failure_message)
task_args = [entry_id, self._get_xmodule_instance_args()] task_args = [entry_id, self._get_xmodule_instance_args()]
with patch('instructor_task.tasks_helper._get_current_task') as mock_get_task: with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task') as mock_get_task:
mock_get_task.return_value = self.current_task mock_get_task.return_value = self.current_task
return task_class.apply(task_args, task_id=task_id).get() return task_class.apply(task_args, task_id=task_id).get()
...@@ -246,7 +246,7 @@ class TestRescoreInstructorTask(TestInstructorTasks): ...@@ -246,7 +246,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
task_entry = self._create_input_entry() task_entry = self._create_input_entry()
mock_instance = MagicMock() mock_instance = MagicMock()
del mock_instance.rescore_problem del mock_instance.rescore_problem
with patch('instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module: with patch('lms.djangoapps.instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module:
mock_get_module.return_value = mock_instance mock_get_module.return_value = mock_instance
with self.assertRaises(UpdateProblemModuleStateError): with self.assertRaises(UpdateProblemModuleStateError):
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
...@@ -264,7 +264,7 @@ class TestRescoreInstructorTask(TestInstructorTasks): ...@@ -264,7 +264,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
task_entry = self._create_input_entry() task_entry = self._create_input_entry()
mock_instance = Mock() mock_instance = Mock()
mock_instance.rescore_problem = Mock(return_value={'success': 'correct'}) mock_instance.rescore_problem = Mock(return_value={'success': 'correct'})
with patch('instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module: with patch('lms.djangoapps.instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module:
mock_get_module.return_value = mock_instance mock_get_module.return_value = mock_instance
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
# check return value # check return value
...@@ -284,7 +284,7 @@ class TestRescoreInstructorTask(TestInstructorTasks): ...@@ -284,7 +284,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
task_entry = self._create_input_entry() task_entry = self._create_input_entry()
mock_instance = Mock() mock_instance = Mock()
mock_instance.rescore_problem = Mock(return_value={'success': 'bogus'}) mock_instance.rescore_problem = Mock(return_value={'success': 'bogus'})
with patch('instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module: with patch('lms.djangoapps.instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module:
mock_get_module.return_value = mock_instance mock_get_module.return_value = mock_instance
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
# check return value # check return value
...@@ -304,7 +304,7 @@ class TestRescoreInstructorTask(TestInstructorTasks): ...@@ -304,7 +304,7 @@ class TestRescoreInstructorTask(TestInstructorTasks):
task_entry = self._create_input_entry() task_entry = self._create_input_entry()
mock_instance = Mock() mock_instance = Mock()
mock_instance.rescore_problem = Mock(return_value={'bogus': 'value'}) mock_instance.rescore_problem = Mock(return_value={'bogus': 'value'})
with patch('instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module: with patch('lms.djangoapps.instructor_task.tasks_helper.get_module_for_descriptor_internal') as mock_get_module:
mock_get_module.return_value = mock_instance mock_get_module.return_value = mock_instance
self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id) self._run_task_with_mock_celery(rescore_problem, task_entry.id, task_entry.task_id)
# check return value # check return value
...@@ -502,7 +502,7 @@ class TestOra2ResponsesInstructorTask(TestInstructorTasks): ...@@ -502,7 +502,7 @@ class TestOra2ResponsesInstructorTask(TestInstructorTasks):
task_entry = self._create_input_entry() task_entry = self._create_input_entry()
task_xmodule_args = self._get_xmodule_instance_args() task_xmodule_args = self._get_xmodule_instance_args()
with patch('instructor_task.tasks.run_main_task') as mock_main_task: with patch('lms.djangoapps.instructor_task.tasks.run_main_task') as mock_main_task:
export_ora2_data(task_entry.id, task_xmodule_args) export_ora2_data(task_entry.id, task_xmodule_args)
action_name = ugettext_noop('generated') action_name = ugettext_noop('generated')
......
...@@ -27,7 +27,11 @@ from certificates.models import CertificateStatuses, GeneratedCertificate ...@@ -27,7 +27,11 @@ from certificates.models import CertificateStatuses, GeneratedCertificate
from certificates.tests.factories import GeneratedCertificateFactory, CertificateWhitelistFactory from certificates.tests.factories import GeneratedCertificateFactory, CertificateWhitelistFactory
from course_modes.models import CourseMode from course_modes.models import CourseMode
from courseware.tests.factories import InstructorFactory from courseware.tests.factories import InstructorFactory
from instructor_task.tests.test_base import InstructorTaskCourseTestCase, TestReportMixin, InstructorTaskModuleTestCase from lms.djangoapps.instructor_task.tests.test_base import (
InstructorTaskCourseTestCase,
TestReportMixin,
InstructorTaskModuleTestCase
)
from openedx.core.djangoapps.course_groups.models import CourseUserGroupPartitionGroup, CohortMembership from openedx.core.djangoapps.course_groups.models import CourseUserGroupPartitionGroup, CohortMembership
from django.conf import settings from django.conf import settings
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
...@@ -44,9 +48,9 @@ from student.models import CourseEnrollment, CourseEnrollmentAllowed, ManualEnro ...@@ -44,9 +48,9 @@ from student.models import CourseEnrollment, CourseEnrollmentAllowed, ManualEnro
from lms.djangoapps.verify_student.tests.factories import SoftwareSecurePhotoVerificationFactory from lms.djangoapps.verify_student.tests.factories import SoftwareSecurePhotoVerificationFactory
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from xmodule.partitions.partitions import Group, UserPartition from xmodule.partitions.partitions import Group, UserPartition
from instructor_task.models import ReportStore from lms.djangoapps.instructor_task.models import ReportStore
from survey.models import SurveyForm, SurveyAnswer from survey.models import SurveyForm, SurveyAnswer
from instructor_task.tasks_helper import ( from lms.djangoapps.instructor_task.tasks_helper import (
cohort_students_and_upload, cohort_students_and_upload,
upload_problem_responses_csv, upload_problem_responses_csv,
upload_grades_csv, upload_grades_csv,
...@@ -73,7 +77,7 @@ class InstructorGradeReportTestCase(TestReportMixin, InstructorTaskCourseTestCas ...@@ -73,7 +77,7 @@ class InstructorGradeReportTestCase(TestReportMixin, InstructorTaskCourseTestCas
""" """
Verify cell data in the grades CSV for a particular user. Verify cell data in the grades CSV for a particular user.
""" """
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_grades_csv(None, None, course_id, None, 'graded') result = upload_grades_csv(None, None, course_id, None, 'graded')
self.assertDictContainsSubset({'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': 2, 'succeeded': 2, 'failed': 0}, result)
report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD') report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
...@@ -104,14 +108,14 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase): ...@@ -104,14 +108,14 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
self.current_task = Mock() self.current_task = Mock()
self.current_task.update_state = Mock() self.current_task.update_state = Mock()
with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task: with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task') as mock_current_task:
mock_current_task.return_value = self.current_task mock_current_task.return_value = self.current_task
result = upload_grades_csv(None, None, self.course.id, None, 'graded') result = upload_grades_csv(None, None, self.course.id, None, 'graded')
num_students = len(emails) num_students = len(emails)
self.assertDictContainsSubset({'attempted': num_students, 'succeeded': num_students, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': num_students, 'succeeded': num_students, 'failed': 0}, result)
@patch('instructor_task.tasks_helper._get_current_task') @patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task')
@patch('instructor_task.tasks_helper.iterate_grades_for') @patch('lms.djangoapps.instructor_task.tasks_helper.iterate_grades_for')
def test_grading_failure(self, mock_iterate_grades_for, _mock_current_task): def test_grading_failure(self, mock_iterate_grades_for, _mock_current_task):
""" """
Test that any grading errors are properly reported in the Test that any grading errors are properly reported in the
...@@ -288,8 +292,8 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase): ...@@ -288,8 +292,8 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
u'Default Group', u'Default Group',
) )
@patch('instructor_task.tasks_helper._get_current_task') @patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task')
@patch('instructor_task.tasks_helper.iterate_grades_for') @patch('lms.djangoapps.instructor_task.tasks_helper.iterate_grades_for')
def test_unicode_in_csv_header(self, mock_iterate_grades_for, _mock_current_task): def test_unicode_in_csv_header(self, mock_iterate_grades_for, _mock_current_task):
""" """
Tests that CSV grade report works if unicode in headers. Tests that CSV grade report works if unicode in headers.
...@@ -354,8 +358,8 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -354,8 +358,8 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskCourseTestCase):
def test_success(self): def test_success(self):
task_input = {'problem_location': ''} task_input = {'problem_location': ''}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
with patch('instructor_task.tasks_helper.list_problem_responses') as patched_data_source: with patch('lms.djangoapps.instructor_task.tasks_helper.list_problem_responses') as patched_data_source:
patched_data_source.return_value = [ patched_data_source.return_value = [
{'username': 'user0', 'state': u'state0'}, {'username': 'user0', 'state': u'state0'},
{'username': 'user1', 'state': u'state1'}, {'username': 'user1', 'state': u'state1'},
...@@ -402,7 +406,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour ...@@ -402,7 +406,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
def test_success(self): def test_success(self):
self.create_student('student', 'student@example.com') self.create_student('student', 'student@example.com')
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report') result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
...@@ -418,7 +422,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour ...@@ -418,7 +422,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
student_cart.purchase() student_cart.purchase()
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report') result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Credit Card - Individual') self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Credit Card - Individual')
...@@ -437,7 +441,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour ...@@ -437,7 +441,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
) )
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report') result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')
enrollment_source = u'manually enrolled by username: {username}'.format( enrollment_source = u'manually enrolled by username: {username}'.format(
...@@ -477,7 +481,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour ...@@ -477,7 +481,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report') result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Used Registration Code') self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Used Registration Code')
...@@ -511,7 +515,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour ...@@ -511,7 +515,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report') result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Used Registration Code') self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Used Registration Code')
...@@ -552,7 +556,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour ...@@ -552,7 +556,7 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
self.assertEquals(response.status_code, 200) self.assertEquals(response.status_code, 200)
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report') result = upload_enrollment_report(None, None, self.course.id, task_input, 'generating_enrollment_report')
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Used Registration Code') self._verify_cell_data_in_csv(student.username, 'Enrollment Source', 'Used Registration Code')
...@@ -586,7 +590,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase): ...@@ -586,7 +590,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
self.student_2 = self.create_student(u'üser_2') self.student_2 = self.create_student(u'üser_2')
self.csv_header_row = [u'Student ID', u'Email', u'Username', u'Final Grade'] self.csv_header_row = [u'Student ID', u'Email', u'Username', u'Final Grade']
@patch('instructor_task.tasks_helper._get_current_task') @patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task')
def test_no_problems(self, _get_current_task): def test_no_problems(self, _get_current_task):
""" """
Verify that we see no grade information for a course with no graded Verify that we see no grade information for a course with no graded
...@@ -605,7 +609,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase): ...@@ -605,7 +609,7 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
)) ))
]) ])
@patch('instructor_task.tasks_helper._get_current_task') @patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task')
def test_single_problem(self, _get_current_task): def test_single_problem(self, _get_current_task):
vertical = ItemFactory.create( vertical = ItemFactory.create(
parent_location=self.problem_section.location, parent_location=self.problem_section.location,
...@@ -640,8 +644,8 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase): ...@@ -640,8 +644,8 @@ class TestProblemGradeReport(TestReportMixin, InstructorTaskModuleTestCase):
)) ))
]) ])
@patch('instructor_task.tasks_helper._get_current_task') @patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task')
@patch('instructor_task.tasks_helper.iterate_grades_for') @patch('lms.djangoapps.instructor_task.tasks_helper.iterate_grades_for')
@ddt.data(u'Cannöt grade student', '') @ddt.data(u'Cannöt grade student', '')
def test_grading_failure(self, error_message, mock_iterate_grades_for, _mock_current_task): def test_grading_failure(self, error_message, mock_iterate_grades_for, _mock_current_task):
""" """
...@@ -701,7 +705,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent, ...@@ -701,7 +705,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent,
self.submit_student_answer(self.student_b.username, self.problem_a_url, [self.OPTION_1, self.OPTION_2]) self.submit_student_answer(self.student_b.username, self.problem_a_url, [self.OPTION_1, self.OPTION_2])
self.submit_student_answer(self.student_b.username, self.problem_b_url, [self.OPTION_1, self.OPTION_2]) self.submit_student_answer(self.student_b.username, self.problem_b_url, [self.OPTION_1, self.OPTION_2])
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_problem_grade_report(None, None, self.course.id, None, 'graded') result = upload_problem_grade_report(None, None, self.course.id, None, 'graded')
self.assertDictContainsSubset( self.assertDictContainsSubset(
{'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, result {'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, result
...@@ -793,7 +797,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent, ...@@ -793,7 +797,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent,
for problem in problem_names: for problem in problem_names:
header_row += [problem + ' (Earned)', problem + ' (Possible)'] header_row += [problem + ' (Earned)', problem + ' (Possible)']
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
upload_problem_grade_report(None, None, self.course.id, None, 'graded') upload_problem_grade_report(None, None, self.course.id, None, 'graded')
self.assertEquals(self.get_csv_row_with_headers(), header_row) self.assertEquals(self.get_csv_row_with_headers(), header_row)
...@@ -849,7 +853,7 @@ class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, In ...@@ -849,7 +853,7 @@ class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, In
self.assertEqual(resp.status_code, 404) self.assertEqual(resp.status_code, 404)
self.submit_student_answer(self.beta_user.username, u'Pröblem1', ['Option 1', 'Option 2']) self.submit_student_answer(self.beta_user.username, u'Pröblem1', ['Option 1', 'Option 2'])
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_problem_grade_report(None, None, self.course.id, None, 'graded') result = upload_problem_grade_report(None, None, self.course.id, None, 'graded')
self.assertDictContainsSubset( self.assertDictContainsSubset(
{'action_name': 'graded', 'attempted': 4, 'succeeded': 4, 'failed': 0}, result {'action_name': 'graded', 'attempted': 4, 'succeeded': 4, 'failed': 0}, result
...@@ -922,7 +926,7 @@ class TestExecutiveSummaryReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -922,7 +926,7 @@ class TestExecutiveSummaryReport(TestReportMixin, InstructorTaskCourseTestCase):
Test that successfully generates the executive summary report. Test that successfully generates the executive summary report.
""" """
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_exec_summary_report( result = upload_exec_summary_report(
None, None, self.course.id, None, None, self.course.id,
task_input, 'generating executive summary report' task_input, 'generating executive summary report'
...@@ -975,7 +979,7 @@ class TestExecutiveSummaryReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -975,7 +979,7 @@ class TestExecutiveSummaryReport(TestReportMixin, InstructorTaskCourseTestCase):
""" """
self.students_purchases() self.students_purchases()
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_exec_summary_report( result = upload_exec_summary_report(
None, None, self.course.id, None, None, self.course.id,
task_input, 'generating executive summary report' task_input, 'generating executive summary report'
...@@ -1041,7 +1045,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1041,7 +1045,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase):
Test that successfully generates the course survey report. Test that successfully generates the course survey report.
""" """
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_course_survey_report( result = upload_course_survey_report(
None, None, self.course.id, None, None, self.course.id,
task_input, 'generating course survey report' task_input, 'generating course survey report'
...@@ -1056,7 +1060,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1056,7 +1060,7 @@ class TestCourseSurveyReport(TestReportMixin, InstructorTaskCourseTestCase):
""" """
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_course_survey_report( result = upload_course_survey_report(
None, None, self.course.id, None, None, self.course.id,
task_input, 'generating course survey report' task_input, 'generating course survey report'
...@@ -1108,7 +1112,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1108,7 +1112,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
def test_success(self): def test_success(self):
self.create_student('student', 'student@example.com') self.create_student('student', 'student@example.com')
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') result = upload_students_csv(None, None, self.course.id, task_input, 'calculated')
report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD') report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
links = report_store.links_for(self.course.id) links = report_store.links_for(self.course.id)
...@@ -1134,7 +1138,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1134,7 +1138,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
'goals' 'goals'
] ]
} }
with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task: with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task') as mock_current_task:
mock_current_task.return_value = self.current_task mock_current_task.return_value = self.current_task
result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') result = upload_students_csv(None, None, self.course.id, task_input, 'calculated')
# This assertion simply confirms that the generation completed with no errors # This assertion simply confirms that the generation completed with no errors
...@@ -1166,7 +1170,7 @@ class TestTeamStudentReport(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1166,7 +1170,7 @@ class TestTeamStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
'goals', 'team' 'goals', 'team'
] ]
} }
with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task: with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task') as mock_current_task:
mock_current_task.return_value = current_task mock_current_task.return_value = current_task
result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') result = upload_students_csv(None, None, self.course.id, task_input, 'calculated')
self.assertDictContainsSubset({'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.assertDictContainsSubset({'attempted': 2, 'succeeded': 2, 'failed': 0}, result)
...@@ -1223,7 +1227,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1223,7 +1227,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase):
def test_success(self): def test_success(self):
self._create_enrollment('user@example.com') self._create_enrollment('user@example.com')
task_input = {'features': []} task_input = {'features': []}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_may_enroll_csv(None, None, self.course.id, task_input, 'calculated') result = upload_may_enroll_csv(None, None, self.course.id, task_input, 'calculated')
report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD') report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
links = report_store.links_for(self.course.id) links = report_store.links_for(self.course.id)
...@@ -1241,7 +1245,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1241,7 +1245,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase):
self._create_enrollment(email) self._create_enrollment(email)
task_input = {'features': ['email']} task_input = {'features': ['email']}
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
result = upload_may_enroll_csv(None, None, self.course.id, task_input, 'calculated') result = upload_may_enroll_csv(None, None, self.course.id, task_input, 'calculated')
# This assertion simply confirms that the generation completed with no errors # This assertion simply confirms that the generation completed with no errors
num_enrollments = len(enrollments) num_enrollments = len(enrollments)
...@@ -1258,7 +1262,7 @@ class MockDefaultStorage(object): ...@@ -1258,7 +1262,7 @@ class MockDefaultStorage(object):
return open(file_name) return open(file_name)
@patch('instructor_task.tasks_helper.DefaultStorage', new=MockDefaultStorage) @patch('lms.djangoapps.instructor_task.tasks_helper.DefaultStorage', new=MockDefaultStorage)
class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase): class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase):
""" """
Tests that bulk student cohorting works. Tests that bulk student cohorting works.
...@@ -1280,7 +1284,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1280,7 +1284,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase):
with tempfile.NamedTemporaryFile() as temp_file: with tempfile.NamedTemporaryFile() as temp_file:
temp_file.write(csv_data.encode('utf-8')) temp_file.write(csv_data.encode('utf-8'))
temp_file.flush() temp_file.flush()
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
return cohort_students_and_upload(None, None, self.course.id, {'file_name': temp_file.name}, 'cohorted') return cohort_students_and_upload(None, None, self.course.id, {'file_name': temp_file.name}, 'cohorted')
def test_username(self): def test_username(self):
...@@ -1489,7 +1493,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase): ...@@ -1489,7 +1493,7 @@ class TestCohortStudents(TestReportMixin, InstructorTaskCourseTestCase):
@ddt.ddt @ddt.ddt
@patch('instructor_task.tasks_helper.DefaultStorage', new=MockDefaultStorage) @patch('lms.djangoapps.instructor_task.tasks_helper.DefaultStorage', new=MockDefaultStorage)
class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTaskModuleTestCase): class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTaskModuleTestCase):
""" """
Test that grade report has correct user enrolment, verification, and certificate information. Test that grade report has correct user enrolment, verification, and certificate information.
...@@ -1539,7 +1543,7 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas ...@@ -1539,7 +1543,7 @@ class TestGradeReportEnrollmentAndCertificateInfo(TestReportMixin, InstructorTas
""" """
Verify grade report data. Verify grade report data.
""" """
with patch('instructor_task.tasks_helper._get_current_task'): with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task'):
upload_grades_csv(None, None, self.course.id, None, 'graded') upload_grades_csv(None, None, self.course.id, None, 'graded')
report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD') report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
report_csv_filename = report_store.links_for(self.course.id)[0][0] report_csv_filename = report_store.links_for(self.course.id)[0][0]
...@@ -2161,7 +2165,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase): ...@@ -2161,7 +2165,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
current_task = Mock() current_task = Mock()
current_task.update_state = Mock() current_task.update_state = Mock()
with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task: with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task') as mock_current_task:
mock_current_task.return_value = current_task mock_current_task.return_value = current_task
with patch('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_queue: with patch('capa.xqueue_interface.XQueueInterface.send_to_queue') as mock_queue:
mock_queue.return_value = (0, "Successfully queued") mock_queue.return_value = (0, "Successfully queued")
...@@ -2208,10 +2212,12 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase): ...@@ -2208,10 +2212,12 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase):
shutil.rmtree(settings.GRADES_DOWNLOAD['ROOT_PATH']) shutil.rmtree(settings.GRADES_DOWNLOAD['ROOT_PATH'])
def test_report_fails_if_error(self): def test_report_fails_if_error(self):
with patch('instructor_task.tasks_helper.OraAggregateData.collect_ora2_data') as mock_collect_data: with patch(
'lms.djangoapps.instructor_task.tasks_helper.OraAggregateData.collect_ora2_data'
) as mock_collect_data:
mock_collect_data.side_effect = KeyError mock_collect_data.side_effect = KeyError
with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task: with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task') as mock_current_task:
mock_current_task.return_value = self.current_task mock_current_task.return_value = self.current_task
response = upload_ora2_data(None, None, self.course.id, None, 'generated') response = upload_ora2_data(None, None, self.course.id, None, 'generated')
...@@ -2222,13 +2228,17 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase): ...@@ -2222,13 +2228,17 @@ class TestInstructorOra2Report(SharedModuleStoreTestCase):
test_header = ['field1', 'field2'] test_header = ['field1', 'field2']
test_rows = [['row1_field1', 'row1_field2'], ['row2_field1', 'row2_field2']] test_rows = [['row1_field1', 'row1_field2'], ['row2_field1', 'row2_field2']]
with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task: with patch('lms.djangoapps.instructor_task.tasks_helper._get_current_task') as mock_current_task:
mock_current_task.return_value = self.current_task mock_current_task.return_value = self.current_task
with patch('instructor_task.tasks_helper.OraAggregateData.collect_ora2_data') as mock_collect_data: with patch(
'lms.djangoapps.instructor_task.tasks_helper.OraAggregateData.collect_ora2_data'
) as mock_collect_data:
mock_collect_data.return_value = (test_header, test_rows) mock_collect_data.return_value = (test_header, test_rows)
with patch('instructor_task.models.DjangoStorageReportStore.store_rows') as mock_store_rows: with patch(
'lms.djangoapps.instructor_task.models.DjangoStorageReportStore.store_rows'
) as mock_store_rows:
return_val = upload_ora2_data(None, None, self.course.id, None, 'generated') return_val = upload_ora2_data(None, None, self.course.id, None, 'generated')
# pylint: disable=maybe-no-member # pylint: disable=maybe-no-member
......
...@@ -9,11 +9,13 @@ from mock import Mock, patch ...@@ -9,11 +9,13 @@ from mock import Mock, patch
from django.http import QueryDict from django.http import QueryDict
from instructor_task.models import PROGRESS from lms.djangoapps.instructor_task.models import PROGRESS
from instructor_task.tests.test_base import (InstructorTaskTestCase, from lms.djangoapps.instructor_task.tests.test_base import (
InstructorTaskTestCase,
TEST_FAILURE_MESSAGE, TEST_FAILURE_MESSAGE,
TEST_FAILURE_EXCEPTION) TEST_FAILURE_EXCEPTION
from instructor_task.views import instructor_task_status, get_task_completion_info )
from lms.djangoapps.instructor_task.views import instructor_task_status, get_task_completion_info
class InstructorTaskReportTest(InstructorTaskTestCase): class InstructorTaskReportTest(InstructorTaskTestCase):
......
...@@ -7,9 +7,8 @@ from django.utils.translation import ugettext as _ ...@@ -7,9 +7,8 @@ from django.utils.translation import ugettext as _
from celery.states import FAILURE, REVOKED, READY_STATES from celery.states import FAILURE, REVOKED, READY_STATES
from instructor_task.api_helper import (get_status_from_instructor_task, from lms.djangoapps.instructor_task.api_helper import (get_status_from_instructor_task, get_updated_instructor_task)
get_updated_instructor_task) from lms.djangoapps.instructor_task.models import PROGRESS
from instructor_task.models import PROGRESS
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
......
...@@ -35,7 +35,7 @@ LOG_OVERRIDES = [ ...@@ -35,7 +35,7 @@ LOG_OVERRIDES = [
('codejail.safe_exec', logging.ERROR), ('codejail.safe_exec', logging.ERROR),
('edx.courseware', logging.ERROR), ('edx.courseware', logging.ERROR),
('audit', logging.ERROR), ('audit', logging.ERROR),
('instructor_task.api_helper', logging.ERROR), ('lms.djangoapps.instructor_task.api_helper', logging.ERROR),
] ]
for log_name, log_level in LOG_OVERRIDES: for log_name, log_level in LOG_OVERRIDES:
......
...@@ -1925,7 +1925,7 @@ INSTALLED_APPS = ( ...@@ -1925,7 +1925,7 @@ INSTALLED_APPS = (
'certificates', 'certificates',
'dashboard', 'dashboard',
'lms.djangoapps.instructor', 'lms.djangoapps.instructor',
'instructor_task', 'lms.djangoapps.instructor_task',
'openedx.core.djangoapps.course_groups', 'openedx.core.djangoapps.course_groups',
'bulk_email', 'bulk_email',
'branding', 'branding',
......
...@@ -877,7 +877,7 @@ if settings.FEATURES.get('ENABLE_INSTRUCTOR_BACKGROUND_TASKS'): ...@@ -877,7 +877,7 @@ if settings.FEATURES.get('ENABLE_INSTRUCTOR_BACKGROUND_TASKS'):
urlpatterns += ( urlpatterns += (
url( url(
r'^instructor_task_status/$', r'^instructor_task_status/$',
'instructor_task.views.instructor_task_status', 'lms.djangoapps.instructor_task.views.instructor_task_status',
name='instructor_task_status' name='instructor_task_status'
), ),
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment