Skip to content

Commit c7c352f

Browse files
committed
PYTHON-1145 RS client obeys "uuidRepresentation=".
1 parent d172aeb commit c7c352f

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

pymongo/mongo_replica_set_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,9 @@ def __init__(self, hosts_or_uri=None, max_pool_size=100,
653653
'max_pool_size', max_pool_size))
654654

655655
common.validate_boolean('tz_aware', tz_aware)
656-
uuid_representation = options.pop('uuidrepresentation', PYTHON_LEGACY)
656+
uuid_representation = self.__opts.pop('uuidrepresentation',
657+
PYTHON_LEGACY)
658+
657659
self.__opts['codec_options'] = CodecOptions(
658660
document_class, tz_aware, uuid_representation)
659661

test/test_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,12 @@ def test_kill_cursors_warning(self):
11251125
collection.find_one()
11261126
cursor.close()
11271127

1128+
def test_uuid_representation_kwarg(self):
1129+
client = MongoClient(uuidRepresentation='javaLegacy',
1130+
connect=False)
1131+
1132+
self.assertEqual(client.uuid_subtype, JAVA_LEGACY)
1133+
11281134

11291135
class TestClientLazyConnect(unittest.TestCase, _TestLazyConnectMixin):
11301136
def _get_client(self, **kwargs):

test/test_replica_set_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from nose.plugins.skip import SkipTest
3535

36+
from bson import JAVA_LEGACY
3637
from bson.son import SON
3738
from bson.tz_util import utc
3839
from pymongo.mongo_client import MongoClient
@@ -1268,6 +1269,13 @@ def test_alive(self):
12681269
finally:
12691270
ctx.exit()
12701271

1272+
def test_uuid_representation_kwarg(self):
1273+
client = MongoReplicaSetClient(uuidRepresentation='javaLegacy',
1274+
replicaSet='rs',
1275+
connect=False)
1276+
1277+
self.assertEqual(client.uuid_subtype, JAVA_LEGACY)
1278+
12711279

12721280
class TestReplicaSetWireVersion(unittest.TestCase):
12731281
def test_wire_version(self):

0 commit comments

Comments
 (0)