assertItemsEqual with six.assertCountEqual
This commit is contained in:
Ayub khan
2019-08-21 16:26:12 +05:00
parent acf3cb684d
commit 8a95a8e520
43 changed files with 167 additions and 103 deletions

View File

@@ -187,7 +187,7 @@ class TestMigrateTranscripts(ModuleStoreTestCase):
Test migrating transcripts
"""
translations = self.video_descriptor.available_translations(self.video_descriptor.get_transcripts_info())
self.assertItemsEqual(translations, ['hr', 'ge'])
six.assertCountEqual(self, translations, ['hr', 'ge'])
self.assertFalse(api.is_transcript_available(self.video_descriptor.edx_video_id, 'hr'))
self.assertFalse(api.is_transcript_available(self.video_descriptor.edx_video_id, 'ge'))
@@ -202,7 +202,7 @@ class TestMigrateTranscripts(ModuleStoreTestCase):
Test migrating transcripts multiple times
"""
translations = self.video_descriptor.available_translations(self.video_descriptor.get_transcripts_info())
self.assertItemsEqual(translations, ['hr', 'ge'])
six.assertCountEqual(self, translations, ['hr', 'ge'])
self.assertFalse(api.is_transcript_available(self.video_descriptor.edx_video_id, 'hr'))
self.assertFalse(api.is_transcript_available(self.video_descriptor.edx_video_id, 'ge'))

View File

@@ -4,6 +4,7 @@ from __future__ import absolute_import
import ddt
import mock
from django.core.management import CommandError, call_command
import six
from six import text_type
from contentstore.courseware_index import SearchIndexingError
@@ -104,7 +105,7 @@ class TestReindexCourse(ModuleStoreTestCase):
patched_yes_no.assert_called_once_with(ReindexCommand.CONFIRMATION_PROMPT, default='no')
expected_calls = self._build_calls(self.first_course, self.second_course)
self.assertItemsEqual(patched_index.mock_calls, expected_calls)
six.assertCountEqual(self, patched_index.mock_calls, expected_calls)
def test_given_all_key_prompts_and_reindexes_all_courses_cancelled(self):
""" Test that does not reindex anything when --all key is given and cancelled """

View File

@@ -104,7 +104,7 @@ class TestReindexLibrary(ModuleStoreTestCase):
patched_yes_no.assert_called_once_with(ReindexCommand.CONFIRMATION_PROMPT, default='no')
expected_calls = self._build_calls(self.first_lib, self.second_lib)
self.assertItemsEqual(patched_index.mock_calls, expected_calls)
six.assertCountEqual(self, patched_index.mock_calls, expected_calls)
def test_given_all_key_prompts_and_reindexes_all_libraries_cancelled(self):
""" Test that does not reindex anything when --all key is given and cancelled """

View File

@@ -554,7 +554,7 @@ class TestCourseOutline(CourseTestCase):
[component for component in advanced_modules if component in deprecated_block_types]
)
self.assertItemsEqual(info['blocks'], expected_blocks)
six.assertCountEqual(self, info['blocks'], expected_blocks)
self.assertEqual(
info['advance_settings_url'],
reverse_course_url('advanced_settings_handler', course_id)

View File

@@ -15,6 +15,7 @@ from django.test import TestCase, override_settings
from django.utils.timezone import now
from mock import patch
from opaque_keys.edx.locator import CourseLocator
import six
from six.moves import zip
from course_modes.helpers import enrollment_mode_display
@@ -399,11 +400,11 @@ class CourseModeModelTest(TestCase):
# Check the selectable modes, which should exclude credit
selectable_modes = CourseMode.modes_for_course_dict(self.course_key)
self.assertItemsEqual(list(selectable_modes.keys()), expected_selectable_modes)
six.assertCountEqual(self, list(selectable_modes.keys()), expected_selectable_modes)
# When we get all unexpired modes, we should see credit as well
all_modes = CourseMode.modes_for_course_dict(self.course_key, only_selectable=False)
self.assertItemsEqual(list(all_modes.keys()), available_modes)
six.assertCountEqual(self, list(all_modes.keys()), available_modes)
def _enrollment_display_modes_dicts(self, dict_type):
"""

View File

@@ -9,6 +9,7 @@ from uuid import uuid4
import ddt
import requests
import six
import six.moves.urllib.parse # pylint: disable=import-error
from six.moves import range
@@ -192,7 +193,7 @@ class StubEdxNotesServiceTest(unittest.TestCase):
updated_note = self._get_notes()[0]
self.assertEqual("new test text", updated_note["text"])
self.assertEqual(note["id"], updated_note["id"])
self.assertItemsEqual(note, updated_note)
six.assertCountEqual(self, note, updated_note)
response = requests.get(self._get_url("api/v1/annotations/does_not_exist"))
self.assertEqual(response.status_code, 404)

View File

@@ -133,7 +133,7 @@ class UserViewsMixin(object):
self.assertEqual(response.status_code, expect_result)
if expect_result == 200:
self.assertIn("active", response.data)
self.assertItemsEqual(response.data["active"], self.expected_active(target_user))
six.assertCountEqual(self, response.data["active"], self.expected_active(target_user))
@ddt.data(
# A server with a valid API key can query any user's list of providers
@@ -149,7 +149,7 @@ class UserViewsMixin(object):
self.assertEqual(response.status_code, expect_result)
if expect_result == 200:
self.assertIn("active", response.data)
self.assertItemsEqual(response.data["active"], self.expected_active(target_user))
six.assertCountEqual(self, response.data["active"], self.expected_active(target_user))
@ddt.data(
(True, ALICE_USERNAME, 200, True),
@@ -352,7 +352,7 @@ class UserMappingViewAPITests(TpaAPITestCase):
if expect_code == 200:
for item in ['results', 'count', 'num_pages']:
self.assertIn(item, response.data)
self.assertItemsEqual(response.data['results'], expect_result)
six.assertCountEqual(self, response.data['results'], expect_result)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')

View File

@@ -3,6 +3,8 @@ Tests related to XBlock support API.
"""
from __future__ import absolute_import
import six
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
from xblock_django.api import authorable_xblocks, deprecated_xblocks, disabled_xblocks
from xblock_django.models import XBlockConfiguration, XBlockStudioConfiguration, XBlockStudioConfigurationFlag
@@ -45,23 +47,23 @@ class XBlockSupportTestCase(CacheIsolationTestCase):
""" Tests the deprecated_xblocks method """
deprecated_xblock_names = [block.name for block in deprecated_xblocks()]
self.assertItemsEqual(["poll", "survey"], deprecated_xblock_names)
six.assertCountEqual(self, ["poll", "survey"], deprecated_xblock_names)
XBlockConfiguration(name="poll", enabled=True, deprecated=False).save()
deprecated_xblock_names = [block.name for block in deprecated_xblocks()]
self.assertItemsEqual(["survey"], deprecated_xblock_names)
six.assertCountEqual(self, ["survey"], deprecated_xblock_names)
def test_disabled_blocks(self):
""" Tests the disabled_xblocks method """
disabled_xblock_names = [block.name for block in disabled_xblocks()]
self.assertItemsEqual(["survey"], disabled_xblock_names)
six.assertCountEqual(self, ["survey"], disabled_xblock_names)
XBlockConfiguration(name="poll", enabled=False, deprecated=True).save()
disabled_xblock_names = [block.name for block in disabled_xblocks()]
self.assertItemsEqual(["survey", "poll"], disabled_xblock_names)
six.assertCountEqual(self, ["survey", "poll"], disabled_xblock_names)
def test_authorable_blocks_empty_model(self):
"""
@@ -79,7 +81,7 @@ class XBlockSupportTestCase(CacheIsolationTestCase):
Tests authorable_xblocks when name is not specified.
"""
authorable_xblock_names = [block.name for block in authorable_xblocks()]
self.assertItemsEqual(["done", "problem", "problem", "html"], authorable_xblock_names)
six.assertCountEqual(self, ["done", "problem", "problem", "html"], authorable_xblock_names)
# Note that "survey" is disabled in XBlockConfiguration, but it is still returned by
# authorable_xblocks because it is marked as enabled and unsupported in XBlockStudioConfiguration.
@@ -87,7 +89,8 @@ class XBlockSupportTestCase(CacheIsolationTestCase):
# is a whitelist and uses a combination of xblock type and template (and in addition has a global feature flag),
# it is expected that Studio code will need to filter by both disabled_xblocks and authorable_xblocks.
authorable_xblock_names = [block.name for block in authorable_xblocks(allow_unsupported=True)]
self.assertItemsEqual(
six.assertCountEqual(
self,
["survey", "done", "problem", "problem", "problem", "html", "split_module"],
authorable_xblock_names
)

View File

@@ -1836,7 +1836,7 @@ class TestMixedModuleStore(CommonMixedModuleStoreSetup):
with check_mongo_calls(max_find, max_send):
found_orphans = self.store.get_orphans(self.course_locations[self.MONGO_COURSEID].course_key)
self.assertItemsEqual(found_orphans, orphan_locations)
six.assertCountEqual(self, found_orphans, orphan_locations)
@ddt.data(ModuleStoreEnum.Type.mongo)
def test_get_non_orphan_parents(self, default_ms):

View File

@@ -7,6 +7,7 @@ from __future__ import absolute_import
import copy
import unittest
import six
import ddt
from bson.objectid import ObjectId
from mock import MagicMock, Mock, call
@@ -169,7 +170,8 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_structure(self.course_key.replace(branch='b'), other_structure)
self.assertConnCalls()
self.bulk._end_bulk_operation(self.course_key)
self.assertItemsEqual(
six.assertCountEqual(
self,
[
call.insert_structure(self.structure, self.course_key),
call.insert_structure(other_structure, self.course_key)
@@ -205,7 +207,8 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_definition(self.course_key.replace(branch='b'), other_definition)
self.bulk.insert_course_index(self.course_key, {'versions': {'a': self.definition['_id'], 'b': other_definition['_id']}})
self.bulk._end_bulk_operation(self.course_key)
self.assertItemsEqual(
six.assertCountEqual(
self,
[
call.insert_definition(self.definition, self.course_key),
call.insert_definition(other_definition, self.course_key),
@@ -236,7 +239,8 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_definition(self.course_key.replace(branch='b'), other_definition)
self.assertConnCalls()
self.bulk._end_bulk_operation(self.course_key)
self.assertItemsEqual(
six.assertCountEqual(
self,
[
call.insert_definition(self.definition, self.course_key),
call.insert_definition(other_definition, self.course_key)
@@ -272,7 +276,8 @@ class TestBulkWriteMixinClosed(TestBulkWriteMixin):
self.bulk.update_structure(self.course_key.replace(branch='b'), other_structure)
self.bulk.insert_course_index(self.course_key, {'versions': {'a': self.structure['_id'], 'b': other_structure['_id']}})
self.bulk._end_bulk_operation(self.course_key)
self.assertItemsEqual(
six.assertCountEqual(
self,
[
call.insert_structure(self.structure, self.course_key),
call.insert_structure(other_structure, self.course_key),
@@ -392,7 +397,7 @@ class TestBulkWriteMixinFindMethods(TestBulkWriteMixin):
expected = matching + db_indexes
self.conn.find_matching_course_indexes.return_value = db_indexes
result = self.bulk.find_matching_course_indexes(branch, search_targets)
self.assertItemsEqual(result, expected)
six.assertCountEqual(self, result, expected)
for item in unmatching:
self.assertNotIn(item, result)
@@ -580,7 +585,7 @@ class TestBulkWriteMixinFindMethods(TestBulkWriteMixin):
self.conn.find_ancestor_structures.return_value = db_match + db_unmatch
results = self.bulk.find_ancestor_structures(original_version, block_id)
self.conn.find_ancestor_structures.assert_called_once_with(original_version, block_id)
self.assertItemsEqual(active_match + db_match, results)
six.assertCountEqual(self, active_match + db_match, results)
@ddt.ddt

View File

@@ -395,7 +395,8 @@ class CourseComparisonTest(TestCase):
}
# Split Mongo and Old-Mongo disagree about what the block_id of courses is, so skip those in
# this comparison
self.assertItemsEqual(
six.assertCountEqual(
self,
[map_key(item.location) for item in expected_items if item.scope_ids.block_type != 'course'],
[key for key in actual_item_map.keys() if key[0] != 'course'],
)

View File

@@ -863,7 +863,7 @@ class ProblemBlockTest(unittest.TestCase):
self.assertEqual(xqueue_interface._http_post.call_count, 1)
_, kwargs = xqueue_interface._http_post.call_args # pylint: disable=unpacking-non-sequence
self.assertItemsEqual(fpaths, list(kwargs['files'].keys()))
six.assertCountEqual(self, fpaths, list(kwargs['files'].keys()))
for fpath, fileobj in six.iteritems(kwargs['files']):
self.assertEqual(fpath, fileobj.name)
@@ -896,7 +896,7 @@ class ProblemBlockTest(unittest.TestCase):
self.assertEqual(xqueue_interface._http_post.call_count, 1)
_, kwargs = xqueue_interface._http_post.call_args # pylint: disable=unpacking-non-sequence
self.assertItemsEqual(fnames, list(kwargs['files'].keys()))
six.assertCountEqual(self, fnames, list(kwargs['files'].keys()))
for fpath, fileobj in six.iteritems(kwargs['files']):
self.assertEqual(fpath, fileobj.name)

View File

@@ -14,6 +14,7 @@ import ddt
import lxml.etree
import mock
import pytz
import six
from django.utils.translation import ugettext_lazy
from fs.osfs import OSFS
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
@@ -136,7 +137,8 @@ class RoundTripTestCase(unittest.TestCase):
course_id = initial_course.id
print("Checking key equality")
self.assertItemsEqual(
six.assertCountEqual(
self,
list(initial_import.modules[course_id].keys()),
list(second_import.modules[course_id].keys())
)

View File

@@ -9,6 +9,7 @@ import json
from datetime import datetime, timedelta
import ddt
import six
from six.moves import range
from openedx.core.lib.tests import attr
@@ -939,4 +940,4 @@ class WordCloudTests(UniqueCourseTest):
self.assertTrue(self.courseware_page.is_word_cloud_rendered)
self.courseware_page.input_word_cloud('test_wordcloud')
self.courseware_page.save_word_cloud()
self.assertItemsEqual(expected_data, self.courseware_page.word_cloud_answer_list)
six.assertCountEqual(self, expected_data, self.courseware_page.word_cloud_answer_list)

View File

@@ -8,6 +8,7 @@ from __future__ import absolute_import
import datetime
import ddt
import six
from common.test.acceptance.fixtures.course import XBlockFixtureDesc
from common.test.acceptance.pages.lms.courseware import CoursewarePage
@@ -297,13 +298,13 @@ class BaseGroupConfigurationsTest(ContainerBase):
"""
Check that the expected partition scheme is selected.
"""
self.assertItemsEqual(expected_scheme, visibility_editor.selected_partition_scheme)
six.assertCountEqual(self, expected_scheme, visibility_editor.selected_partition_scheme)
def verify_selected_groups(self, visibility_editor, expected_groups):
"""
Check the expected partition groups.
"""
self.assertItemsEqual(expected_groups, [group.text for group in visibility_editor.selected_groups])
six.assertCountEqual(self, expected_groups, [group.text for group in visibility_editor.selected_groups])
def select_and_verify_saved(self, component, partition_label, groups=[]):
"""

View File

@@ -10,6 +10,7 @@ from datetime import datetime, timedelta
from unittest import skip
from pytz import UTC
import six
from six.moves import range
from common.test.acceptance.fixtures.config import ConfigModelFixture
@@ -1713,7 +1714,7 @@ class DeprecationWarningMessageTest(CourseOutlineTest):
self.assertEqual(self.course_outline_page.components_visible, components_present)
if components_present:
self.assertEqual(self.course_outline_page.components_list_heading, self.COMPONENT_LIST_HEADING)
self.assertItemsEqual(self.course_outline_page.components_display_names, components_display_name_list)
six.assertCountEqual(self, self.course_outline_page.components_display_names, components_display_name_list)
def test_no_deprecation_warning_message_present(self):
"""

View File

@@ -248,7 +248,7 @@ class BadgeAssertionTest(ModuleStoreTestCase):
Verify that grabbing all assertions for a user behaves as expected.
This function uses object IDs because for some reason Jenkins trips up
on its assertItemsEqual check here despite the items being equal.
on its assertCountEqual check here despite the items being equal.
"""
user = UserFactory()
assertions = [BadgeAssertionFactory.create(user=user).id for _i in range(3)]

View File

@@ -290,7 +290,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
# the 1 is for the instructor in this test and others
self.assertEquals(len(mail.outbox), 1 + len(self.staff))
self.assertItemsEqual(
six.assertCountEqual(
self,
[e.to[0] for e in mail.outbox],
[self.instructor.email] + [s.email for s in self.staff]
)
@@ -311,7 +312,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
response = self.client.post(self.send_mail_url, test_email)
self.assertEquals(json.loads(response.content.decode('utf-8')), self.success_content)
self.assertItemsEqual(
six.assertCountEqual(
self,
[e.to[0] for e in mail.outbox],
[s.email for s in self.students]
)
@@ -352,7 +354,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
response = self.client.post(self.send_mail_url, test_email)
self.assertEquals(json.loads(response.content.decode('utf-8')), self.success_content)
self.assertItemsEqual(
six.assertCountEqual(
self,
[e.to[0] for e in mail.outbox],
[s.email for s in self.students]
)
@@ -410,7 +413,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
# the 1 is for the instructor
self.assertEquals(len(mail.outbox), 1 + len(self.staff) + len(self.students))
self.assertItemsEqual(
six.assertCountEqual(
self,
[e.to[0] for e in mail.outbox],
[self.instructor.email] + [s.email for s in self.staff] + [s.email for s in self.students]
)
@@ -467,7 +471,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
self.assertEquals(json.loads(response.content.decode('utf-8')), self.success_content)
self.assertEquals(len(mail.outbox), 1 + len(self.staff) + len(self.students))
self.assertItemsEqual(
six.assertCountEqual(
self,
[e.to[0] for e in mail.outbox],
[self.instructor.email] + [s.email for s in self.staff] + [s.email for s in self.students]
)
@@ -494,7 +499,8 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
self.assertEquals(len(mail.outbox), 1 + len(self.staff) + len(self.students))
self.assertItemsEqual(
six.assertCountEqual(
self,
[e.to[0] for e in mail.outbox],
[self.instructor.email] + [s.email for s in self.staff] + [s.email for s in self.students]
)
@@ -595,7 +601,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
[s.email for s in self.staff] +
[s.email for s in self.students] +
[s.email for s in added_users if s not in optouts])
self.assertItemsEqual(outbox_contents, should_send_contents)
six.assertCountEqual(self, outbox_contents, should_send_contents)
@skipIf(os.environ.get("TRAVIS") == 'true', "Skip this test in Travis CI.")
@@ -623,7 +629,8 @@ class TestEmailSendFromDashboard(EmailSendFromDashboardTestCase):
self.assertEquals(json.loads(response.content.decode('utf-8')), self.success_content)
self.assertEquals(len(mail.outbox), 1 + len(self.staff) + len(self.students))
self.assertItemsEqual(
six.assertCountEqual(
self,
[e.to[0] for e in mail.outbox],
[self.instructor.email] + [s.email for s in self.staff] + [s.email for s in self.students]
)

View File

@@ -1105,7 +1105,7 @@ class CcxDetailTest(CcxRestApiTest):
)
self.assertEqual(resp.data.get('coach_email'), self.ccx.coach.email) # pylint: disable=no-member
self.assertEqual(resp.data.get('master_course_id'), six.text_type(self.ccx.course_id))
self.assertItemsEqual(resp.data.get('course_modules'), self.master_course_chapters)
six.assertCountEqual(self, resp.data.get('course_modules'), self.master_course_chapters)
@ddt.data(*AUTH_ATTRS)
def test_delete_detail(self, auth_attr):
@@ -1332,19 +1332,19 @@ class CcxDetailTest(CcxRestApiTest):
resp = self.client.patch(self.detail_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
ccx_from_db = CustomCourseForEdX.objects.get(id=self.ccx.id)
self.assertItemsEqual(ccx_from_db.structure, data['course_modules'])
six.assertCountEqual(self, ccx_from_db.structure, data['course_modules'])
data = {'course_modules': []}
resp = self.client.patch(self.detail_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
ccx_from_db = CustomCourseForEdX.objects.get(id=self.ccx.id)
self.assertItemsEqual(ccx_from_db.structure, [])
six.assertCountEqual(self, ccx_from_db.structure, [])
data = {'course_modules': self.master_course_chapters}
resp = self.client.patch(self.detail_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
ccx_from_db = CustomCourseForEdX.objects.get(id=self.ccx.id)
self.assertItemsEqual(ccx_from_db.structure, self.master_course_chapters)
six.assertCountEqual(self, ccx_from_db.structure, self.master_course_chapters)
data = {'course_modules': None}
resp = self.client.patch(self.detail_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
@@ -1357,7 +1357,7 @@ class CcxDetailTest(CcxRestApiTest):
resp = self.client.patch(self.detail_url, data, format='json', HTTP_AUTHORIZATION=getattr(self, auth_attr))
self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
ccx_from_db = CustomCourseForEdX.objects.get(id=self.ccx.id)
self.assertItemsEqual(ccx_from_db.structure, chapters)
six.assertCountEqual(self, ccx_from_db.structure, chapters)
@ddt.data(
('auth', True),
@@ -1381,7 +1381,7 @@ class CcxDetailTest(CcxRestApiTest):
else:
self.assertEqual(resp.status_code, status.HTTP_204_NO_CONTENT)
ccx_from_db = CustomCourseForEdX.objects.get(id=self.ccx.id)
self.assertItemsEqual(ccx_from_db.structure, chapters)
six.assertCountEqual(self, ccx_from_db.structure, chapters)
@ddt.data(
('auth', True),

View File

@@ -762,7 +762,8 @@ class CertificatesBrandingTest(TestCase):
data = certs_api.get_certificate_header_context(is_secure=True)
# Make sure there are not unexpected keys in dict returned by 'get_certificate_header_context'
self.assertItemsEqual(
six.assertCountEqual(
self,
list(data.keys()),
['logo_src', 'logo_url']
)
@@ -787,7 +788,8 @@ class CertificatesBrandingTest(TestCase):
data = certs_api.get_certificate_footer_context()
# Make sure there are not unexpected keys in dict returned by 'get_certificate_footer_context'
self.assertItemsEqual(
six.assertCountEqual(
self,
list(data.keys()),
['company_about_url', 'company_privacy_url', 'company_tos_url']
)

View File

@@ -135,7 +135,8 @@ class CommandsTestBase(SharedModuleStoreTestCase):
self.assertEqual(dump[video_id]['category'], 'video')
video_metadata = dump[video_id]['metadata']
video_metadata.pop('edx_video_id', None)
self.assertItemsEqual(
six.assertCountEqual(
self,
list(video_metadata.keys()),
['youtube_id_0_75', 'youtube_id_1_0', 'youtube_id_1_25', 'youtube_id_1_5']
)

View File

@@ -803,8 +803,8 @@ class ProblemWithUploadedFilesTest(TestSubmittingProblems):
self.assertEqual(name, "post")
self.assertEqual(len(args), 1)
self.assertTrue(args[0].endswith("/submit/"))
self.assertItemsEqual(list(kwargs.keys()), ["files", "data", "timeout"])
self.assertItemsEqual(list(kwargs['files'].keys()), filenames.split())
six.assertCountEqual(self, list(kwargs.keys()), ["files", "data", "timeout"])
six.assertCountEqual(self, list(kwargs['files'].keys()), filenames.split())
class TestPythonGradedResponse(TestSubmittingProblems):

View File

@@ -366,7 +366,7 @@ class TestTranscriptAvailableTranslationsDispatch(TestVideo):
# Make request to available translations dispatch.
request = Request.blank('/available_translations')
response = self.item.transcript(request=request, dispatch='available_translations')
self.assertItemsEqual(json.loads(response.body), result)
six.assertCountEqual(self, json.loads(response.body), result)
@patch('xmodule.video_module.transcripts_utils.edxval_api.get_available_transcript_languages')
def test_val_available_translations_feature_disabled(self, mock_get_available_transcript_languages):

View File

@@ -1576,7 +1576,7 @@ class TestVideoBlockStudentViewJson(BaseTestVideoXBlock, CacheIsolationTestCase)
self.video.transcripts = transcripts
self.video.sub = english_sub
student_view_response = self.get_result()
self.assertItemsEqual(list(student_view_response['transcripts'].keys()), expected_transcripts)
six.assertCountEqual(self, list(student_view_response['transcripts'].keys()), expected_transcripts)
@ddt.ddt

View File

@@ -7,6 +7,7 @@ import json
import ddt
import mock
import six
from django.test import RequestFactory, TestCase
from django.urls import reverse
from edx_django_utils.cache import RequestCache
@@ -1019,7 +1020,8 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
"Topic B": {"id": "Topic_B"},
"Topic C": {"id": "Topic_C"}
}
self.assertItemsEqual(
six.assertCountEqual(
self,
utils.get_discussion_categories_ids(self.course, self.user),
["Topic_A", "Topic_B", "Topic_C"]
)
@@ -1031,7 +1033,8 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
self.create_discussion("Chapter 2 / Section 1 / Subsection 1", "Discussion")
self.create_discussion("Chapter 2 / Section 1 / Subsection 2", "Discussion")
self.create_discussion("Chapter 3 / Section 1", "Discussion")
self.assertItemsEqual(
six.assertCountEqual(
self,
utils.get_discussion_categories_ids(self.course, self.user),
["discussion1", "discussion2", "discussion3", "discussion4", "discussion5", "discussion6"]
)
@@ -1045,7 +1048,8 @@ class CategoryMapTestCase(CategoryMapTestMixin, ModuleStoreTestCase):
self.create_discussion("Chapter 1", "Discussion 1")
self.create_discussion("Chapter 2", "Discussion")
self.create_discussion("Chapter 2 / Section 1 / Subsection 1", "Discussion")
self.assertItemsEqual(
six.assertCountEqual(
self,
utils.get_discussion_categories_ids(self.course, self.user),
["Topic_A", "Topic_B", "Topic_C", "discussion1", "discussion2", "discussion3"]
)

View File

@@ -10,6 +10,7 @@ from unittest import skipUnless
import ddt
import jwt
import six
from six import text_type
from six.moves.urllib.parse import urlparse, parse_qs # pylint: disable=import-error
from django.conf import settings
@@ -334,7 +335,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
}
)
self.assertItemsEqual(
six.assertCountEqual(
self,
{
"count": 2,
"current_page": 1,
@@ -440,7 +442,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
]
})
self.assertItemsEqual(
six.assertCountEqual(
self,
{
"count": 2,
"current_page": 1,
@@ -524,7 +527,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
Tests no results.
"""
mock_get.return_value.content = json.dumps(NOTES_API_EMPTY_RESPONSE)
self.assertItemsEqual(
six.assertCountEqual(
self,
NOTES_VIEW_EMPTY_RESPONSE,
helpers.get_notes(self.request, self.course)
)
@@ -571,7 +575,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
},
]
self.assertItemsEqual(
six.assertCountEqual(
self,
[{
u"quote": u"quote text",
u"text": u"text",
@@ -617,7 +622,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
]
self.html_module_2.visible_to_staff_only = True
self.store.update_item(self.html_module_2, self.user.id)
self.assertItemsEqual(
six.assertCountEqual(
self,
[{
u"quote": u"quote text",
u"text": u"text",
@@ -660,8 +666,10 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
u"updated": datetime(2014, 11, 19, 8, 5, 16, 00000).isoformat(),
}]
self.assertItemsEqual(
[], helpers.preprocess_collection(self.user, self.course, initial_collection)
six.assertCountEqual(
self,
[],
helpers.preprocess_collection(self.user, self.course, initial_collection)
)
@override_settings(NOTES_DISABLED_TABS=['course_structure', 'tags'])
@@ -684,7 +692,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
},
]
self.assertItemsEqual(
six.assertCountEqual(
self,
[
{

View File

@@ -11,6 +11,7 @@ import shutil
from tempfile import mkdtemp
from uuid import uuid4
import six
import unicodecsv
from celery.states import FAILURE, SUCCESS
from django.contrib.auth.models import User
@@ -369,8 +370,8 @@ class TestReportMixin(object):
self.assertEqual(csv_rows, expected_rows)
self.assertEqual(numeric_csv_rows, numeric_expected_rows)
else:
self.assertItemsEqual(csv_rows, expected_rows)
self.assertItemsEqual(numeric_csv_rows, numeric_expected_rows)
six.assertCountEqual(self, csv_rows, expected_rows)
six.assertCountEqual(self, numeric_csv_rows, numeric_expected_rows)
@staticmethod
def _extract_and_round_numeric_items(dictionary):

View File

@@ -1376,12 +1376,12 @@ class InvoiceHistoryTest(TestCase):
def _assert_history_items(self, expected_items):
"""Check line item info in the latest history record. """
items = self._latest_history()['items']
self.assertItemsEqual(items, expected_items)
six.assertCountEqual(self, items, expected_items)
def _assert_history_transactions(self, expected_transactions):
"""Check transactions (payments/refunds) in the latest history record. """
transactions = self._latest_history()['transactions']
self.assertItemsEqual(transactions, expected_transactions)
six.assertCountEqual(self, transactions, expected_transactions)
def _latest_history(self):
"""Retrieve the snapshot from the latest history record. """

View File

@@ -842,7 +842,7 @@ class TestGetProgramsByType(CacheIsolationTestCase):
def test_get_masters_programs(self):
expected_programs = [self.masters_program_1, self.masters_program_2]
self.assertItemsEqual(expected_programs, get_programs_by_type(self.site, 'masters'))
six.assertCountEqual(self, expected_programs, get_programs_by_type(self.site, 'masters'))
def test_get_bachelors_programs(self):
expected_programs = [self.bachelors_program]

View File

@@ -8,6 +8,7 @@ from datetime import datetime
import ddt
import mock
import six
from django.core.management import call_command
from django.utils import six
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
@@ -422,7 +423,7 @@ class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
# 2 nodes and no relationships from the second
self.assertEqual(len(mock_graph.nodes), 11)
self.assertItemsEqual(submitted, self.course_strings)
six.assertCountEqual(self, submitted, self.course_strings)
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.NodeSelector')
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.authenticate_and_create_graph')
@@ -445,7 +446,7 @@ class TestModuleStoreSerializer(TestDumpToNeo4jCommandBase):
number_rollbacks=2,
)
self.assertItemsEqual(submitted, self.course_strings)
six.assertCountEqual(self, submitted, self.course_strings)
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.NodeSelector')
@mock.patch('openedx.core.djangoapps.coursegraph.tasks.authenticate_and_create_graph')

View File

@@ -363,7 +363,8 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
response = self.client.get(reverse('courseenrollments'), {'user': self.user.username}, **kwargs)
self.assertEqual(response.status_code, status.HTTP_200_OK)
data = json.loads(response.content.decode('utf-8'))
self.assertItemsEqual(
six.assertCountEqual(
self,
[(datum['course_details']['course_id'], datum['course_details']['course_name']) for datum in data],
[(six.text_type(course.id), course.display_name_with_default) for course in courses]
)
@@ -1683,4 +1684,4 @@ class CourseEnrollmentsApiListTest(APITestCase, ModuleStoreTestCase):
content = self._assert_list_of_enrollments(query_params, status.HTTP_200_OK)
results = content['results']
self.assertItemsEqual(results, expected_results)
six.assertCountEqual(self, results, expected_results)

View File

@@ -8,6 +8,7 @@ import itertools
import ddt
import mock
import six
from django.conf import settings
from django.contrib.sessions.middleware import SessionMiddleware
from django.http import HttpResponse
@@ -149,7 +150,7 @@ class TestUserPreferenceMiddleware(CacheIsolationTestCase):
accept_lang_out = parse_accept_lang_header(accept_lang_out)
if accept_lang_out and accept_lang_result:
self.assertItemsEqual(accept_lang_result, accept_lang_out)
six.assertCountEqual(self, accept_lang_result, accept_lang_out)
else:
self.assertEqual(accept_lang_result, accept_lang_out)

View File

@@ -674,7 +674,8 @@ class TestProgramProgressMeter(TestCase):
self._create_certificates(unknown['key'], status='unknown')
meter = ProgramProgressMeter(self.site, self.user)
self.assertItemsEqual(
six.assertCountEqual(
self,
meter.completed_course_runs,
[
{'course_run_id': downloadable['key'], 'type': CourseMode.VERIFIED},

View File

@@ -7,6 +7,7 @@ import logging
from unittest import skipUnless
import ddt
import six
from django.conf import settings
from edx_ace import Message
from edx_ace.utils.date import serialize
@@ -86,7 +87,8 @@ class TestUpgradeReminder(ScheduleSendEmailTestMixin, CacheIsolationTestCase):
messages = [Message.from_string(m) for m in sent_messages]
self.assertEqual(len(messages), 1)
message = messages[0]
self.assertItemsEqual(
six.assertCountEqual(
self,
message.context['course_ids'],
[str(schedules[i].enrollment.course.id) for i in (1, 2, 4)]
)

View File

@@ -3,6 +3,7 @@ Tests for helper function provided by site_configuration app.
"""
from __future__ import absolute_import
import six
from django.test import TestCase
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
@@ -81,7 +82,8 @@ class TestHelpers(TestCase):
Test that get_dict returns correct value for any given key.
"""
# Make sure entry is saved and retrieved correctly
self.assertItemsEqual(
six.assertCountEqual(
self,
configuration_helpers.get_dict("REGISTRATION_EXTRA_FIELDS"),
test_config['REGISTRATION_EXTRA_FIELDS'],
)
@@ -91,7 +93,8 @@ class TestHelpers(TestCase):
expected.update(test_config['REGISTRATION_EXTRA_FIELDS'])
# Test that the default value is returned if the value for the given key is not found in the configuration
self.assertItemsEqual(
six.assertCountEqual(
self,
configuration_helpers.get_dict("REGISTRATION_EXTRA_FIELDS", default),
expected,
)
@@ -134,7 +137,8 @@ class TestHelpers(TestCase):
test_config['css_overrides_file']
)
self.assertItemsEqual(
six.assertCountEqual(
self,
configuration_helpers.get_value_for_org(test_org, "REGISTRATION_EXTRA_FIELDS"),
test_config['REGISTRATION_EXTRA_FIELDS']
)
@@ -177,7 +181,8 @@ class TestHelpers(TestCase):
"""
test_orgs = [test_config['course_org_filter']]
with with_site_configuration_context(configuration=test_config):
self.assertItemsEqual(
six.assertCountEqual(
self,
list(configuration_helpers.get_all_orgs()),
test_orgs,
)
@@ -185,7 +190,8 @@ class TestHelpers(TestCase):
@with_site_configuration(configuration=test_config_multi_org)
def test_get_current_site_orgs(self):
test_orgs = test_config_multi_org['course_org_filter']
self.assertItemsEqual(
six.assertCountEqual(
self,
list(configuration_helpers.get_current_site_orgs()),
test_orgs
)

View File

@@ -3,6 +3,7 @@ Tests for Management commands of comprehensive theming.
"""
from __future__ import absolute_import
import six
from django.core.management import CommandError, call_command
from django.test import TestCase
@@ -44,12 +45,16 @@ class TestUpdateAssets(TestCase):
"""
# make sure compile_sass picks all themes when called with 'themes=all' option
parsed_args = Command.parse_arguments(themes=["all"])
self.assertItemsEqual(parsed_args[2], get_themes())
six.assertCountEqual(self, parsed_args[2], get_themes())
# make sure compile_sass picks no themes when called with 'themes=no' option
parsed_args = Command.parse_arguments(themes=["no"])
self.assertItemsEqual(parsed_args[2], [])
six.assertCountEqual(self, parsed_args[2], [])
# make sure compile_sass picks only specified themes
parsed_args = Command.parse_arguments(themes=["test-theme"])
self.assertItemsEqual(parsed_args[2], [theme for theme in get_themes() if theme.theme_dir_name == "test-theme"])
six.assertCountEqual(
self,
parsed_args[2],
[theme for theme in get_themes() if theme.theme_dir_name == "test-theme"]
)

View File

@@ -3,6 +3,7 @@ Test helpers for Comprehensive Theming.
"""
from __future__ import absolute_import
import six
from django.conf import settings
from django.test import TestCase, override_settings
from edx_django_utils.cache import RequestCache
@@ -38,7 +39,7 @@ class TestHelpers(TestCase):
Theme('test-theme', 'test-theme', get_theme_base_dir('test-theme'), settings.PROJECT_ROOT),
]
actual_themes = get_themes()
self.assertItemsEqual(expected_themes, actual_themes)
six.assertCountEqual(self, expected_themes, actual_themes)
@override_settings(COMPREHENSIVE_THEME_DIRS=[settings.TEST_THEME.dirname()])
def test_get_themes_2(self):
@@ -49,7 +50,7 @@ class TestHelpers(TestCase):
Theme('test-theme', 'test-theme', get_theme_base_dir('test-theme'), settings.PROJECT_ROOT),
]
actual_themes = get_themes()
self.assertItemsEqual(expected_themes, actual_themes)
six.assertCountEqual(self, expected_themes, actual_themes)
def test_get_value_returns_override(self):
"""

View File

@@ -11,6 +11,7 @@ import unittest
import ddt
import mock
import pytz
import six
from consent.models import DataSharingConsent
from django.conf import settings
from django.contrib.auth.models import User
@@ -661,7 +662,7 @@ class TestAccountRetirementList(RetirementTestCase):
del retirement['created']
del retirement['modified']
self.assertItemsEqual(response_data, expected_data)
six.assertCountEqual(self, response_data, expected_data)
def test_empty(self):
"""
@@ -834,7 +835,7 @@ class TestAccountRetirementsByStatusAndDate(RetirementTestCase):
except KeyError:
pass
self.assertItemsEqual(response_data, expected_data)
six.assertCountEqual(self, response_data, expected_data)
def test_empty(self):
"""

View File

@@ -12,6 +12,7 @@ from copy import deepcopy
import ddt
import mock
import pytz
import six
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test.testcases import TransactionTestCase
@@ -790,7 +791,7 @@ class TestAccountsAPI(CacheIsolationTestCase, UserAPITestCase):
# than django model id.
for proficiencies in ([{"code": "en"}, {"code": "fr"}, {"code": "es"}], [{"code": "fr"}], [{"code": "aa"}], []):
response = self.send_patch(client, {"language_proficiencies": proficiencies})
self.assertItemsEqual(response.data["language_proficiencies"], proficiencies)
six.assertCountEqual(self, response.data["language_proficiencies"], proficiencies)
@ddt.data(
(

View File

@@ -93,8 +93,9 @@ class UserAPITestCase(ApiTestCase):
def assertUserIsValid(self, user):
"""Assert that the given user result is valid"""
self.assertItemsEqual(list(user.keys()), ["email", "id", "name", "username", "preferences", "url"])
self.assertItemsEqual(
six.assertCountEqual(self, list(user.keys()), ["email", "id", "name", "username", "preferences", "url"])
six.assertCountEqual(
self,
list(user["preferences"].items()),
[(pref.key, pref.value) for pref in self.prefs if pref.user.id == user["id"]]
)
@@ -104,7 +105,7 @@ class UserAPITestCase(ApiTestCase):
"""
Assert that the given preference is acknowledged by the system
"""
self.assertItemsEqual(list(pref.keys()), ["user", "key", "value", "url"])
six.assertCountEqual(self, list(pref.keys()), ["user", "key", "value", "url"])
self.assertSelfReferential(pref)
self.assertUserIsValid(pref["user"])

View File

@@ -5,6 +5,7 @@ from __future__ import absolute_import
import base64
import json
import re
import six
from django.test import TestCase
from django.test.utils import override_settings
@@ -49,7 +50,7 @@ class ApiTestCase(TestCase):
allow_header = resp.get("Allow")
self.assertIsNotNone(allow_header)
allowed_methods = re.split('[^A-Z]+', allow_header)
self.assertItemsEqual(allowed_methods, expected_methods)
six.assertCountEqual(self, allowed_methods, expected_methods)
def assertSelfReferential(self, obj):
"""Assert that accessing the "url" entry in the given object returns the same object"""

View File

@@ -216,7 +216,7 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
course_home_url = reverse('openedx.course_experience.course_home', args=[six.text_type(self.course.id)])
response = self.client.get(course_home_url, follow=True)
self.assertEqual(response.status_code, 200)
self.assertItemsEqual(response.redirect_chain, [])
six.assertCountEqual(self, response.redirect_chain, [])
banner_text = 'You lose all access to this course, including your progress,'
if show_expiration_banner:
self.assertIn(banner_text, response.content)
@@ -281,7 +281,7 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
course_home_url = reverse('openedx.course_experience.course_home', args=[six.text_type(self.course.id)])
response = self.client.get(course_home_url, follow=True)
self.assertEqual(response.status_code, 200)
self.assertItemsEqual(response.redirect_chain, [])
six.assertCountEqual(self, response.redirect_chain, [])
banner_text = 'You lose all access to this course, including your progress,'
self.assertNotIn(banner_text, response.content)
@@ -317,7 +317,7 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
course_home_url = reverse('openedx.course_experience.course_home', args=[six.text_type(self.course.id)])
response = self.client.get(course_home_url, follow=True)
self.assertEqual(response.status_code, 200)
self.assertItemsEqual(response.redirect_chain, [])
six.assertCountEqual(self, response.redirect_chain, [])
banner_text = 'This learner does not have access to this course. Their access expired on'
self.assertIn(banner_text, response.content)
@@ -368,7 +368,7 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
course_home_url = reverse('openedx.course_experience.course_home', args=[six.text_type(self.course.id)])
response = self.client.get(course_home_url, follow=True)
self.assertEqual(response.status_code, 200)
self.assertItemsEqual(response.redirect_chain, [])
six.assertCountEqual(self, response.redirect_chain, [])
banner_text = 'This learner does not have access to this course. Their access expired on'
self.assertNotIn(banner_text, response.content)
@@ -417,6 +417,6 @@ class CourseExpirationTestCase(ModuleStoreTestCase):
course_home_url = reverse('openedx.course_experience.course_home', args=[six.text_type(self.course.id)])
response = self.client.get(course_home_url, follow=True)
self.assertEqual(response.status_code, 200)
self.assertItemsEqual(response.redirect_chain, [])
six.assertCountEqual(self, response.redirect_chain, [])
banner_text = 'This learner does not have access to this course. Their access expired on'
self.assertNotIn(banner_text, response.content)

View File

@@ -7,6 +7,7 @@ from unittest import TestCase
import ddt
import paver.tasks
import six
from mock import patch
from paver.easy import call_task, path
from watchdog.observers import Observer
@@ -78,7 +79,7 @@ class TestPaverAssetTasks(PaverTestCase):
u'rtlcss cms/static/css/bootstrap/studio-main.css cms/static/css/bootstrap/studio-main-rtl.css'
)
self.assertItemsEqual(self.task_messages, expected_messages)
six.assertCountEqual(self, self.task_messages, expected_messages)
@ddt.ddt
@@ -195,7 +196,7 @@ class TestPaverThemeAssetTasks(PaverTestCase):
u'rtlcss cms/static/css/bootstrap/studio-main.css cms/static/css/bootstrap/studio-main-rtl.css'
)
self.assertItemsEqual(self.task_messages, expected_messages)
six.assertCountEqual(self, self.task_messages, expected_messages)
class TestPaverWatchAssetTasks(TestCase):
@@ -245,7 +246,7 @@ class TestPaverWatchAssetTasks(TestCase):
self.assertIsInstance(sass_watcher_args[0], Observer)
self.assertIsInstance(sass_watcher_args[1], list)
self.assertItemsEqual(sass_watcher_args[1], self.expected_sass_directories)
six.assertCountEqual(self, sass_watcher_args[1], self.expected_sass_directories)
def test_watch_theme_assets(self):
"""
@@ -275,7 +276,7 @@ class TestPaverWatchAssetTasks(TestCase):
sass_watcher_args = mock_register.call_args_list[0][0]
self.assertIsInstance(sass_watcher_args[0], Observer)
self.assertIsInstance(sass_watcher_args[1], list)
self.assertItemsEqual(sass_watcher_args[1], self.expected_sass_directories)
six.assertCountEqual(self, sass_watcher_args[1], self.expected_sass_directories)
@ddt.ddt