Skip to content

Commit

Permalink
add is_mongos @Property, so that mim won't error using an exhaust cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
brondsem committed Mar 16, 2023
1 parent 51d8073 commit ec8f1f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions ming/mim.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def _ensure_connected(self):
def _is_writable(self):
return True

@property
def is_mongos(self):
return False


class Database(database.Database):
def __init__(self, client, name, **__):
Expand Down
3 changes: 2 additions & 1 deletion ming/tests/test_mim.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from bson.raw_bson import RawBSONDocument

from ming import create_datastore, mim
from pymongo import UpdateOne
from pymongo import UpdateOne, CursorType
from pymongo.errors import OperationFailure, DuplicateKeyError
from unittest.mock import patch

Expand Down Expand Up @@ -155,6 +155,7 @@ def test_find_with_invalid_kwargs(self):
self.assertRaises(TypeError, self.bind.db.coll.find, {'a': 2}, foo=123)
self.assertRaises(TypeError, self.bind.db.coll.find_one, foo=123)
self.bind.db.coll.find(allow_disk_use=True) # kwargs that pymongo knows are ok
self.bind.db.coll.find(cursor_type=CursorType.EXHAUST)

def test_rewind(self):
collection = self.bind.db.coll
Expand Down

0 comments on commit ec8f1f6

Please sign in to comment.