Skip to content

Commit c51de5e

Browse files
committed
no tests fail?
1 parent 3e20747 commit c51de5e

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

django_mongodb_backend/test.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,6 @@ class MongoTestCaseMixin:
77
maxDiff = None
88
query_types = {"SON": SON, "ObjectId": ObjectId, "Decimal128": Decimal128}
99

10-
COMMUTATIVE_OPERATORS = {"$and", "$or", "$all"}
11-
12-
@staticmethod
13-
def _normalize_query(obj):
14-
if isinstance(obj, dict):
15-
normalized = {}
16-
for k, v in obj.items():
17-
if k in MongoTestCaseMixin.COMMUTATIVE_OPERATORS and isinstance(v, list):
18-
# Only sort for commutative operators
19-
normalized[k] = sorted(
20-
(MongoTestCaseMixin._normalize_query(i) for i in v), key=lambda x: str(x)
21-
)
22-
else:
23-
normalized[k] = MongoTestCaseMixin._normalize_query(v)
24-
return normalized
25-
26-
if isinstance(obj, list):
27-
# Lists not under commutative ops keep their order
28-
return [MongoTestCaseMixin._normalize_query(i) for i in obj]
29-
30-
return obj
31-
3210
def assertAggregateQuery(self, query, expected_collection, expected_pipeline):
3311
"""
3412
Assert that the logged query is equal to:
@@ -38,14 +16,7 @@ def assertAggregateQuery(self, query, expected_collection, expected_pipeline):
3816
_, collection, operator = prefix.split(".")
3917
self.assertEqual(operator, "aggregate")
4018
self.assertEqual(collection, expected_collection)
41-
self.assertEqual(
42-
self._normalize_query(
43-
eval( # noqa: S307
44-
pipeline[:-1], {"SON": SON, "ObjectId": ObjectId, "Decimal128": Decimal128}, {}
45-
)
46-
),
47-
self._normalize_query(expected_pipeline),
48-
)
19+
self.assertEqual(eval(pipeline[:-1], self.query_types, {}), expected_pipeline) # noqa: S307
4920

5021
def assertInsertQuery(self, query, expected_collection, expected_documents):
5122
"""

0 commit comments

Comments
 (0)