Skip to content

Commit

Permalink
MongoDB/PyMongo: Fix tests about result ordering
Browse files Browse the repository at this point in the history
Because the `ordered` option of `insert_many` is not being honored yet,
the result order of returned documents is indeterministic.
Using `.sort("_id", pymongo.ASCENDING)` does not improve the situation.
  • Loading branch information
amotl committed Jul 17, 2024
1 parent 7100144 commit ffc58ef
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/adapter/test_pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,24 +302,26 @@ def test_pymongo_tutorial(

# Querying for More Than One Document.
# https://pymongo.readthedocs.io/en/stable/tutorial.html#querying-for-more-than-one-document
assert list(posts.find({"author": "Mike"})) == [
{
# TODO: Because the `ordered` option of `insert_many` is not being honored yet,
# the result order of returned documents is indeterministic.
# Using `.sort("_id", pymongo.ASCENDING)` does not improve the situation.
results = list(posts.find({"author": "Mike"}))
assert {
"author": "Mike",
"text": "My first blog post!",
"tags": mock.ANY,
"date": mock.ANY,
"title": mock.ANY,
"_id": mock.ANY,
},
{
} in results
assert {
"author": "Mike",
"text": "Another post!",
"tags": mock.ANY,
"date": mock.ANY,
"title": mock.ANY,
"_id": mock.ANY,
},
]
} in results

# Counting.
# https://pymongo.readthedocs.io/en/stable/tutorial.html#counting
Expand Down

0 comments on commit ffc58ef

Please sign in to comment.