MCPcopy Create free account
hub / github.com/apify/crawlee-python / test_get_session_no_usable

Function test_get_session_no_usable

tests/unit/sessions/test_session_pool.py:86–99  ·  view source on GitHub ↗

Ensure that retrieval of a non-existent or retired session returns None and logs warning.

(caplog: pytest.LogCaptureFixture, session_pool: SessionPool)

Source from the content-addressed store, hash-verified

84
85
86async def test_get_session_no_usable(caplog: pytest.LogCaptureFixture, session_pool: SessionPool) -> None:
87 """Ensure that retrieval of a non-existent or retired session returns None and logs warning."""
88 session = await session_pool.get_session_by_id('non_existent')
89 assert session is None
90
91 session = Session(id='test_session_not_usable')
92 session.retire()
93 assert not session.is_usable
94 session_pool.add_session(session=session)
95 assert session_pool.session_count == MAX_POOL_SIZE + 1
96
97 with caplog.at_level(logging.WARNING):
98 session = await session_pool.get_session_by_id('test_session_not_usable')
99 assert session is None
100
101
102async def test_create_session_function() -> None:

Callers

nothing calls this directly

Calls 4

retireMethod · 0.95
SessionClass · 0.90
get_session_by_idMethod · 0.80
add_sessionMethod · 0.80

Tested by

no test coverage detected