From 3c221b4cc6acd23695e8db6f982df2f8a9123ab5 Mon Sep 17 00:00:00 2001 From: Francisco Javier Arceo Date: Fri, 5 Sep 2025 17:21:52 -0400 Subject: [PATCH] fix tests Signed-off-by: Francisco Javier Arceo --- llama_stack/core/stack.py | 2 -- tests/unit/prompts/prompts/test_prompts.py | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/llama_stack/core/stack.py b/llama_stack/core/stack.py index f7b723a93..7ab8d2c64 100644 --- a/llama_stack/core/stack.py +++ b/llama_stack/core/stack.py @@ -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") diff --git a/tests/unit/prompts/prompts/test_prompts.py b/tests/unit/prompts/prompts/test_prompts.py index 47c154bf2..0527b6b89 100644 --- a/tests/unit/prompts/prompts/test_prompts.py +++ b/tests/unit/prompts/prompts/test_prompts.py @@ -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"})