Skip to content

Commit 56925fd

Browse files
authored
PYTHON-1321 Remove MongoReplicaSetClient (mongodb#552)
1 parent 6e8c370 commit 56925fd

13 files changed

+37
-499
lines changed

doc/api/pymongo/index.rst

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99

1010
Alias for :class:`pymongo.mongo_client.MongoClient`.
1111

12-
.. data:: MongoReplicaSetClient
13-
14-
Alias for :class:`pymongo.mongo_replica_set_client.MongoReplicaSetClient`.
15-
1612
.. data:: ReadPreference
1713

1814
Alias for :class:`pymongo.read_preferences.ReadPreference`.
@@ -46,7 +42,6 @@ Sub-modules:
4642
errors
4743
message
4844
mongo_client
49-
mongo_replica_set_client
5045
monitoring
5146
operations
5247
pool

doc/api/pymongo/mongo_replica_set_client.rst

Lines changed: 0 additions & 32 deletions
This file was deleted.

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Breaking Changes in 4.0
2525
- Removed :meth:`pymongo.database.Database.collection_names`.
2626
- Removed :meth:`pymongo.collection.Collection.parallel_scan`.
2727
- Removed :mod:`pymongo.thread_util`.
28+
- Removed :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`.
2829

2930
Notable improvements
3031
....................

doc/migrate-to-pymongo4.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ Warnings can also be changed to errors::
5050
.. note:: Not all deprecated features raise :exc:`DeprecationWarning` when
5151
used. See `Removed features with no migration path`_.
5252

53+
MongoReplicaSetClient
54+
---------------------
55+
56+
Removed :class:`~pymongo.mongo_replica_set_client.MongoReplicaSetClient`.
57+
Since PyMongo 3.0, ``MongoReplicaSetClient`` has been identical to
58+
:class:`pymongo.mongo_client.MongoClient`. Applications can simply replace
59+
``MongoReplicaSetClient`` with :class:`pymongo.mongo_client.MongoClient` and
60+
get the same behavior.
61+
5362
MongoClient
5463
-----------
5564

pymongo/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ def get_version_string():
8989
MAX_SUPPORTED_WIRE_VERSION)
9090
from pymongo.cursor import CursorType
9191
from pymongo.mongo_client import MongoClient
92-
from pymongo.mongo_replica_set_client import MongoReplicaSetClient
9392
from pymongo.operations import (IndexModel,
9493
InsertOne,
9594
DeleteOne,

pymongo/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def validate_read_preference(dummy, value):
364364

365365

366366
def validate_read_preference_mode(dummy, value):
367-
"""Validate read preference mode for a MongoReplicaSetClient.
367+
"""Validate read preference mode for a MongoClient.
368368
369369
.. versionchanged:: 3.5
370370
Returns the original ``value`` instead of the validated read preference

pymongo/mongo_client.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,7 @@ def primary(self):
10011001
`replicaSet` option.
10021002
10031003
.. versionadded:: 3.0
1004-
MongoClient gained this property in version 3.0 when
1005-
MongoReplicaSetClient's functionality was merged in.
1004+
MongoClient gained this property in version 3.0.
10061005
"""
10071006
return self._topology.get_primary()
10081007

@@ -1015,8 +1014,7 @@ def secondaries(self):
10151014
client was created without the `replicaSet` option.
10161015
10171016
.. versionadded:: 3.0
1018-
MongoClient gained this property in version 3.0 when
1019-
MongoReplicaSetClient's functionality was merged in.
1017+
MongoClient gained this property in version 3.0.
10201018
"""
10211019
return self._topology.get_secondaries()
10221020

pymongo/mongo_replica_set_client.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

pymongo/read_preferences.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
def _validate_tag_sets(tag_sets):
41-
"""Validate tag sets for a MongoReplicaSetClient.
41+
"""Validate tag sets for a MongoClient.
4242
"""
4343
if tag_sets is None:
4444
return tag_sets
@@ -144,7 +144,7 @@ def tag_sets(self):
144144
To specify a priority-order for tag sets, provide a list of
145145
tag sets: ``[{'dc': 'ny'}, {'dc': 'la'}, {}]``. A final, empty tag
146146
set, ``{}``, means "read from any member that matches the mode,
147-
ignoring tags." MongoReplicaSetClient tries each set of tags in turn
147+
ignoring tags." MongoClient tries each set of tags in turn
148148
until it finds a set of tags with at least one matching member.
149149
150150
.. seealso:: `Data-Center Awareness

test/test_gridfs.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
from bson.py3compat import StringIO, string_type
2929
from pymongo.mongo_client import MongoClient
3030
from pymongo.errors import (ConfigurationError,
31-
ConnectionFailure,
31+
NotMasterError,
3232
ServerSelectionTimeoutError)
3333
from pymongo.read_preferences import ReadPreference
3434
from gridfs.errors import CorruptGridFile, FileExists, NoFile
35-
from test.test_replica_set_client import TestReplicaSetClientBase
3635
from test import (client_context,
3736
unittest,
3837
IntegrationTest)
@@ -487,7 +486,7 @@ def test_md5(self):
487486
self.assertIsNone(gout.md5)
488487

489488

490-
class TestGridfsReplicaSet(TestReplicaSetClientBase):
489+
class TestGridfsReplicaSet(IntegrationTest):
491490

492491
@classmethod
493492
@client_context.require_secondaries_count(1)
@@ -500,7 +499,7 @@ def tearDownClass(cls):
500499

501500
def test_gridfs_replica_set(self):
502501
rsc = rs_client(
503-
w=self.w,
502+
w=client_context.w,
504503
read_preference=ReadPreference.SECONDARY)
505504

506505
fs = gridfs.GridFS(rsc.gfsreplica, 'gfsreplicatest')
@@ -513,10 +512,7 @@ def test_gridfs_replica_set(self):
513512
self.assertEqual(b'foo', content)
514513

515514
def test_gridfs_secondary(self):
516-
primary_host, primary_port = self.primary
517-
primary_connection = single_client(primary_host, primary_port)
518-
519-
secondary_host, secondary_port = one(self.secondaries)
515+
secondary_host, secondary_port = one(self.client.secondaries)
520516
secondary_connection = single_client(
521517
secondary_host, secondary_port,
522518
read_preference=ReadPreference.SECONDARY)
@@ -526,12 +522,12 @@ def test_gridfs_secondary(self):
526522
fs = gridfs.GridFS(secondary_connection.gfsreplica, 'gfssecondarytest')
527523

528524
# This won't detect secondary, raises error
529-
self.assertRaises(ConnectionFailure, fs.put, b'foo')
525+
self.assertRaises(NotMasterError, fs.put, b'foo')
530526

531527
def test_gridfs_secondary_lazy(self):
532528
# Should detect it's connected to secondary and not attempt to
533529
# create index.
534-
secondary_host, secondary_port = one(self.secondaries)
530+
secondary_host, secondary_port = one(self.client.secondaries)
535531
client = single_client(
536532
secondary_host,
537533
secondary_port,
@@ -543,7 +539,7 @@ def test_gridfs_secondary_lazy(self):
543539

544540
# Connects, doesn't create index.
545541
self.assertRaises(NoFile, fs.get_last_version)
546-
self.assertRaises(ConnectionFailure, fs.put, 'data')
542+
self.assertRaises(NotMasterError, fs.put, 'data')
547543

548544

549545
if __name__ == "__main__":

0 commit comments

Comments
 (0)