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

@@ -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())
)