Skip to content

Commit

Permalink
The WebIDE will only take you so far
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijah Frederickson authored and bagerard committed Sep 19, 2024
1 parent dbf7888 commit 37762ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions tests/queryset/test_queryset_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ class Bar(Document):
bars = Bar.objects.read_preference(
ReadPreference.SECONDARY_PREFERRED
).aggregate(pipeline)
assert (
bars._CommandCursor__collection.read_preference
== ReadPreference.SECONDARY_PREFERRED
)
if hasattr(bars, "_CommandCursor__collection"):
read_pref = bars._CommandCursor__collection.read_preference
else: # pymongo >= 4.9
read_pref = bars._collection.read_preference
assert read_pref == ReadPreference.SECONDARY_PREFERRED

def test_queryset_aggregation_framework(self):
class Person(Document):
Expand Down
7 changes: 6 additions & 1 deletion tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import uuid

import pymongo
import pymongo.database
import pymongo.mongo_client
import pytest
from bson.tz_util import utc
from pymongo import MongoClient, ReadPreference
Expand Down Expand Up @@ -608,7 +610,10 @@ def test_connect_with_replicaset_via_kwargs(self):
connection kwargs
"""
c = connect(replicaset="local-rs")
assert c._MongoClient__options.replica_set_name == "local-rs"
if hasattr(c, "_MongoClient__options"):
assert c._MongoClient__options.replica_set_name == "local-rs"
else: # pymongo >= 4.9
assert c._options.replica_set_name == "local-rs"
db = get_db()
assert isinstance(db, pymongo.database.Database)
assert db.name == "test"
Expand Down

0 comments on commit 37762ab

Please sign in to comment.