def test_recreates_clients_after_set_timeout(self, mock_MongoClient, mock_MongoReplicaSetClient): """ Ensure that all created Clients are dropped and new ones are created after a set_timeout call to ensure the correct timeout value is used """ pool = MongoPool(self.config) new_timeout = 5 pool.db1 pool.db2 mock_MongoClient.reset_mock() mock_MongoReplicaSetClient.reset_mock() pool.set_timeout(new_timeout) pool.db1 self.call_arguments['socketTimeoutMS'] = new_timeout mock_MongoClient.assert_called_once_with(**self.call_arguments) call_arguments = {'hosts_or_uri': '127.0.0.1:27017', 'replicaSet': 'rset0', 'socketTimeoutMS': new_timeout, 'safe': True, 'read_preference': 0} pool.db2 mock_MongoReplicaSetClient.assert_called_with(**call_arguments)
def test_uses_set_timeout(self, mock_MongoClient): """ Ensure that Clients are created with the correct timeout after set_timeout method is called """ pool = MongoPool(self.config) new_timeout = 5 pool.set_timeout(new_timeout) pool.db1 self.call_arguments['socketTimeoutMS'] = new_timeout mock_MongoClient.assert_called_with(**self.call_arguments)
def test_recreates_clients_after_set_timeout(self, mock_MongoClient): """ Ensure that all created Clients are dropped and new ones are created after a set_timeout call to ensure the correct timeout value is used """ pool = MongoPool(self.config) new_timeout = 5 pool.db1 mock_MongoClient.reset_mock() pool.set_timeout(new_timeout) pool.db1 self.call_arguments['socketTimeoutMS'] = new_timeout mock_MongoClient.assert_called_once_with(**self.call_arguments)