MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_auth_network_error

Method test_auth_network_error

test/test_client.py:1585–1605  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1583
1584 @client_context.require_auth
1585 def test_auth_network_error(self):
1586 # Make sure there's no semaphore leak if we get a network error
1587 # when authenticating a new socket with cached credentials.
1588
1589 # Get a client with one socket so we detect if it's leaked.
1590 c = connected(
1591 self.rs_or_single_client(maxPoolSize=1, waitQueueTimeoutMS=1, retryReads=False)
1592 )
1593
1594 # Cause a network error on the actual socket.
1595 pool = get_pool(c)
1596 conn = one(pool.conns)
1597 conn.conn.close()
1598
1599 # Connection.authenticate logs, but gets a socket.error. Should be
1600 # reraised as AutoReconnect.
1601 with self.assertRaises(AutoReconnect):
1602 c.test.collection.find_one()
1603
1604 # No semaphore leak, the pool is allowed to make a new socket.
1605 c.test.collection.find_one()
1606
1607 @client_context.require_no_replica_set
1608 def test_connect_to_standalone_using_replica_set_name(self):

Callers

nothing calls this directly

Calls 6

connectedFunction · 0.90
get_poolFunction · 0.90
oneFunction · 0.90
rs_or_single_clientMethod · 0.80
closeMethod · 0.45
find_oneMethod · 0.45

Tested by

no test coverage detected