Skip to content

Commit

Permalink
add tests using with and synchronous client
Browse files Browse the repository at this point in the history
Signed-off-by: odlmarce <[email protected]>
  • Loading branch information
odelmarcelle committed Dec 22, 2023
1 parent e50f6be commit 62f7d73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test_opensearchpy/test_async/test_server/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,8 @@ class TestClose:
async def test_close_doesnt_break_client(self, async_client: Any) -> None:
await async_client.close()
await async_client.cluster.health()

async with async_client:
await async_client.cluster.health()
async with async_client:
await async_client.cluster.health()
12 changes: 12 additions & 0 deletions test_opensearchpy/test_server/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,15 @@ def test_bulk_works_with_bytestring_body(self) -> None:

self.assertFalse(response["errors"])
self.assertEqual(1, len(response["items"]))


class TestClose(OpenSearchTestCase):
def test_close_doesnt_break_client(self) -> None:
self.client.cluster.health()
self.client.close()
self.client.cluster.health()

with self.client as client:
client.cluster.health()
with self.client as client:
client.cluster.health()

0 comments on commit 62f7d73

Please sign in to comment.