fix tests

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
Francisco Javier Arceo 2025-09-05 17:21:52 -04:00
parent 5d610de5db
commit 3c221b4cc6
2 changed files with 11 additions and 12 deletions

View file

@ -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.resolver import ProviderRegistry, resolve_impls
from llama_stack.core.routing_tables.common import CommonRoutingTableImpl from llama_stack.core.routing_tables.common import CommonRoutingTableImpl
from llama_stack.core.store.registry import create_dist_registry 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.core.utils.dynamic import instantiate_class_type
from llama_stack.log import get_logger from llama_stack.log import get_logger
from llama_stack.providers.datatypes import Api from llama_stack.providers.datatypes import Api
from llama_stack.providers.utils.kvstore.config import SqliteKVStoreConfig
logger = get_logger(name=__name__, category="core") logger = get_logger(name=__name__, category="core")

View file

@ -9,24 +9,25 @@ import tempfile
import pytest import pytest
from llama_stack.core.datatypes import StackRunConfig
from llama_stack.core.prompts.prompts import PromptServiceConfig, PromptServiceImpl from llama_stack.core.prompts.prompts import PromptServiceConfig, PromptServiceImpl
from llama_stack.providers.utils.kvstore.config import SqliteKVStoreConfig
class TestPrompts: class TestPrompts:
@pytest.fixture @pytest.fixture
async def store(self): async def store(self):
with tempfile.NamedTemporaryFile(delete=False, suffix=".db") as tmp_file: with tempfile.TemporaryDirectory() as temp_dir:
db_path = tmp_file.name mock_run_config = StackRunConfig(image_name="test-distribution", apis=[], providers={})
config = PromptServiceConfig(run_config=mock_run_config)
try:
config = PromptServiceConfig(kvstore=SqliteKVStoreConfig(db_path=db_path))
store = PromptServiceImpl(config, deps={}) 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 yield store
finally:
if os.path.exists(db_path):
os.unlink(db_path)
async def test_create_and_get_prompt(self, store): async def test_create_and_get_prompt(self, store):
prompt = await store.create_prompt("Hello world!", {"name": "John"}) prompt = await store.create_prompt("Hello world!", {"name": "John"})