From ec15012d00b400659ac8004143075cdb13895d3b Mon Sep 17 00:00:00 2001 From: Deeman Date: Tue, 24 Feb 2026 20:55:38 +0100 Subject: [PATCH] test: update mock_fetch_analytics to handle COUNT(*) queries count_template_data() uses fetch_analytics with a COUNT(*) query. The pseo_env test fixture's mock returned TEST_ROWS for any unrecognized query, causing a KeyError on rows[0]["cnt"]. Add a COUNT(*) branch that returns [{cnt: len(TEST_ROWS)}]. Co-Authored-By: Claude Opus 4.6 --- web/tests/test_content.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/tests/test_content.py b/web/tests/test_content.py index 02cc103..06a1633 100644 --- a/web/tests/test_content.py +++ b/web/tests/test_content.py @@ -134,6 +134,8 @@ def pseo_env(tmp_path, monkeypatch): async def mock_fetch_analytics(query, params=None): if "information_schema" in query: return TEST_COLUMNS + if "COUNT(*)" in query.upper(): + return [{"cnt": len(TEST_ROWS)}] if "WHERE" in query and params: # preview_article: filter by natural key value return [r for r in TEST_ROWS if params[0] in r.values()]