Refactor duplicated code
This commit is contained in:
@@ -8,6 +8,7 @@ import pytest
|
||||
from knowledge_search_mcp.main import (
|
||||
GoogleCloudFileStorage,
|
||||
GoogleCloudVectorSearch,
|
||||
LRUCache,
|
||||
SourceNamespace,
|
||||
)
|
||||
|
||||
@@ -19,14 +20,15 @@ class TestGoogleCloudFileStorage:
|
||||
"""Test storage initialization."""
|
||||
storage = GoogleCloudFileStorage(bucket="test-bucket")
|
||||
assert storage.bucket_name == "test-bucket"
|
||||
assert storage._cache == {}
|
||||
assert isinstance(storage._cache, LRUCache)
|
||||
assert storage._cache.max_size == 100
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_cache_hit(self):
|
||||
"""Test that cached files are returned without fetching."""
|
||||
storage = GoogleCloudFileStorage(bucket="test-bucket")
|
||||
test_content = b"cached content"
|
||||
storage._cache["test.md"] = test_content
|
||||
storage._cache.put("test.md", test_content)
|
||||
|
||||
result = await storage.async_get_file_stream("test.md")
|
||||
|
||||
@@ -48,7 +50,7 @@ class TestGoogleCloudFileStorage:
|
||||
result = await storage.async_get_file_stream("test.md")
|
||||
|
||||
assert result.read() == test_content
|
||||
assert storage._cache["test.md"] == test_content
|
||||
assert storage._cache.get("test.md") == test_content
|
||||
|
||||
|
||||
class TestGoogleCloudVectorSearch:
|
||||
|
||||
Reference in New Issue
Block a user