diff --git a/cms/djangoapps/contentstore/views/tests/test_block.py b/cms/djangoapps/contentstore/views/tests/test_block.py index 01aff3d613c1..2b21a9b9b970 100644 --- a/cms/djangoapps/contentstore/views/tests/test_block.py +++ b/cms/djangoapps/contentstore/views/tests/test_block.py @@ -86,6 +86,7 @@ add_container_page_publishing_info, create_xblock_info, ) +from common.test.utils import assert_dict_contains_subset class AsideTest(XBlockAside): @@ -863,7 +864,8 @@ def test_duplicate_event(self): XBLOCK_DUPLICATED.connect(event_receiver) usage_key = self._duplicate_and_verify(self.vert_usage_key, self.seq_usage_key) event_receiver.assert_called() - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": XBLOCK_DUPLICATED, "sender": None, diff --git a/common/djangoapps/student/tests/test_events.py b/common/djangoapps/student/tests/test_events.py index f336396e6e71..7c9d625118d0 100644 --- a/common/djangoapps/student/tests/test_events.py +++ b/common/djangoapps/student/tests/test_events.py @@ -36,6 +36,7 @@ from xmodule.modulestore.tests.django_utils import \ SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order +from common.test.utils import assert_dict_contains_subset class TestUserProfileEvents(UserSettingsEventTestMixin, TestCase): @@ -271,7 +272,8 @@ def test_enrollment_created_event_emitted(self): enrollment = CourseEnrollment.enroll(self.user, self.course.id) self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": COURSE_ENROLLMENT_CREATED, "sender": None, @@ -294,7 +296,7 @@ def test_enrollment_created_event_emitted(self): creation_date=enrollment.created, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) def test_enrollment_changed_event_emitted(self): @@ -314,7 +316,8 @@ def test_enrollment_changed_event_emitted(self): enrollment.update_enrollment(mode="verified") self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": COURSE_ENROLLMENT_CHANGED, "sender": None, @@ -337,7 +340,7 @@ def test_enrollment_changed_event_emitted(self): creation_date=enrollment.created, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) def test_unenrollment_completed_event_emitted(self): @@ -357,7 +360,8 @@ def test_unenrollment_completed_event_emitted(self): CourseEnrollment.unenroll(self.user, self.course.id) self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": COURSE_UNENROLLMENT_COMPLETED, "sender": None, @@ -380,7 +384,7 @@ def test_unenrollment_completed_event_emitted(self): creation_date=enrollment.created, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) @@ -430,7 +434,8 @@ def test_access_role_created_event_emitted(self, AccessRole): role.add_users(self.user) self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": COURSE_ACCESS_ROLE_ADDED, "sender": None, @@ -448,7 +453,7 @@ def test_access_role_created_event_emitted(self, AccessRole): role=role._role_name, # pylint: disable=protected-access ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) @ddt.data( @@ -468,7 +473,8 @@ def test_access_role_removed_event_emitted(self, AccessRole): role.remove_users(self.user) self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": COURSE_ACCESS_ROLE_REMOVED, "sender": None, @@ -486,5 +492,5 @@ def test_access_role_removed_event_emitted(self, AccessRole): role=role._role_name, # pylint: disable=protected-access ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) diff --git a/common/djangoapps/third_party_auth/tests/specs/test_testshib.py b/common/djangoapps/third_party_auth/tests/specs/test_testshib.py index caddd325ba76..18059ac6873c 100644 --- a/common/djangoapps/third_party_auth/tests/specs/test_testshib.py +++ b/common/djangoapps/third_party_auth/tests/specs/test_testshib.py @@ -30,6 +30,7 @@ from openedx.features.enterprise_support.tests.factories import EnterpriseCustomerFactory from .base import IntegrationTestMixin +from common.test.utils import assert_dict_contains_subset TESTSHIB_ENTITY_ID = "https://idp.testshib.org/idp/shibboleth" TESTSHIB_METADATA_URL = "https://mock.testshib.org/metadata/testshib-providers.xml" @@ -402,8 +403,10 @@ def test_debug_mode_login(self, debug_mode_enabled): assert msg.startswith("SAML login %s") assert action_type == "request" assert idp_name == self.PROVIDER_IDP_SLUG - self.assertDictContainsSubset( - {"idp": idp_name, "auth_entry": "login", "next": expected_next_url}, request_data + assert_dict_contains_subset( + self, + {"idp": idp_name, "auth_entry": "login", "next": expected_next_url}, + request_data, ) assert next_url == expected_next_url assert " Section > Subsection > Problem1', - 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', - 'title': 'Problem1', - }, student_data[0]) + assert_dict_contains_subset( + self, + { + 'username': 'student', + 'location': 'test_course > Section > Subsection > Problem1', + 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', + 'title': 'Problem1', + }, + student_data[0], + ) assert 'state' in student_data[0] assert student_data_keys_list == ['username', 'title', 'location', 'block_key', 'state'] mock_list_problem_responses.assert_called_with(self.course.id, ANY, ANY) @@ -569,22 +576,30 @@ def test_build_student_data_for_block_with_mock_generate_report_data(self, mock_ usage_key_str_list=[str(self.course.location)], ) assert len(student_data) == 2 - self.assertDictContainsSubset({ - 'username': 'student', - 'location': 'test_course > Section > Subsection > Problem1', - 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', - 'title': 'Problem1', - 'some': 'state1', - 'more': 'state1!', - }, student_data[0]) - self.assertDictContainsSubset({ - 'username': 'student', - 'location': 'test_course > Section > Subsection > Problem1', - 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', - 'title': 'Problem1', - 'some': 'state2', - 'more': 'state2!', - }, student_data[1]) + assert_dict_contains_subset( + self, + { + 'username': 'student', + 'location': 'test_course > Section > Subsection > Problem1', + 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', + 'title': 'Problem1', + 'some': 'state1', + 'more': 'state1!', + }, + student_data[0], + ) + assert_dict_contains_subset( + self, + { + 'username': 'student', + 'location': 'test_course > Section > Subsection > Problem1', + 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', + 'title': 'Problem1', + 'some': 'state2', + 'more': 'state2!', + }, + student_data[1], + ) assert student_data[0]['state'] == student_data[1]['state'] assert student_data_keys_list == ['username', 'title', 'location', 'more', 'some', 'block_key', 'state'] @@ -610,22 +625,30 @@ def test_build_student_data_for_block_with_ordered_generate_report_data(self, mo usage_key_str_list=[str(self.course.location)], ) assert len(student_data) == 2 - self.assertDictContainsSubset({ - 'username': 'student', - 'location': 'test_course > Section > Subsection > Problem1', - 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', - 'title': 'Problem1', - 'some': 'state1', - 'more': 'state1!', - }, student_data[0]) - self.assertDictContainsSubset({ - 'username': 'student', - 'location': 'test_course > Section > Subsection > Problem1', - 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', - 'title': 'Problem1', - 'some': 'state2', - 'more': 'state2!', - }, student_data[1]) + assert_dict_contains_subset( + self, + { + 'username': 'student', + 'location': 'test_course > Section > Subsection > Problem1', + 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', + 'title': 'Problem1', + 'some': 'state1', + 'more': 'state1!', + }, + student_data[0], + ) + assert_dict_contains_subset( + self, + { + 'username': 'student', + 'location': 'test_course > Section > Subsection > Problem1', + 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', + 'title': 'Problem1', + 'some': 'state2', + 'more': 'state2!', + }, + student_data[1], + ) assert student_data[0]['state'] == student_data[1]['state'] assert student_data_keys_list == ['username', 'title', 'location', 'some', 'more', 'block_key', 'state'] @@ -642,16 +665,20 @@ def test_build_student_data_for_block_with_real_generate_report_data(self): usage_key_str_list=[str(self.course.location)], ) assert len(student_data) == 1 - self.assertDictContainsSubset({ - 'username': 'student', - 'location': 'test_course > Section > Subsection > Problem1', - 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', - 'title': 'Problem1', - 'Answer ID': 'Problem1_2_1', - 'Answer': 'Option 1', - 'Correct Answer': 'Option 1', - 'Question': 'The correct answer is Option 1', - }, student_data[0]) + assert_dict_contains_subset( + self, + { + 'username': 'student', + 'location': 'test_course > Section > Subsection > Problem1', + 'block_key': 'block-v1:edx+1.23x+test_course+type@problem+block@Problem1', + 'title': 'Problem1', + 'Answer ID': 'Problem1_2_1', + 'Answer': 'Option 1', + 'Correct Answer': 'Option 1', + 'Question': 'The correct answer is Option 1', + }, + student_data[0], + ) assert 'state' in student_data[0] assert student_data_keys_list == ['username', 'title', 'location', 'Answer', 'Answer ID', 'Correct Answer', 'Question', 'block_key', 'state'] @@ -671,16 +698,20 @@ def test_build_student_data_for_multiple_problems(self): ) assert len(student_data) == 2 for idx in range(1, 3): - self.assertDictContainsSubset({ - 'username': 'student', - 'location': f'test_course > Section > Subsection > Problem{idx}', - 'block_key': f'block-v1:edx+1.23x+test_course+type@problem+block@Problem{idx}', - 'title': f'Problem{idx}', - 'Answer ID': f'Problem{idx}_2_1', - 'Answer': 'Option 1', - 'Correct Answer': 'Option 1', - 'Question': 'The correct answer is Option 1', - }, student_data[idx - 1]) + assert_dict_contains_subset( + self, + { + 'username': 'student', + 'location': f'test_course > Section > Subsection > Problem{idx}', + 'block_key': f'block-v1:edx+1.23x+test_course+type@problem+block@Problem{idx}', + 'title': f'Problem{idx}', + 'Answer ID': f'Problem{idx}_2_1', + 'Answer': 'Option 1', + 'Correct Answer': 'Option 1', + 'Question': 'The correct answer is Option 1', + }, + student_data[idx - 1], + ) assert 'state' in student_data[(idx - 1)] @ddt.data( @@ -819,7 +850,11 @@ def test_no_problems(self, use_tempfile, _): """ with patch(USE_ON_DISK_GRADE_REPORT, return_value=use_tempfile): result = ProblemGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset({'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset( + self, + {'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, + result + ) self.verify_rows_in_csv([ dict(list(zip( self.csv_header_row, @@ -845,7 +880,11 @@ def test_single_problem(self, use_tempfile, _): self.submit_student_answer(self.student_1.username, 'Problem1', ['Option 1']) with patch(USE_ON_DISK_GRADE_REPORT, return_value=use_tempfile): result = ProblemGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset({'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset( + self, + {'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, + result + ) problem_name = 'Homework 1: Subsection - Problem1' header_row = self.csv_header_row + [problem_name + ' (Earned)', problem_name + ' (Possible)'] self.verify_rows_in_csv([ @@ -891,8 +930,10 @@ def test_single_problem_verified_student_only(self, use_tempfile, _): self.submit_student_answer(student_verified.username, 'Problem1', ['Option 1']) with patch(USE_ON_DISK_GRADE_REPORT, return_value=use_tempfile): result = ProblemGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset( - {'action_name': 'graded', 'attempted': 1, 'succeeded': 1, 'failed': 0}, result + assert_dict_contains_subset( + self, + {'action_name': 'graded', 'attempted': 1, 'succeeded': 1, 'failed': 0}, + result, ) @patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task') @@ -913,7 +954,11 @@ def test_inactive_enrollment_included(self, use_tempfile, _): self.submit_student_answer(self.student_1.username, 'Problem1', ['Option 1']) with patch(USE_ON_DISK_GRADE_REPORT, return_value=use_tempfile): result = ProblemGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset({'action_name': 'graded', 'attempted': 3, 'succeeded': 3, 'failed': 0}, result) + assert_dict_contains_subset( + self, + {'action_name': 'graded', 'attempted': 3, 'succeeded': 3, 'failed': 0}, + result + ) problem_name = 'Homework 1: Subsection - Problem1' header_row = self.csv_header_row + [problem_name + ' (Earned)', problem_name + ' (Possible)'] self.verify_rows_in_csv([ @@ -987,8 +1032,10 @@ def test_problem_grade_report(self, use_tempfile): with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'): with patch(USE_ON_DISK_GRADE_REPORT, return_value=use_tempfile): result = ProblemGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset( - {'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, result + assert_dict_contains_subset( + self, + {'action_name': 'graded', 'attempted': 2, 'succeeded': 2, 'failed': 0}, + result, ) problem_names = ['Homework 1: Subsection - problem_a_url', 'Homework 1: Subsection - problem_b_url'] @@ -1143,8 +1190,10 @@ def test_cohort_content(self, use_tempfile): with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'): with patch(USE_ON_DISK_GRADE_REPORT, return_value=use_tempfile): result = ProblemGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset( - {'action_name': 'graded', 'attempted': 5, 'succeeded': 5, 'failed': 0}, result + assert_dict_contains_subset( + self, + {'action_name': 'graded', 'attempted': 5, 'succeeded': 5, 'failed': 0}, + result, ) problem_names = ['Homework 1: Subsection - Problem0', 'Homework 1: Subsection - Problem1'] header_row = ['Student ID', 'Email', 'Username', 'Enrollment Status', 'Grade'] @@ -1228,7 +1277,7 @@ def test_successfully_generate_course_survey_report(self): None, None, self.course.id, task_input, 'generating course survey report' ) - self.assertDictContainsSubset({'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'attempted': 2, 'succeeded': 2, 'failed': 0}, result) def test_generate_course_survey_report(self): """ @@ -1262,7 +1311,7 @@ def test_generate_course_survey_report(self): ]) expected_data = [header_row, student1_row, student2_row] - self.assertDictContainsSubset({'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self._verify_csv_file_report(report_store, expected_data) def _verify_csv_file_report(self, report_store, expected_data): @@ -1297,7 +1346,7 @@ def test_success(self): links = report_store.links_for(self.course.id) assert len(links) == 1 - self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result) + assert_dict_contains_subset(self, {'attempted': 1, 'succeeded': 1, 'failed': 0}, result) def test_custom_directory(self): self.create_student('student', 'student@example.com') @@ -1352,7 +1401,7 @@ def test_unicode_usernames(self, students): result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') # This assertion simply confirms that the generation completed with no errors num_students = len(students) - self.assertDictContainsSubset({'attempted': num_students, 'succeeded': num_students, 'failed': 0}, result) + assert_dict_contains_subset(self, {'attempted': num_students, 'succeeded': num_students, 'failed': 0}, result) class TestTeamStudentReport(TestReportMixin, InstructorTaskCourseTestCase): @@ -1382,7 +1431,7 @@ def _generate_and_verify_teams_column(self, username, expected_team): with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task') as mock_current_task: mock_current_task.return_value = current_task result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') - self.assertDictContainsSubset({'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'attempted': 2, 'succeeded': 2, 'failed': 0}, result) report_store = ReportStore.from_config(config_name='GRADES_DOWNLOAD') report_csv_filename = report_store.links_for(self.course.id)[0][0] report_path = report_store.path_to(self.course.id, report_csv_filename) @@ -1447,7 +1496,7 @@ def test_success(self): links = report_store.links_for(self.course.id) assert len(links) == 1 - self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result) + assert_dict_contains_subset(self, {'attempted': 1, 'succeeded': 1, 'failed': 0}, result) def test_unicode_email_addresses(self): """ @@ -1463,7 +1512,11 @@ def test_unicode_email_addresses(self): result = upload_may_enroll_csv(None, None, self.course.id, task_input, 'calculated') # This assertion simply confirms that the generation completed with no errors num_enrollments = len(enrollments) - self.assertDictContainsSubset({'attempted': num_enrollments, 'succeeded': num_enrollments, 'failed': 0}, result) + assert_dict_contains_subset( + self, + {'attempted': num_enrollments, 'succeeded': num_enrollments, 'failed': 0}, + result + ) class MockDefaultStorage: @@ -1510,7 +1563,7 @@ def test_username(self): 'student_1\xec,,Cohort 1\n' 'student_2,,Cohort 2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '1', '', '', '']))), @@ -1525,7 +1578,7 @@ def test_email(self): ',student_1@example.com,Cohort 1\n' ',student_2@example.com,Cohort 2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '1', '', '', '']))), @@ -1540,7 +1593,7 @@ def test_username_and_email(self): 'student_1\xec,student_1@example.com,Cohort 1\n' 'student_2,student_2@example.com,Cohort 2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '1', '', '', '']))), @@ -1561,7 +1614,7 @@ def test_prefer_email(self): 'student_1\xec,student_1@example.com,Cohort 1\n' # valid username and email 'Invalid,student_2@example.com,Cohort 2' # invalid username, valid email ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '1', '', '', '']))), @@ -1575,7 +1628,7 @@ def test_non_existent_user(self): 'username,email,cohort\n' 'Invalid,,Cohort 1\n' ) - self.assertDictContainsSubset({'total': 1, 'attempted': 1, 'succeeded': 0, 'failed': 1}, result) + assert_dict_contains_subset(self, {'total': 1, 'attempted': 1, 'succeeded': 0, 'failed': 1}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '0', 'Invalid', '', '']))), @@ -1589,7 +1642,7 @@ def test_non_existent_cohort(self): ',student_1@example.com,Does Not Exist\n' 'student_2,,Cohort 2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 1, 'failed': 1}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 1, 'failed': 1}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Does Not Exist', 'False', '0', '', '', '']))), @@ -1603,8 +1656,11 @@ def test_preassigned_user(self): 'username,email,cohort\n' ',example_email@example.com,Cohort 1' ) - self.assertDictContainsSubset({'total': 1, 'attempted': 1, 'succeeded': 0, 'failed': 0}, - result) + assert_dict_contains_subset( + self, + {'total': 1, 'attempted': 1, 'succeeded': 0, 'failed': 0}, + result, + ) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '0', '', '', 'example_email@example.com']))), @@ -1617,7 +1673,7 @@ def test_invalid_email(self): 'username,email,cohort\n' ',student_1@,Cohort 1\n' ) - self.assertDictContainsSubset({'total': 1, 'attempted': 1, 'succeeded': 0, 'failed': 1}, result) + assert_dict_contains_subset(self, {'total': 1, 'attempted': 1, 'succeeded': 0, 'failed': 1}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '0', '', 'student_1@', '']))), @@ -1642,7 +1698,7 @@ def test_too_few_commas(self): 'student_1\xec,\n' 'student_2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 0, 'failed': 2}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 0, 'failed': 2}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['', 'False', '0', '', '', '']))), @@ -1654,7 +1710,7 @@ def test_only_header_row(self): result = self._cohort_students_and_upload( 'username,email,cohort' ) - self.assertDictContainsSubset({'total': 0, 'attempted': 0, 'succeeded': 0, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 0, 'attempted': 0, 'succeeded': 0, 'failed': 0}, result) self.verify_rows_in_csv([]) def test_carriage_return(self): @@ -1666,7 +1722,7 @@ def test_carriage_return(self): 'student_1\xec,,Cohort 1\r' 'student_2,,Cohort 2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '1', '', '', '']))), @@ -1684,7 +1740,7 @@ def test_carriage_return_line_feed(self): 'student_1\xec,,Cohort 1\r\n' 'student_2,,Cohort 2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '1', '', '', '']))), @@ -1704,7 +1760,7 @@ def test_move_users_to_new_cohort(self): 'student_1\xec,,Cohort 2\n' 'student_2,,Cohort 1' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'succeeded': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '1', '', '', '']))), @@ -1724,7 +1780,7 @@ def test_move_users_to_same_cohort(self): 'student_1\xec,,Cohort 1\n' 'student_2,,Cohort 2' ) - self.assertDictContainsSubset({'total': 2, 'attempted': 2, 'skipped': 2, 'failed': 0}, result) + assert_dict_contains_subset(self, {'total': 2, 'attempted': 2, 'skipped': 2, 'failed': 0}, result) self.verify_rows_in_csv( [ dict(list(zip(self.csv_header_row, ['Cohort 1', 'True', '0', '', '', '']))), @@ -1809,7 +1865,8 @@ def test_grade_report(self): with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'): result = CourseGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, {'action_name': 'graded', 'attempted': 1, 'succeeded': 1, 'failed': 0}, result, ) @@ -1868,7 +1925,8 @@ def test_grade_report_with_overrides(self): with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'): result = CourseGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, {'action_name': 'graded', 'attempted': 1, 'succeeded': 1, 'failed': 0}, result, ) @@ -1912,8 +1970,10 @@ def test_course_grade_with_verified_student_only(self, _get_current_task): self.submit_student_answer(student_1.username, 'Problem4', ['Option 1']) self.submit_student_answer(student_verified.username, 'Problem4', ['Option 1']) result = CourseGradeReport.generate(None, None, self.course.id, {}, 'graded') - self.assertDictContainsSubset( - {'action_name': 'graded', 'attempted': 1, 'succeeded': 1, 'failed': 0}, result + assert_dict_contains_subset( + self, + {'action_name': 'graded', 'attempted': 1, 'succeeded': 1, 'failed': 0}, + result, ) @ddt.data(True, False) @@ -2517,9 +2577,10 @@ def assertCertificatesGenerated(self, task_input, expected_results): None, None, self.course.id, task_input, 'certificates generated' ) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, expected_results, - result + result, ) def _create_students(self, number_of_students): diff --git a/lms/djangoapps/support/tests/test_views.py b/lms/djangoapps/support/tests/test_views.py index 4abc4508ea35..df713daf0b98 100644 --- a/lms/djangoapps/support/tests/test_views.py +++ b/lms/djangoapps/support/tests/test_views.py @@ -52,7 +52,7 @@ UserFactory, ) from common.djangoapps.third_party_auth.tests.factories import SAMLProviderConfigFactory -from common.test.utils import disable_signal +from common.test.utils import disable_signal, assert_dict_contains_subset from lms.djangoapps.program_enrollments.tests.factories import ProgramCourseEnrollmentFactory, ProgramEnrollmentFactory from lms.djangoapps.support.models import CourseResetAudit from lms.djangoapps.support.serializers import ProgramEnrollmentSerializer @@ -343,14 +343,18 @@ def test_get_enrollments(self, search_string_type): assert response.status_code == 200 data = json.loads(response.content.decode('utf-8')) assert len(data) == 1 - self.assertDictContainsSubset({ - 'mode': CourseMode.AUDIT, - 'manual_enrollment': {}, - 'user': self.student.username, - 'course_id': str(self.course.id), - 'is_active': True, - 'verified_upgrade_deadline': None, - }, data[0]) + assert_dict_contains_subset( + self, + { + 'mode': CourseMode.AUDIT, + 'manual_enrollment': {}, + 'user': self.student.username, + 'course_id': str(self.course.id), + 'is_active': True, + 'verified_upgrade_deadline': None, + }, + data[0], + ) assert {CourseMode.VERIFIED, CourseMode.AUDIT, CourseMode.HONOR, CourseMode.NO_ID_PROFESSIONAL_MODE, CourseMode.PROFESSIONAL, CourseMode.CREDIT_MODE} == {mode['slug'] for mode in data[0]['course_modes']} assert 'enterprise_course_enrollments' not in data[0] @@ -471,10 +475,14 @@ def test_get_manual_enrollment_history(self): ) response = self.client.get(self.url) assert response.status_code == 200 - self.assertDictContainsSubset({ - 'enrolled_by': self.user.email, - 'reason': 'Financial Assistance', - }, json.loads(response.content.decode('utf-8'))[0]['manual_enrollment']) + assert_dict_contains_subset( + self, + { + 'enrolled_by': self.user.email, + 'reason': 'Financial Assistance', + }, + json.loads(response.content.decode('utf-8'))[0]['manual_enrollment'], + ) @disable_signal(signals, 'post_save') @ddt.data('username', 'email') diff --git a/openedx/core/djangoapps/content_libraries/tests/test_runtime.py b/openedx/core/djangoapps/content_libraries/tests/test_runtime.py index 9cb10e514a60..97699dbf8d6b 100644 --- a/openedx/core/djangoapps/content_libraries/tests/test_runtime.py +++ b/openedx/core/djangoapps/content_libraries/tests/test_runtime.py @@ -27,6 +27,7 @@ from openedx.core.djangolib.testing.utils import skip_unless_lms, skip_unless_cms from openedx.core.lib.xblock_serializer import api as serializer_api from common.djangoapps.student.tests.factories import UserFactory +from common.test.utils import assert_dict_contains_subset class ContentLibraryContentTestMixin: @@ -205,10 +206,14 @@ def test_xblock_metadata(self): assert metadata_view_result.data['display_name'] == 'New Multi Choice Question' assert 'children' not in metadata_view_result.data assert 'editable_children' not in metadata_view_result.data - self.assertDictContainsSubset({ - "content_type": "CAPA", - "problem_types": ["multiplechoiceresponse"], - }, metadata_view_result.data["index_dictionary"]) + assert_dict_contains_subset( + self, + { + "content_type": "CAPA", + "problem_types": ["multiplechoiceresponse"], + }, + metadata_view_result.data["index_dictionary"], + ) assert metadata_view_result.data['student_view_data'] is None # Capa doesn't provide student_view_data @@ -493,11 +498,15 @@ def test_scores_persisted(self): submit_result = client.post(problem_check_url, data={problem_key: "choice_3"}) assert submit_result.status_code == 200 submit_data = json.loads(submit_result.content.decode('utf-8')) - self.assertDictContainsSubset({ - "current_score": 0, - "total_possible": 1, - "attempts_used": 1, - }, submit_data) + assert_dict_contains_subset( + self, + { + "current_score": 0, + "total_possible": 1, + "attempts_used": 1, + }, + submit_data, + ) # Now test that the score is also persisted in StudentModule: # If we add a REST API to get an individual block's score, that should be checked instead of StudentModule. @@ -509,11 +518,15 @@ def test_scores_persisted(self): submit_result = client.post(problem_check_url, data={problem_key: "choice_1"}) assert submit_result.status_code == 200 submit_data = json.loads(submit_result.content.decode('utf-8')) - self.assertDictContainsSubset({ - "current_score": 1, - "total_possible": 1, - "attempts_used": 2, - }, submit_data) + assert_dict_contains_subset( + self, + { + "current_score": 1, + "total_possible": 1, + "attempts_used": 2, + }, + submit_data, + ) # Now test that the score is also updated in StudentModule: # If we add a REST API to get an individual block's score, that should be checked instead of StudentModule. sm = get_score(self.student_a, block_id) diff --git a/openedx/core/djangoapps/course_groups/tests/test_events.py b/openedx/core/djangoapps/course_groups/tests/test_events.py index 616a7bb3f156..f11e95088fd0 100644 --- a/openedx/core/djangoapps/course_groups/tests/test_events.py +++ b/openedx/core/djangoapps/course_groups/tests/test_events.py @@ -18,6 +18,7 @@ from openedx.core.djangoapps.course_groups.tests.helpers import CohortFactory from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order +from common.test.utils import assert_dict_contains_subset @skip_unless_lms @@ -90,7 +91,8 @@ def test_send_cohort_membership_changed_event(self): ) self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": COHORT_MEMBERSHIP_CHANGED, "sender": None, @@ -110,5 +112,5 @@ def test_send_cohort_membership_changed_event(self): name=cohort_membership.course_user_group.name, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) diff --git a/openedx/core/djangoapps/oauth_dispatch/tests/mixins.py b/openedx/core/djangoapps/oauth_dispatch/tests/mixins.py index d99ac4883b18..407a9aac2b84 100644 --- a/openedx/core/djangoapps/oauth_dispatch/tests/mixins.py +++ b/openedx/core/djangoapps/oauth_dispatch/tests/mixins.py @@ -11,6 +11,7 @@ from jwt.exceptions import ExpiredSignatureError from common.djangoapps.student.models import UserProfile, anonymous_id_for_user +from common.test.utils import assert_dict_contains_subset class AccessTokenMixin: @@ -88,7 +89,7 @@ def _decode_jwt(verify_expiration): expected['grant_type'] = grant_type or '' - self.assertDictContainsSubset(expected, payload) + assert_dict_contains_subset(self, expected, payload) if expires_in: assert payload['exp'] == payload['iat'] + expires_in diff --git a/openedx/core/djangoapps/oauth_dispatch/tests/test_api.py b/openedx/core/djangoapps/oauth_dispatch/tests/test_api.py index 3c064cc63c55..5bf1f524bce6 100644 --- a/openedx/core/djangoapps/oauth_dispatch/tests/test_api.py +++ b/openedx/core/djangoapps/oauth_dispatch/tests/test_api.py @@ -9,6 +9,7 @@ from oauth2_provider.models import AccessToken from common.djangoapps.student.tests.factories import UserFactory +from common.test.utils import assert_dict_contains_subset OAUTH_PROVIDER_ENABLED = settings.FEATURES.get('ENABLE_OAUTH2_PROVIDER') if OAUTH_PROVIDER_ENABLED: @@ -43,7 +44,8 @@ def test_create_token_success(self): token = api.create_dot_access_token(HttpRequest(), self.user, self.client) assert token['access_token'] assert token['refresh_token'] - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { 'token_type': 'Bearer', 'expires_in': EXPECTED_DEFAULT_EXPIRES_IN, @@ -63,5 +65,5 @@ def test_create_token_overrides(self): token = api.create_dot_access_token( HttpRequest(), self.user, self.client, expires_in=expires_in, scopes=['profile'], ) - self.assertDictContainsSubset({'scope': 'profile'}, token) - self.assertDictContainsSubset({'expires_in': expires_in}, token) + assert_dict_contains_subset(self, {'scope': 'profile'}, token) + assert_dict_contains_subset(self, {'expires_in': expires_in}, token) diff --git a/openedx/core/djangoapps/oauth_dispatch/tests/test_jwt.py b/openedx/core/djangoapps/oauth_dispatch/tests/test_jwt.py index da95fd072ded..647da14f6edd 100644 --- a/openedx/core/djangoapps/oauth_dispatch/tests/test_jwt.py +++ b/openedx/core/djangoapps/oauth_dispatch/tests/test_jwt.py @@ -12,6 +12,7 @@ from openedx.core.djangoapps.oauth_dispatch.models import RestrictedApplication from openedx.core.djangoapps.oauth_dispatch.tests.mixins import AccessTokenMixin from common.djangoapps.student.tests.factories import UserFactory +from common.test.utils import assert_dict_contains_subset @ddt.ddt @@ -171,7 +172,7 @@ def test_create_jwt_for_user(self, user_email_verified, mock_create_roles): token_payload = self.assert_valid_jwt_access_token( jwt_token, self.user, self.default_scopes, aud=aud, secret=secret, ) - self.assertDictContainsSubset(additional_claims, token_payload) + assert_dict_contains_subset(self, additional_claims, token_payload) assert user_email_verified == token_payload['email_verified'] assert token_payload['roles'] == mock_create_roles.return_value diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py b/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py index 0346aee25ae6..b68774903092 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_auto_auth.py @@ -21,6 +21,7 @@ ) from openedx.core.djangoapps.django_comment_common.utils import seed_permissions_roles from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order +from common.test.utils import assert_dict_contains_subset class AutoAuthTestCase(UrlResetMixin, TestCase): @@ -182,12 +183,13 @@ def test_json_response(self): for key in ['created_status', 'username', 'email', 'password', 'user_id', 'anonymous_id']: assert key in response_data user = User.objects.get(username=response_data['username']) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { 'created_status': 'Logged in', 'anonymous_id': anonymous_id_for_user(user, None), }, - response_data + response_data, ) @ddt.data(*COURSE_IDS_DDT) diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_events.py b/openedx/core/djangoapps/user_authn/views/tests/test_events.py index acec4a935d60..7efd4e4cf5c0 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_events.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_events.py @@ -18,6 +18,7 @@ from common.djangoapps.student.tests.factories import UserFactory, UserProfileFactory from openedx.core.djangoapps.user_api.tests.test_views import UserAPITestCase from openedx.core.djangolib.testing.utils import skip_unless_lms +from common.test.utils import assert_dict_contains_subset @skip_unless_lms @@ -83,7 +84,8 @@ def test_send_registration_event(self): user = User.objects.get(username=self.user_info.get("username")) self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": STUDENT_REGISTRATION_COMPLETED, "sender": None, @@ -97,7 +99,7 @@ def test_send_registration_event(self): is_active=user.is_active, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) @@ -165,7 +167,8 @@ def test_send_login_event(self): user = User.objects.get(username=self.user.username) self.assertTrue(self.receiver_called) - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": SESSION_LOGIN_COMPLETED, "sender": None, @@ -179,5 +182,5 @@ def test_send_login_event(self): is_active=user.is_active, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_login.py b/openedx/core/djangoapps/user_authn/views/tests/test_login.py index b00702ee25da..c8bfa082900b 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_login.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_login.py @@ -44,6 +44,7 @@ from openedx.features.enterprise_support.tests.factories import EnterpriseCustomerUserFactory from common.djangoapps.student.models import LoginFailures from common.djangoapps.util.password_policy_validators import DEFAULT_MAX_PASSWORD_LENGTH +from common.test.utils import assert_dict_contains_subset @ddt.ddt @@ -544,7 +545,7 @@ def test_unicode_mktg_cookie_names(self): expected = { 'target': '/', } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) @patch.dict("django.conf.settings.FEATURES", {'SQUELCH_PII_IN_LOGS': True}) def test_logout_logging_no_pii(self): diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_logout.py b/openedx/core/djangoapps/user_authn/views/tests/test_logout.py index 77c21c86e1b1..a81d11c42cf4 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_logout.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_logout.py @@ -14,6 +14,7 @@ from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationFactory from openedx.core.djangolib.testing.utils import skip_unless_lms from common.djangoapps.student.tests.factories import UserFactory +from common.test.utils import assert_dict_contains_subset @skip_unless_lms @@ -76,14 +77,14 @@ def test_logout_redirect_success(self, redirect_url, host): expected = { 'target': urllib.parse.unquote(redirect_url), } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) def test_no_redirect_supplied(self): response = self.client.get(reverse('logout'), HTTP_HOST='testserver') expected = { 'target': '/', } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) @ddt.data( ('https://www.amazon.org', 'edx.org'), @@ -100,7 +101,7 @@ def test_logout_redirect_failure(self, redirect_url, host): expected = { 'target': '/', } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) def test_client_logout(self): """ Verify the context includes a list of the logout URIs of the authenticated OpenID Connect clients. @@ -113,7 +114,7 @@ def test_client_logout(self): 'logout_uris': [], 'target': '/', } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) @mock.patch( 'django.conf.settings.IDA_LOGOUT_URI_LIST', @@ -138,7 +139,7 @@ def test_client_logout_with_dot_idas(self): 'logout_uris': expected_logout_uris, 'target': '/', } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) @mock.patch( 'django.conf.settings.IDA_LOGOUT_URI_LIST', @@ -161,7 +162,7 @@ def test_client_logout_with_dot_idas_and_no_oidc_idas(self): 'logout_uris': expected_logout_uris, 'target': '/', } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) def test_filter_referring_service(self): """ Verify that, if the user is directed to the logout page from a service, that service's logout URL @@ -174,7 +175,7 @@ def test_filter_referring_service(self): 'target': '/', 'show_tpa_logout_link': False, } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) def test_learner_portal_logout_having_idp_logout_url(self): """ @@ -194,7 +195,7 @@ def test_learner_portal_logout_having_idp_logout_url(self): 'tpa_logout_url': idp_logout_url, 'show_tpa_logout_link': True, } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) @mock.patch('django.conf.settings.TPA_AUTOMATIC_LOGOUT_ENABLED', True) def test_automatic_tpa_logout_url_redirect(self): @@ -214,7 +215,7 @@ def test_automatic_tpa_logout_url_redirect(self): expected = { 'target': idp_logout_url, } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) @mock.patch('django.conf.settings.TPA_AUTOMATIC_LOGOUT_ENABLED', True) def test_no_automatic_tpa_logout_without_logout_url(self): @@ -241,4 +242,4 @@ def test_logout_redirect_failure_with_xss_vulnerability(self, redirect_url, host expected = { 'target': nh3.clean(urllib.parse.unquote(redirect_url)), } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) diff --git a/openedx/features/enterprise_support/tests/test_logout.py b/openedx/features/enterprise_support/tests/test_logout.py index c83b67c3a5e6..cbec23397795 100644 --- a/openedx/features/enterprise_support/tests/test_logout.py +++ b/openedx/features/enterprise_support/tests/test_logout.py @@ -19,6 +19,7 @@ factories ) from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseServiceMockMixin +from common.test.utils import assert_dict_contains_subset @ddt.ddt @@ -60,7 +61,7 @@ def test_logout_enterprise_target(self, redirect_url, enterprise_target): expected = { 'enterprise_target': enterprise_target, } - self.assertDictContainsSubset(expected, response.context_data) + assert_dict_contains_subset(self, expected, response.context_data) if enterprise_target: self.assertContains(response, 'We are signing you in.') diff --git a/xmodule/modulestore/tests/test_mixed_modulestore.py b/xmodule/modulestore/tests/test_mixed_modulestore.py index 1f4bcfac7b0c..f82d1e57c570 100644 --- a/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -63,6 +63,7 @@ from xmodule.modulestore.xml_importer import LocationMixin, import_course_from_xml from xmodule.tests import DATA_DIR, CourseComparisonTest from xmodule.x_module import XModuleMixin +from common.test.utils import assert_dict_contains_subset if not settings.configured: settings.configure() @@ -813,7 +814,8 @@ def test_course_create_event(self, default_ms): event_receiver.assert_called() - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": COURSE_CREATED, "sender": None, @@ -821,7 +823,7 @@ def test_course_create_event(self, default_ms): course_key=test_course.id, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) @ddt.data(ModuleStoreEnum.Type.split) @@ -891,7 +893,8 @@ def test_xblock_publish_event(self, default_ms): self.store.publish(sequential.location, self.user_id) event_receiver.assert_called() - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": XBLOCK_PUBLISHED, "sender": None, @@ -900,7 +903,7 @@ def test_xblock_publish_event(self, default_ms): block_type=sequential.location.block_type, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) @ddt.data(ModuleStoreEnum.Type.split) @@ -925,7 +928,8 @@ def test_xblock_delete_event(self, default_ms): self.store.delete_item(vertical.location, self.user_id) event_receiver.assert_called() - self.assertDictContainsSubset( + assert_dict_contains_subset( + self, { "signal": XBLOCK_DELETED, "sender": None, @@ -934,7 +938,7 @@ def test_xblock_delete_event(self, default_ms): block_type=vertical.location.block_type, ), }, - event_receiver.call_args.kwargs + event_receiver.call_args.kwargs, ) def setup_has_changes(self, default_ms):