mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
refactor(sessions):
remove BaseSession's initializer, add timeout ommitable field to base method model
This commit is contained in:
parent
15bcc0ba9f
commit
ea6a02bf97
5 changed files with 90 additions and 39 deletions
|
|
@ -83,6 +83,22 @@ class TestAiohttpSession:
|
|||
aiohttp_session = await session.create_session()
|
||||
assert isinstance(aiohttp_session.connector, aiohttp_socks.ChainProxyConnector)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_reset_connector(self):
|
||||
session = AiohttpSession()
|
||||
assert session._should_reset_connector
|
||||
await session.create_session()
|
||||
assert session._should_reset_connector is False
|
||||
await session.close()
|
||||
assert session._should_reset_connector is False
|
||||
|
||||
assert session.proxy is None
|
||||
session.proxy = "socks5://auth:auth@proxy.url/"
|
||||
assert session._should_reset_connector
|
||||
await session.create_session()
|
||||
assert session._should_reset_connector is False
|
||||
await session.close()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_close_session(self):
|
||||
session = AiohttpSession()
|
||||
|
|
|
|||
|
|
@ -40,8 +40,10 @@ class TestBaseSession:
|
|||
base="http://example.com/{token}/{method}",
|
||||
file="http://example.com/{token}/file/{path{",
|
||||
)
|
||||
session = CustomSession(api=api)
|
||||
session = CustomSession()
|
||||
session.api = api
|
||||
assert session.api == api
|
||||
assert "example.com" in session.api.base
|
||||
|
||||
def test_prepare_value(self):
|
||||
session = CustomSession()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue