2023-10-12 18:55:31 -04:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
# The OpenSearch Contributors require contributions made to
|
|
|
|
|
# this file be licensed under the Apache-2.0 license or a
|
|
|
|
|
# compatible open source license.
|
|
|
|
|
#
|
|
|
|
|
# Modifications Copyright OpenSearch Contributors. See
|
|
|
|
|
# GitHub history for details.
|
|
|
|
|
|
|
|
|
|
from unittest import TestCase
|
|
|
|
|
|
|
|
|
|
from opensearchpy import OpenSearch, RequestsHttpConnection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestRequests(TestCase):
|
2023-11-06 13:08:19 -05:00
|
|
|
def test_connection_class(self) -> None:
|
2023-10-12 18:55:31 -04:00
|
|
|
client = OpenSearch(connection_class=RequestsHttpConnection)
|
|
|
|
|
self.assertEqual(client.transport.pool_maxsize, None)
|
|
|
|
|
self.assertEqual(client.transport.connection_class, RequestsHttpConnection)
|
|
|
|
|
self.assertIsInstance(
|
|
|
|
|
client.transport.connection_pool.connections[0], RequestsHttpConnection
|
|
|
|
|
)
|
|
|
|
|
|
2023-11-06 13:08:19 -05:00
|
|
|
def test_pool_maxsize(self) -> None:
|
2023-10-12 18:55:31 -04:00
|
|
|
client = OpenSearch(connection_class=RequestsHttpConnection, pool_maxsize=42)
|
|
|
|
|
self.assertEqual(client.transport.pool_maxsize, 42)
|
|
|
|
|
self.assertEqual(
|
|
|
|
|
client.transport.connection_pool.connections[0]
|
|
|
|
|
.session.adapters["https://"]
|
|
|
|
|
._pool_maxsize,
|
|
|
|
|
42,
|
|
|
|
|
)
|