From 4fb07370dd0071893df33ac54dc38462a332cfca Mon Sep 17 00:00:00 2001 From: Will Miao Date: Sat, 7 Mar 2026 23:10:00 +0800 Subject: [PATCH] fix(tests): add offset parameter to MockTagFTSIndex.search() Add missing offset parameter to MockTagFTSIndex to support pagination changes from commit a802a89. - Update search() signature to include offset=0 - Implement pagination logic with offset/limit slicing --- tests/test_custom_words_service.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/test_custom_words_service.py b/tests/test_custom_words_service.py index c43836de..f6c7eb6c 100644 --- a/tests/test_custom_words_service.py +++ b/tests/test_custom_words_service.py @@ -2,7 +2,10 @@ import pytest -from py.services.custom_words_service import CustomWordsService, get_custom_words_service +from py.services.custom_words_service import ( + CustomWordsService, + get_custom_words_service, +) class TestCustomWordsService: @@ -99,13 +102,19 @@ class MockTagFTSIndex: self.called = False self._results = [ {"tag_name": "hatsune_miku", "category": 4, "post_count": 500000}, - {"tag_name": "hatsune_miku_(vocaloid)", "category": 4, "post_count": 250000}, + { + "tag_name": "hatsune_miku_(vocaloid)", + "category": 4, + "post_count": 250000, + }, ] - def search(self, query, categories=None, limit=20): + def search(self, query, categories=None, limit=20, offset=0): self.called = True if not query: return [] if categories: - return [r for r in self._results if r["category"] in categories][:limit] - return self._results[:limit] + results = [r for r in self._results if r["category"] in categories] + else: + results = self._results + return results[offset : offset + limit]