mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-05 12:21:52 +00:00
fix tests
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
parent
5d610de5db
commit
3c221b4cc6
2 changed files with 11 additions and 12 deletions
|
@ -43,11 +43,9 @@ from llama_stack.core.providers import ProviderImpl, ProviderImplConfig
|
|||
from llama_stack.core.resolver import ProviderRegistry, resolve_impls
|
||||
from llama_stack.core.routing_tables.common import CommonRoutingTableImpl
|
||||
from llama_stack.core.store.registry import create_dist_registry
|
||||
from llama_stack.core.utils.config_dirs import DISTRIBS_BASE_DIR
|
||||
from llama_stack.core.utils.dynamic import instantiate_class_type
|
||||
from llama_stack.log import get_logger
|
||||
from llama_stack.providers.datatypes import Api
|
||||
from llama_stack.providers.utils.kvstore.config import SqliteKVStoreConfig
|
||||
|
||||
logger = get_logger(name=__name__, category="core")
|
||||
|
||||
|
|
|
@ -9,24 +9,25 @@ import tempfile
|
|||
|
||||
import pytest
|
||||
|
||||
from llama_stack.core.datatypes import StackRunConfig
|
||||
from llama_stack.core.prompts.prompts import PromptServiceConfig, PromptServiceImpl
|
||||
from llama_stack.providers.utils.kvstore.config import SqliteKVStoreConfig
|
||||
|
||||
|
||||
class TestPrompts:
|
||||
@pytest.fixture
|
||||
async def store(self):
|
||||
with tempfile.NamedTemporaryFile(delete=False, suffix=".db") as tmp_file:
|
||||
db_path = tmp_file.name
|
||||
|
||||
try:
|
||||
config = PromptServiceConfig(kvstore=SqliteKVStoreConfig(db_path=db_path))
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
mock_run_config = StackRunConfig(image_name="test-distribution", apis=[], providers={})
|
||||
config = PromptServiceConfig(run_config=mock_run_config)
|
||||
store = PromptServiceImpl(config, deps={})
|
||||
await store.initialize()
|
||||
|
||||
from llama_stack.providers.utils.kvstore import kvstore_impl
|
||||
from llama_stack.providers.utils.kvstore.config import SqliteKVStoreConfig
|
||||
|
||||
test_db_path = os.path.join(temp_dir, "test_prompts.db")
|
||||
store.kvstore = await kvstore_impl(SqliteKVStoreConfig(db_path=test_db_path))
|
||||
|
||||
yield store
|
||||
finally:
|
||||
if os.path.exists(db_path):
|
||||
os.unlink(db_path)
|
||||
|
||||
async def test_create_and_get_prompt(self, store):
|
||||
prompt = await store.create_prompt("Hello world!", {"name": "John"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue