From c7c352ff3d93a4d661b717ba4c3ccc7453d4cfca Mon Sep 17 00:00:00 2001 From: "A. Jesse Jiryu Davis" Date: Mon, 19 Sep 2016 17:19:06 -0400 Subject: [PATCH] PYTHON-1145 RS client obeys "uuidRepresentation=". --- pymongo/mongo_replica_set_client.py | 4 +++- test/test_client.py | 6 ++++++ test/test_replica_set_client.py | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pymongo/mongo_replica_set_client.py b/pymongo/mongo_replica_set_client.py index ad4f087fc..59f9156f2 100644 --- a/pymongo/mongo_replica_set_client.py +++ b/pymongo/mongo_replica_set_client.py @@ -653,7 +653,9 @@ class MongoReplicaSetClient(common.BaseObject): 'max_pool_size', max_pool_size)) common.validate_boolean('tz_aware', tz_aware) - uuid_representation = options.pop('uuidrepresentation', PYTHON_LEGACY) + uuid_representation = self.__opts.pop('uuidrepresentation', + PYTHON_LEGACY) + self.__opts['codec_options'] = CodecOptions( document_class, tz_aware, uuid_representation) diff --git a/test/test_client.py b/test/test_client.py index 739ecf672..312e3e2af 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -1125,6 +1125,12 @@ with client.start_request() as request: collection.find_one() cursor.close() + def test_uuid_representation_kwarg(self): + client = MongoClient(uuidRepresentation='javaLegacy', + connect=False) + + self.assertEqual(client.uuid_subtype, JAVA_LEGACY) + class TestClientLazyConnect(unittest.TestCase, _TestLazyConnectMixin): def _get_client(self, **kwargs): diff --git a/test/test_replica_set_client.py b/test/test_replica_set_client.py index 57fd389be..53fd3210d 100644 --- a/test/test_replica_set_client.py +++ b/test/test_replica_set_client.py @@ -33,6 +33,7 @@ sys.path[0:0] = [""] from nose.plugins.skip import SkipTest +from bson import JAVA_LEGACY from bson.son import SON from bson.tz_util import utc from pymongo.mongo_client import MongoClient @@ -1268,6 +1269,13 @@ class TestReplicaSetClient(TestReplicaSetClientBase, TestRequestMixin): finally: ctx.exit() + def test_uuid_representation_kwarg(self): + client = MongoReplicaSetClient(uuidRepresentation='javaLegacy', + replicaSet='rs', + connect=False) + + self.assertEqual(client.uuid_subtype, JAVA_LEGACY) + class TestReplicaSetWireVersion(unittest.TestCase): def test_wire_version(self):