Ensure that retrieval of a non-existent or retired session returns None and logs warning.
(caplog: pytest.LogCaptureFixture, session_pool: SessionPool)
| 84 | |
| 85 | |
| 86 | async 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 | |
| 102 | async def test_create_session_function() -> None: |
nothing calls this directly
no test coverage detected