Skip to content

Commit 18f3fc1

Browse files
committed
Add unit test for async context manager. Passes.
[skip ci]
1 parent 9e2a2df commit 18f3fc1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_aries_controller_base.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import pytest
3+
import unittest
34
from aiohttp import (
45
ClientSession,
56
)
@@ -211,3 +212,19 @@ async def test_terminate(self, caplog):
211212
with pytest.raises(AttributeError):
212213
assert ac.webhook_server is None
213214
await ac.terminate()
215+
216+
@pytest.mark.asyncio
217+
async def test_context_manager(self, caplog):
218+
caplog.set_level(logging.INFO)
219+
api_key = "123456789"
220+
221+
async with AriesAgentControllerBase(admin_url="", api_key=api_key) as ac:
222+
assert ac.client_session
223+
assert ac.api_key == api_key
224+
assert ac.headers == {"X-API-Key": api_key}
225+
ac.remove_api_key()
226+
227+
assert ac.headers == {}
228+
assert ac.api_key is None
229+
assert ac.client_session.headers == {}
230+
assert "Client Session closed." in caplog.text

0 commit comments

Comments
 (0)