Skip to content

Commit

Permalink
make readpreference work again
Browse files Browse the repository at this point in the history
  • Loading branch information
lzy7071 committed Sep 4, 2019
1 parent 4974329 commit b0b5ac3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions datanator_query_python/util/mongo_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class MongoUtil:

def __init__(self, cache_dirname=None, MongoDB=None, replicaSet=None, db='test',
verbose=False, max_entries=float('inf'), username = None,
password = None, authSource = 'admin'):
password = None, authSource = 'admin', readPreference='nearest'):
self.client = pymongo.MongoClient(
host=MongoDB, replicaSet=replicaSet,
username = username, password = password,
authSource = authSource)
self.db_obj = self.client[db]
authSource = authSource, readPreference=readPreference)
self.db_obj = self.client.get_database(db)

def list_all_collections(self):
'''List all non-system collections within database
Expand Down
1 change: 1 addition & 0 deletions tests/util/test_mongo_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def tearDownClass(cls):
# @unittest.skip('passed')
def test_list_all_collections(self):
self.assertTrue('ecmdb' in self.src.list_all_collections())
print(self.src.client.read_preference)


# @unittest.skip('passed')
Expand Down

0 comments on commit b0b5ac3

Please sign in to comment.