def test_lazy_auth_raises_operation_failure(self): lazy_client = MongoClient( "mongodb://*****:*****@%s:%d/pymongo_test" % (host, port), _connect=False) assertRaisesExactly( OperationFailure, lazy_client.test.collection.find_one)
def test_lazy_auth_raises_operation_failure(self): lazy_client = MongoClient("mongodb://*****:*****@%s:%d/pymongo_test" % (host, port), _connect=False) assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
def test_lazy_auth_raises_operation_failure(self): lazy_client = MongoReplicaSetClient( "mongodb://*****:*****@%s/pymongo_test" % pair, replicaSet=self.name, _connect=False) assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
def test_connect(self): assertRaisesExactly(ConnectionFailure, MongoReplicaSetClient, "somedomainthatdoesntexist.org:27017", replicaSet=self.name, connectTimeoutMS=600) self.assertRaises(ConfigurationError, MongoReplicaSetClient, pair, replicaSet='fdlksjfdslkjfd') self.assertTrue(MongoReplicaSetClient(pair, replicaSet=self.name))
def test_lazy_auth_raises_operation_failure(self): lazy_client = MongoReplicaSetClient( "mongodb://*****:*****@%s/pymongo_test" % pair, replicaSet=self.name, _connect=False) assertRaisesExactly( OperationFailure, lazy_client.test.collection.find_one)
def test_connect(self): # Check that the exception is a ConnectionFailure, not a subclass like # AutoReconnect assertRaisesExactly(ConnectionFailure, MongoClient, "somedomainthatdoesntexist.org", connectTimeoutMS=600) assertRaisesExactly(ConnectionFailure, MongoClient, host, 123456789) self.assertTrue(MongoClient(host, port))
def test_lazy_auth_raises_operation_failure(self): # Check if we have the prerequisites to run this test. c = self._get_client() if not server_started_with_auth(c): raise SkipTest("Authentication is not enabled on server") lazy_client = MongoReplicaSetClient( "mongodb://*****:*****@%s/pymongo_test" % pair, replicaSet=self.name, _connect=False ) assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
def test_connect_with_internal_ips(self): # Client is passed an IP it can reach, 'a:1', but the RS config # only contains unreachable IPs like 'internal-ip'. PYTHON-608. assertRaisesExactly(ConnectionFailure, MockReplicaSetClient, standalones=[], members=['a:1'], mongoses=[], ismaster_hosts=['internal-ip:27017'], host='a:1', replicaSet='rs')
def test_lazy_auth_raises_operation_failure(self): # Check if we have the prerequisites to run this test. c = MongoClient(host, port) if not server_started_with_auth(c): raise SkipTest("Authentication is not enabled on server") if is_mongos(c) and not version.at_least(c, (2, 0, 0)): raise SkipTest("Auth with sharding requires MongoDB >= 2.0.0") lazy_client = MongoClient("mongodb://*****:*****@%s:%d/pymongo_test" % (host, port), _connect=False) assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
def test_connect_with_internal_ips(self): # Client is passed an IP it can reach, 'a:1', but the RS config # only contains unreachable IPs like 'internal-ip'. PYTHON-608. assertRaisesExactly( ConnectionFailure, MockReplicaSetClient, standalones=[], members=['a:1'], mongoses=[], ismaster_hosts=['internal-ip:27017'], host='a:1', replicaSet='rs')
def test_constants(self): MongoClient.HOST = host MongoClient.PORT = port self.assertTrue(MongoClient()) MongoClient.HOST = "somedomainthatdoesntexist.org" MongoClient.PORT = 123456789 assertRaisesExactly(ConnectionFailure, MongoClient, connectTimeoutMS=600) self.assertTrue(MongoClient(host, port)) MongoClient.HOST = host MongoClient.PORT = port self.assertTrue(MongoClient())
def test_constants(self): Connection.HOST = self.host Connection.PORT = self.port self.assertTrue(Connection()) Connection.HOST = "somedomainthatdoesntexist.org" Connection.PORT = 123456789 assertRaisesExactly(ConnectionFailure, Connection, connectTimeoutMS=600) self.assertTrue(Connection(self.host, self.port)) Connection.HOST = self.host Connection.PORT = self.port self.assertTrue(Connection())
def test_lazy_auth_raises_operation_failure(self): # Check if we have the prerequisites to run this test. c = self._get_client() if not server_started_with_auth(c): raise SkipTest('Authentication is not enabled on server') lazy_client = MongoReplicaSetClient( "mongodb://*****:*****@%s/pymongo_test" % pair, replicaSet=self.name, _connect=False) assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
def test_constants(self): MongoClient.HOST = host MongoClient.PORT = port self.assertTrue(MongoClient()) MongoClient.HOST = "somedomainthatdoesntexist.org" MongoClient.PORT = 123456789 assertRaisesExactly( ConnectionFailure, MongoClient, connectTimeoutMS=600) self.assertTrue(MongoClient(host, port)) MongoClient.HOST = host MongoClient.PORT = port self.assertTrue(MongoClient())
def test_lazy_auth_raises_operation_failure(self): # Check if we have the prerequisites to run this test. c = MongoClient(host, port) if not server_started_with_auth(c): raise SkipTest('Authentication is not enabled on server') if is_mongos(c) and not version.at_least(c, (2, 0, 0)): raise SkipTest("Auth with sharding requires MongoDB >= 2.0.0") lazy_client = MongoClient("mongodb://*****:*****@%s:%d/pymongo_test" % (host, port), _connect=False) assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
def test_connect(self): # Check that the exception is a ConnectionFailure, not a subclass like # AutoReconnect assertRaisesExactly( ConnectionFailure, MongoClient, "somedomainthatdoesntexist.org", connectTimeoutMS=600) assertRaisesExactly( ConnectionFailure, MongoClient, host, 123456789) self.assertTrue(MongoClient(host, port)) # Test that connect=False prevents the constructor from raising # ConnectionFailure. client = MongoClient("somedomainthatdoesnotexist.org", connectTimeoutMS=100, connect=False) try: client.admin.command("ismaster") except AutoReconnect: pass
def test_lazy_auth_raises_operation_failure(self): lazy_client = rs_or_single_client( "mongodb://*****:*****@%s/pymongo_test" % host, connect=False) assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one)
def test_host_w_port(self): self.assertTrue(Connection("%s:%d" % (self.host, self.port))) assertRaisesExactly(ConnectionFailure, Connection, "%s:1234567" % (self.host,), self.port)
def test_lazy_auth_raises_operation_failure(self): lazy_client = rs_or_single_client( "mongodb://*****:*****@%s/pymongo_test" % host, connect=False) assertRaisesExactly( OperationFailure, lazy_client.test.collection.find_one)
def test_host_w_port(self): self.assertTrue(MongoClient("%s:%d" % (host, port))) assertRaisesExactly(ConnectionFailure, MongoClient, "%s:1234567" % (host, ), port)
def test_host_w_port(self): self.assertTrue(Connection("%s:%d" % (self.host, self.port))) assertRaisesExactly(ConnectionFailure, Connection, "%s:1234567" % (self.host, ), self.port)
def test_host_w_port(self): self.assertTrue(MongoClient("%s:%d" % (host, port))) assertRaisesExactly( ConnectionFailure, MongoClient, "%s:1234567" % (host,), port)