Skip to content

Commit 4c46a42

Browse files
committed
tests
1 parent fc29bc8 commit 4c46a42

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/test_descope_client.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,27 @@ def test_async_mode_experimental_flag_does_not_return_coroutine(self, mock_post,
10891089
self.assertFalse(asyncio.iscoroutine(result))
10901090
self.assertIsNotNone(result)
10911091

1092+
@patch("httpx.AsyncClient")
1093+
def test_async_context_manager(self, mock_async_cls):
1094+
import asyncio
1095+
from unittest.mock import AsyncMock
1096+
1097+
mock_async_instance = mock.Mock()
1098+
mock_async_instance.aclose = AsyncMock()
1099+
mock_async_cls.return_value = mock_async_instance
1100+
1101+
async def run():
1102+
async with DescopeClient(
1103+
project_id=self.dummy_project_id,
1104+
public_key=self.public_key_dict,
1105+
async_mode_experimental=True,
1106+
) as client:
1107+
self.assertIsNotNone(client)
1108+
# aclose called once for auth client + once for mgmt client
1109+
self.assertEqual(mock_async_instance.aclose.await_count, 2)
1110+
1111+
asyncio.run(run())
1112+
10921113

10931114
if __name__ == "__main__":
10941115
unittest.main()

0 commit comments

Comments
 (0)