Merge pull request #22643 from edx/feanil/2to3_asserts

Run `2to3 -f asserts . -w` on edx-platform.
This commit is contained in:
Feanil Patel
2019-12-30 12:13:42 -05:00
committed by GitHub
214 changed files with 1459 additions and 1464 deletions

View File

@@ -61,7 +61,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
self._create_success_entry()
progress_task_ids = [self._create_progress_entry().task_id for _ in range(1, 5)]
task_ids = [instructor_task.task_id for instructor_task in get_running_instructor_tasks(TEST_COURSE_KEY)]
self.assertEquals(set(task_ids), set(progress_task_ids))
self.assertEqual(set(task_ids), set(progress_task_ids))
def test_get_instructor_task_history(self):
# when fetching historical tasks, we get all tasks, including running tasks
@@ -72,7 +72,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
expected_ids.append(self._create_progress_entry().task_id)
task_ids = [instructor_task.task_id for instructor_task
in get_instructor_task_history(TEST_COURSE_KEY, usage_key=self.problem_url)]
self.assertEquals(set(task_ids), set(expected_ids))
self.assertEqual(set(task_ids), set(expected_ids))
# make the same call using explicit task_type:
task_ids = [instructor_task.task_id for instructor_task
in get_instructor_task_history(
@@ -80,7 +80,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
usage_key=self.problem_url,
task_type='rescore_problem'
)]
self.assertEquals(set(task_ids), set(expected_ids))
self.assertEqual(set(task_ids), set(expected_ids))
# make the same call using a non-existent task_type:
task_ids = [instructor_task.task_id for instructor_task
in get_instructor_task_history(
@@ -88,7 +88,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
usage_key=self.problem_url,
task_type='dummy_type'
)]
self.assertEquals(set(task_ids), set())
self.assertEqual(set(task_ids), set())
@ddt.ddt
@@ -175,11 +175,11 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
instructor_task = task_function(self.create_task_request(self.instructor), location, **params)
most_recent_task = InstructorTask.objects.latest('id')
self.assertEquals(most_recent_task.task_state, FAILURE)
self.assertEqual(most_recent_task.task_state, FAILURE)
# successful submission
instructor_task = task_function(self.create_task_request(self.instructor), location, **params)
self.assertEquals(instructor_task.task_type, expected_task_type)
self.assertEqual(instructor_task.task_type, expected_task_type)
# test resubmitting, by updating the existing record:
instructor_task = InstructorTask.objects.get(id=instructor_task.id)

View File

@@ -134,7 +134,7 @@ class TestRescoringTask(TestIntegrationTask):
expected_subsection_grade = expected_score
course_grade = CourseGradeFactory().read(user, self.course)
self.assertEquals(
self.assertEqual(
course_grade.graded_subsections_by_format['Homework'][self.problem_section.location].graded_total.earned,
expected_subsection_grade,
)
@@ -473,12 +473,12 @@ class TestResetAttemptsTask(TestIntegrationTask):
self.submit_student_answer(username, problem_url_name, [OPTION_1, OPTION_1])
for username in self.userlist:
self.assertEquals(self.get_num_attempts(username, descriptor), num_attempts)
self.assertEqual(self.get_num_attempts(username, descriptor), num_attempts)
self.reset_problem_attempts('instructor', location)
for username in self.userlist:
self.assertEquals(self.get_num_attempts(username, descriptor), 0)
self.assertEqual(self.get_num_attempts(username, descriptor), 0)
def test_reset_failure(self):
"""Simulate a failure in resetting attempts on a problem"""

View File

@@ -134,16 +134,16 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
expected_total = expected_total \
if expected_total else expected_num_succeeded + expected_num_skipped
# check return value
self.assertEquals(status.get('attempted'), expected_attempted)
self.assertEquals(status.get('succeeded'), expected_num_succeeded)
self.assertEquals(status.get('skipped'), expected_num_skipped)
self.assertEquals(status.get('total'), expected_total)
self.assertEquals(status.get('action_name'), action_name)
self.assertEqual(status.get('attempted'), expected_attempted)
self.assertEqual(status.get('succeeded'), expected_num_succeeded)
self.assertEqual(status.get('skipped'), expected_num_skipped)
self.assertEqual(status.get('total'), expected_total)
self.assertEqual(status.get('action_name'), action_name)
self.assertGreater(status.get('duration_ms'), 0)
# compare with entry in table:
entry = InstructorTask.objects.get(id=task_entry.id)
self.assertEquals(json.loads(entry.task_output), status)
self.assertEquals(entry.task_state, SUCCESS)
self.assertEqual(json.loads(entry.task_output), status)
self.assertEqual(entry.task_state, SUCCESS)
def _test_run_with_no_state(self, task_class, action_name):
"""Run with no StudentModules defined for the current problem."""
@@ -186,7 +186,7 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
student=student,
module_state_key=self.location)
state = json.loads(module.state)
self.assertEquals(state['attempts'], num_attempts)
self.assertEqual(state['attempts'], num_attempts)
def _test_run_with_failure(self, task_class, expected_message):
"""Run a task and trigger an artificial failure with the given message."""
@@ -196,10 +196,10 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
self._run_task_with_mock_celery(task_class, task_entry.id, task_entry.task_id, expected_message)
# compare with entry in table:
entry = InstructorTask.objects.get(id=task_entry.id)
self.assertEquals(entry.task_state, FAILURE)
self.assertEqual(entry.task_state, FAILURE)
output = json.loads(entry.task_output)
self.assertEquals(output['exception'], 'TestTaskFailure')
self.assertEquals(output['message'], expected_message)
self.assertEqual(output['exception'], 'TestTaskFailure')
self.assertEqual(output['message'], expected_message)
def _test_run_with_long_error_msg(self, task_class):
"""
@@ -213,11 +213,11 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
self._run_task_with_mock_celery(task_class, task_entry.id, task_entry.task_id, expected_message)
# compare with entry in table:
entry = InstructorTask.objects.get(id=task_entry.id)
self.assertEquals(entry.task_state, FAILURE)
self.assertEqual(entry.task_state, FAILURE)
self.assertGreater(1023, len(entry.task_output))
output = json.loads(entry.task_output)
self.assertEquals(output['exception'], 'TestTaskFailure')
self.assertEquals(output['message'], expected_message[:len(output['message']) - 3] + "...")
self.assertEqual(output['exception'], 'TestTaskFailure')
self.assertEqual(output['message'], expected_message[:len(output['message']) - 3] + "...")
self.assertNotIn('traceback', output)
def _test_run_with_short_error_msg(self, task_class):
@@ -233,12 +233,12 @@ class TestInstructorTasks(InstructorTaskModuleTestCase):
self._run_task_with_mock_celery(task_class, task_entry.id, task_entry.task_id, expected_message)
# compare with entry in table:
entry = InstructorTask.objects.get(id=task_entry.id)
self.assertEquals(entry.task_state, FAILURE)
self.assertEqual(entry.task_state, FAILURE)
self.assertGreater(1023, len(entry.task_output))
output = json.loads(entry.task_output)
self.assertEquals(output['exception'], 'TestTaskFailure')
self.assertEquals(output['message'], expected_message)
self.assertEquals(output['traceback'][-3:], "...")
self.assertEqual(output['exception'], 'TestTaskFailure')
self.assertEqual(output['message'], expected_message)
self.assertEqual(output['traceback'][-3:], "...")
class TestOverrideScoreInstructorTask(TestInstructorTasks):
@@ -303,8 +303,8 @@ class TestOverrideScoreInstructorTask(TestInstructorTasks):
# check values stored in table:
entry = InstructorTask.objects.get(id=task_entry.id)
output = json.loads(entry.task_output)
self.assertEquals(output['exception'], "UpdateProblemModuleStateError")
self.assertEquals(output['message'], "Scores cannot be overridden for this problem type.")
self.assertEqual(output['exception'], "UpdateProblemModuleStateError")
self.assertEqual(output['message'], "Scores cannot be overridden for this problem type.")
self.assertGreater(len(output['traceback']), 0)
def test_overriding_unaccessable(self):
@@ -435,8 +435,8 @@ class TestRescoreInstructorTask(TestInstructorTasks):
# check values stored in table:
entry = InstructorTask.objects.get(id=task_entry.id)
output = json.loads(entry.task_output)
self.assertEquals(output['exception'], "UpdateProblemModuleStateError")
self.assertEquals(output['message'], u"Specified module {0} of type {1} does not support rescoring.".format(
self.assertEqual(output['exception'], "UpdateProblemModuleStateError")
self.assertEqual(output['message'], u"Specified module {0} of type {1} does not support rescoring.".format(
self.location,
mock_instance.__class__,
))
@@ -553,7 +553,7 @@ class TestResetAttemptsInstructorTask(TestInstructorTasks):
student=student,
module_state_key=self.location)
state = json.loads(module.state)
self.assertEquals(state['attempts'], initial_attempts)
self.assertEqual(state['attempts'], initial_attempts)
if use_email:
student_ident = students[3].email
@@ -563,16 +563,16 @@ class TestResetAttemptsInstructorTask(TestInstructorTasks):
status = self._run_task_with_mock_celery(reset_problem_attempts, task_entry.id, task_entry.task_id)
# check return value
self.assertEquals(status.get('attempted'), 1)
self.assertEquals(status.get('succeeded'), 1)
self.assertEquals(status.get('total'), 1)
self.assertEquals(status.get('action_name'), 'reset')
self.assertEqual(status.get('attempted'), 1)
self.assertEqual(status.get('succeeded'), 1)
self.assertEqual(status.get('total'), 1)
self.assertEqual(status.get('action_name'), 'reset')
self.assertGreater(status.get('duration_ms'), 0)
# compare with entry in table:
entry = InstructorTask.objects.get(id=task_entry.id)
self.assertEquals(json.loads(entry.task_output), status)
self.assertEquals(entry.task_state, SUCCESS)
self.assertEqual(json.loads(entry.task_output), status)
self.assertEqual(entry.task_state, SUCCESS)
# check that the correct entry was reset
for index, student in enumerate(students):
module = StudentModule.objects.get(course_id=self.course.id,
@@ -580,9 +580,9 @@ class TestResetAttemptsInstructorTask(TestInstructorTasks):
module_state_key=self.location)
state = json.loads(module.state)
if index == 3:
self.assertEquals(state['attempts'], 0)
self.assertEqual(state['attempts'], 0)
else:
self.assertEquals(state['attempts'], initial_attempts)
self.assertEqual(state['attempts'], initial_attempts)
def test_reset_with_student_username(self):
self._test_reset_with_student(False)

View File

@@ -530,7 +530,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
usage_key_str=str(self.course.location),
)
self.assertEquals(len(student_data), 4)
self.assertEqual(len(student_data), 4)
@patch(
'lms.djangoapps.instructor_task.tasks_helper.grades.list_problem_responses',
@@ -549,7 +549,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
course_key=self.course.id,
usage_key_str=str(problem.location),
)
self.assertEquals(len(student_data), 1)
self.assertEqual(len(student_data), 1)
self.assertDictContainsSubset({
'username': 'student',
'location': 'Problem1',
@@ -578,7 +578,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
course_key=self.course.id,
usage_key_str=str(self.course.location),
)
self.assertEquals(len(student_data), 2)
self.assertEqual(len(student_data), 2)
self.assertDictContainsSubset({
'username': 'student',
'location': 'test_course > Section > Subsection > Problem1',
@@ -595,7 +595,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
'some': 'state2',
'more': 'state2!',
}, student_data[1])
self.assertEquals(student_data[0]['state'], student_data[1]['state'])
self.assertEqual(student_data[0]['state'], student_data[1]['state'])
def test_build_student_data_for_block_with_real_generate_report_data(self):
"""
@@ -609,7 +609,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
course_key=self.course.id,
usage_key_str=str(self.course.location),
)
self.assertEquals(len(student_data), 1)
self.assertEqual(len(student_data), 1)
self.assertDictContainsSubset({
'username': 'student',
'location': 'test_course > Section > Subsection > Problem1',
@@ -665,7 +665,7 @@ class TestProblemResponsesReport(TestReportMixin, InstructorTaskModuleTestCase):
report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
links = report_store.links_for(self.course.id)
self.assertEquals(len(links), 1)
self.assertEqual(len(links), 1)
self.assertDictContainsSubset({'attempted': 3, 'succeeded': 3, 'failed': 0}, result)
self.assertIn("report_name", result)
@@ -770,12 +770,12 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
course_reg_codes = CourseRegistrationCode.objects.filter(order=student_cart)
redeem_url = reverse('register_code_redemption', args=[course_reg_codes[0].code])
response = self.client.get(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
# check button text
self.assertContains(response, 'Activate Course Enrollment')
response = self.client.post(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
task_input = {'features': []}
with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'):
@@ -804,12 +804,12 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
redeem_url = reverse('register_code_redemption', args=['abcde'])
response = self.client.get(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
# check button text
self.assertContains(response, 'Activate Course Enrollment')
response = self.client.post(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
task_input = {'features': []}
with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'):
@@ -845,12 +845,12 @@ class TestInstructorDetailedEnrollmentReport(TestReportMixin, InstructorTaskCour
redeem_url = reverse('register_code_redemption', args=['abcde'])
response = self.client.get(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
# check button text
self.assertContains(response, 'Activate Course Enrollment')
response = self.client.post(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
task_input = {'features': []}
with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'):
@@ -1174,7 +1174,7 @@ class TestProblemReportSplitTestContent(TestReportMixin, TestConditionalContent,
with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'):
ProblemGradeReport.generate(None, None, self.course.id, None, 'graded')
self.assertEquals(self.get_csv_row_with_headers(), header_row)
self.assertEqual(self.get_csv_row_with_headers(), header_row)
class TestProblemReportCohortedContent(TestReportMixin, ContentGroupTestCase, InstructorTaskModuleTestCase):
@@ -1352,12 +1352,12 @@ class TestExecutiveSummaryReport(TestReportMixin, InstructorTaskCourseTestCase):
course_reg_codes = CourseRegistrationCode.objects.filter(order=self.student1_cart)
redeem_url = reverse('register_code_redemption', args=[course_reg_codes[0].code])
response = self.client.get(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
# check button text
self.assertContains(response, 'Activate Course Enrollment')
response = self.client.post(redeem_url)
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.client.login(username=self.student2.username, password='test')
PaidCourseRegistration.add_to_order(self.student2_cart, self.course.id)
@@ -1516,7 +1516,7 @@ class TestStudentReport(TestReportMixin, InstructorTaskCourseTestCase):
report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
links = report_store.links_for(self.course.id)
self.assertEquals(len(links), 1)
self.assertEqual(len(links), 1)
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
@ddt.data([u'student', u'student\xec'])
@@ -1630,7 +1630,7 @@ class TestListMayEnroll(TestReportMixin, InstructorTaskCourseTestCase):
report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD')
links = report_store.links_for(self.course.id)
self.assertEquals(len(links), 1)
self.assertEqual(len(links), 1)
self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
def test_unicode_email_addresses(self):
@@ -2688,7 +2688,7 @@ class TestCertificateGeneration(InstructorTaskModuleTestCase):
[cert for cert in generated_certificates
if cert.status == CertificateStatuses.unavailable and cert.grade == default_grade]
self.assertEquals(len(unavailable_certificates), 2)
self.assertEqual(len(unavailable_certificates), 2)
def test_certificate_regeneration_for_students(self):
"""

View File

@@ -38,7 +38,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
request.GET = request.POST = {'task_id': task_id}
response = instructor_task_status(request)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(output['task_id'], task_id)
self.assertEqual(output['task_id'], task_id)
def test_missing_instructor_task_status(self):
task_id = "missing_id"
@@ -46,7 +46,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
request.GET = request.POST = {'task_id': task_id}
response = instructor_task_status(request)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(output, {})
self.assertEqual(output, {})
def test_instructor_task_status_list(self):
# Fetch status for existing tasks by arg list, as if called from ajax.
@@ -59,9 +59,9 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
request.GET = request.POST = task_ids_query_dict
response = instructor_task_status(request)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(len(output), len(task_ids))
self.assertEqual(len(output), len(task_ids))
for task_id in task_ids:
self.assertEquals(output[task_id]['task_id'], task_id)
self.assertEqual(output[task_id]['task_id'], task_id)
def test_get_status_from_failure(self):
# get status for a task that has already failed
@@ -69,16 +69,16 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
task_id = instructor_task.task_id
response = self._get_instructor_task_status(task_id)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(output['message'], TEST_FAILURE_MESSAGE)
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_id'], task_id)
self.assertEquals(output['task_state'], FAILURE)
self.assertEqual(output['message'], TEST_FAILURE_MESSAGE)
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_id'], task_id)
self.assertEqual(output['task_state'], FAILURE)
self.assertFalse(output['in_progress'])
expected_progress = {
'exception': TEST_FAILURE_EXCEPTION,
'message': TEST_FAILURE_MESSAGE,
}
self.assertEquals(output['task_progress'], expected_progress)
self.assertEqual(output['task_progress'], expected_progress)
def test_get_status_from_success(self):
# get status for a task that has already succeeded
@@ -86,10 +86,10 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
task_id = instructor_task.task_id
response = self._get_instructor_task_status(task_id)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(output['message'], "Problem rescored for 2 of 3 students (out of 5)")
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_id'], task_id)
self.assertEquals(output['task_state'], SUCCESS)
self.assertEqual(output['message'], "Problem rescored for 2 of 3 students (out of 5)")
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_id'], task_id)
self.assertEqual(output['task_state'], SUCCESS)
self.assertFalse(output['in_progress'])
expected_progress = {
'attempted': 3,
@@ -97,7 +97,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
'total': 5,
'action_name': 'rescored',
}
self.assertEquals(output['task_progress'], expected_progress)
self.assertEqual(output['task_progress'], expected_progress)
def test_get_status_from_legacy_success(self):
# get status for a task that had already succeeded, back at a time
@@ -112,12 +112,12 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
task_id = instructor_task.task_id
response = self._get_instructor_task_status(task_id)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(output['message'], "Problem rescored for 2 of 3 students (out of 5)")
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_id'], task_id)
self.assertEquals(output['task_state'], SUCCESS)
self.assertEqual(output['message'], "Problem rescored for 2 of 3 students (out of 5)")
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_id'], task_id)
self.assertEqual(output['task_state'], SUCCESS)
self.assertFalse(output['in_progress'])
self.assertEquals(output['task_progress'], legacy_progress)
self.assertEqual(output['task_progress'], legacy_progress)
def _create_email_subtask_entry(self, total=5, attempted=3, succeeded=2, skipped=0, task_state=PROGRESS):
"""Create an InstructorTask with subtask defined and email argument."""
@@ -140,10 +140,10 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
task_id = instructor_task.task_id
response = self._get_instructor_task_status(task_id)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(output['message'], "Progress: emailed 2 of 3 so far (skipping 1) (out of 5)")
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_id'], task_id)
self.assertEquals(output['task_state'], PROGRESS)
self.assertEqual(output['message'], "Progress: emailed 2 of 3 so far (skipping 1) (out of 5)")
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_id'], task_id)
self.assertEqual(output['task_state'], PROGRESS)
self.assertTrue(output['in_progress'])
expected_progress = {
'attempted': 3,
@@ -152,7 +152,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
'total': 5,
'action_name': 'emailed',
}
self.assertEquals(output['task_progress'], expected_progress)
self.assertEqual(output['task_progress'], expected_progress)
def _test_get_status_from_result(self, task_id, mock_result=None):
"""
@@ -162,7 +162,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
mock_result_ctor.return_value = mock_result
response = self._get_instructor_task_status(task_id)
output = json.loads(response.content.decode('utf-8'))
self.assertEquals(output['task_id'], task_id)
self.assertEqual(output['task_id'], task_id)
return output
def test_get_status_to_pending(self):
@@ -175,7 +175,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
output = self._test_get_status_from_result(task_id, mock_result)
for key in ['message', 'succeeded', 'task_progress']:
self.assertNotIn(key, output)
self.assertEquals(output['task_state'], 'PENDING')
self.assertEqual(output['task_state'], 'PENDING')
self.assertTrue(output['in_progress'])
def test_update_progress_to_progress(self):
@@ -192,11 +192,11 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
'action_name': 'rescored',
}
output = self._test_get_status_from_result(task_id, mock_result)
self.assertEquals(output['message'], "Progress: rescored 4 of 5 so far (out of 10)")
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_state'], PROGRESS)
self.assertEqual(output['message'], "Progress: rescored 4 of 5 so far (out of 10)")
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_state'], PROGRESS)
self.assertTrue(output['in_progress'])
self.assertEquals(output['task_progress'], mock_result.result)
self.assertEqual(output['task_progress'], mock_result.result)
def test_update_progress_to_failure(self):
# view task entry for task in progress that later fails
@@ -208,16 +208,16 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
mock_result.result = NotImplementedError("This task later failed.")
mock_result.traceback = "random traceback"
output = self._test_get_status_from_result(task_id, mock_result)
self.assertEquals(output['message'], "This task later failed.")
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_state'], FAILURE)
self.assertEqual(output['message'], "This task later failed.")
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_state'], FAILURE)
self.assertFalse(output['in_progress'])
expected_progress = {
'exception': 'NotImplementedError',
'message': "This task later failed.",
'traceback': "random traceback",
}
self.assertEquals(output['task_progress'], expected_progress)
self.assertEqual(output['task_progress'], expected_progress)
def test_update_progress_to_revoked(self):
# view task entry for task in progress that later fails
@@ -227,12 +227,12 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
mock_result.task_id = task_id
mock_result.state = REVOKED
output = self._test_get_status_from_result(task_id, mock_result)
self.assertEquals(output['message'], "Task revoked before running")
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_state'], REVOKED)
self.assertEqual(output['message'], "Task revoked before running")
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_state'], REVOKED)
self.assertFalse(output['in_progress'])
expected_progress = {'message': "Task revoked before running"}
self.assertEquals(output['task_progress'], expected_progress)
self.assertEqual(output['task_progress'], expected_progress)
def _get_output_for_task_success(self, attempted, succeeded, total, student=None):
"""returns the task_id and the result returned by instructor_task_status()."""
@@ -264,9 +264,9 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
def test_update_progress_to_success(self):
output = self._get_output_for_task_success(10, 8, 10)
self.assertEquals(output['message'], "Problem rescored for 8 of 10 students")
self.assertEquals(output['succeeded'], False)
self.assertEquals(output['task_state'], SUCCESS)
self.assertEqual(output['message'], "Problem rescored for 8 of 10 students")
self.assertEqual(output['succeeded'], False)
self.assertEqual(output['task_state'], SUCCESS)
self.assertFalse(output['in_progress'])
expected_progress = {
'attempted': 10,
@@ -274,7 +274,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
'total': 10,
'action_name': 'rescored',
}
self.assertEquals(output['task_progress'], expected_progress)
self.assertEqual(output['task_progress'], expected_progress)
def test_success_messages(self):
output = self._get_output_for_task_success(0, 0, 10)
@@ -355,7 +355,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
instructor_task = self._create_entry()
succeeded, message = get_task_completion_info(instructor_task)
self.assertFalse(succeeded)
self.assertEquals(message, "No status information available")
self.assertEqual(message, "No status information available")
def test_get_info_for_missing_output(self):
# check for missing task_output
@@ -363,7 +363,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
instructor_task.task_output = None
succeeded, message = get_task_completion_info(instructor_task)
self.assertFalse(succeeded)
self.assertEquals(message, "No status information available")
self.assertEqual(message, "No status information available")
def test_get_info_for_broken_output(self):
# check for non-JSON task_output
@@ -371,7 +371,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
instructor_task.task_output = u"{ bad"
succeeded, message = get_task_completion_info(instructor_task)
self.assertFalse(succeeded)
self.assertEquals(message, "No parsable status information available")
self.assertEqual(message, "No parsable status information available")
def test_get_info_for_empty_output(self):
# check for JSON task_output with missing keys
@@ -379,7 +379,7 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
instructor_task.task_output = "{}"
succeeded, message = get_task_completion_info(instructor_task)
self.assertFalse(succeeded)
self.assertEquals(message, "No progress status information available")
self.assertEqual(message, "No progress status information available")
def test_get_info_for_broken_input(self):
# check for non-JSON task_input, but then just ignore it
@@ -387,4 +387,4 @@ class InstructorTaskReportTest(InstructorTaskTestCase):
instructor_task.task_input = u"{ bad"
succeeded, message = get_task_completion_info(instructor_task)
self.assertFalse(succeeded)
self.assertEquals(message, "Status: rescored 2 of 3 (out of 5)")
self.assertEqual(message, "Status: rescored 2 of 3 (out of 5)")