mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
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
This commit is contained in:
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
import pytest
|
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:
|
class TestCustomWordsService:
|
||||||
@@ -99,13 +102,19 @@ class MockTagFTSIndex:
|
|||||||
self.called = False
|
self.called = False
|
||||||
self._results = [
|
self._results = [
|
||||||
{"tag_name": "hatsune_miku", "category": 4, "post_count": 500000},
|
{"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
|
self.called = True
|
||||||
if not query:
|
if not query:
|
||||||
return []
|
return []
|
||||||
if categories:
|
if categories:
|
||||||
return [r for r in self._results if r["category"] in categories][:limit]
|
results = [r for r in self._results if r["category"] in categories]
|
||||||
return self._results[:limit]
|
else:
|
||||||
|
results = self._results
|
||||||
|
return results[offset : offset + limit]
|
||||||
|
|||||||
Reference in New Issue
Block a user