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 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,8 @@ def pseo_env(tmp_path, monkeypatch):
|
|||||||
async def mock_fetch_analytics(query, params=None):
|
async def mock_fetch_analytics(query, params=None):
|
||||||
if "information_schema" in query:
|
if "information_schema" in query:
|
||||||
return TEST_COLUMNS
|
return TEST_COLUMNS
|
||||||
|
if "COUNT(*)" in query.upper():
|
||||||
|
return [{"cnt": len(TEST_ROWS)}]
|
||||||
if "WHERE" in query and params:
|
if "WHERE" in query and params:
|
||||||
# preview_article: filter by natural key value
|
# preview_article: filter by natural key value
|
||||||
return [r for r in TEST_ROWS if params[0] in r.values()]
|
return [r for r in TEST_ROWS if params[0] in r.values()]
|
||||||
|
|||||||
Reference in New Issue
Block a user