2828from bson .py3compat import StringIO , string_type
2929from pymongo .mongo_client import MongoClient
3030from pymongo .errors import (ConfigurationError ,
31- ConnectionFailure ,
31+ NotMasterError ,
3232 ServerSelectionTimeoutError )
3333from pymongo .read_preferences import ReadPreference
3434from gridfs .errors import CorruptGridFile , FileExists , NoFile
35- from test .test_replica_set_client import TestReplicaSetClientBase
3635from 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
549545if __name__ == "__main__" :
0 commit comments