From e8ee077f1a2a70e3a89b1ffc8f985f270e6b7811 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 3 Oct 2026 15:41:30 -0600 Subject: [PATCH] tests: name the real extra connections in the request connection xfails Channel detail: get_channel already uses the request session; the extra connection is Channel.get_statistics opening a raw cursor (get_db_curs). Search: count_file_groups opens a cursor for the total, then handle_file_group_search_results opens a cursor and a session. Co-Authored-By: Claude Opus 5.5 --- wrolpi/test/test_request_db.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wrolpi/test/test_request_db.py b/wrolpi/test/test_request_db.py index 32e66888..c915e923 100644 --- a/wrolpi/test/test_request_db.py +++ b/wrolpi/test/test_request_db.py @@ -92,7 +92,8 @@ async def test_zim_search_uses_one_connection(async_client, test_session, zim_fa @pytest.mark.asyncio @pytest.mark.parametrize('path', ['/api/files/search', '/api/videos/search']) async def test_search_uses_one_connection(async_client, test_session, simple_channel, video_factory, path): - """The search helpers in `wrolpi.files.lib` open a cursor, then a separate session.""" + """`count_file_groups` opens a cursor for the total (skipped when the total is cached), then + `handle_file_group_search_results` opens another cursor and a separate session for the page.""" video_factory(title='a video', channel_id=simple_channel.id) response, count = await count_request_connections( async_client, test_session, 'post', path, json={'search_str': 'video'}) @@ -103,7 +104,8 @@ async def test_search_uses_one_connection(async_client, test_session, simple_cha @OPENS_OWN_CONNECTION @pytest.mark.asyncio async def test_channel_uses_one_connection(async_client, test_session, simple_channel): - """`get_channel` and the Channel's statistics each open their own session.""" + """`get_channel` uses the request session, but `Channel.get_statistics` opens a raw cursor of its own + (`get_db_curs`).""" response, count = await count_request_connections( async_client, test_session, 'get', f'/api/videos/channels/{simple_channel.id}') assert response.status_code == HTTPStatus.OK, response.body