Skip to content

Commit 3f8a3ac

Browse files
authored
Preserve interface for SQL store testing (#279)
1 parent e0b55ab commit 3f8a3ac

File tree

3 files changed

+467
-461
lines changed

3 files changed

+467
-461
lines changed

tests/store/conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import pytest
77
from opentelemetry.sdk.trace import ReadableSpan
8+
from pytest import FixtureRequest
89

10+
from agentlightning.store.base import LightningStore
911
from agentlightning.store.memory import InMemoryLightningStore
1012

1113
__all__ = [
@@ -20,6 +22,22 @@ def inmemory_store() -> InMemoryLightningStore:
2022
return InMemoryLightningStore()
2123

2224

25+
@pytest.fixture
26+
def sql_store():
27+
"""Placeholder fixture for SQL store implementation. Returns None until SQL store is ready."""
28+
return None
29+
30+
31+
# Uncomment this when sql store is ready
32+
# @pytest.fixture(params=["inmemory_store", "sql_store"])
33+
@pytest.fixture(params=["inmemory_store"])
34+
def store_fixture(request: FixtureRequest) -> LightningStore:
35+
"""Parameterized fixture that provides different store implementations for testing.
36+
Currently supports InMemoryLightningStore, with SQL store support planned.
37+
"""
38+
return request.getfixturevalue(request.param)
39+
40+
2341
@pytest.fixture
2442
def mock_readable_span() -> ReadableSpan:
2543
"""Create a mock ReadableSpan for testing."""

tests/store/test_client_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from portpicker import pick_unused_port
1616
from yarl import URL
1717

18-
from agentlightning.store.base import UNSET
18+
from agentlightning.store.base import UNSET, LightningStore
1919
from agentlightning.store.client_server import LightningStoreClient, LightningStoreServer
2020
from agentlightning.store.memory import InMemoryLightningStore
2121
from agentlightning.types import LLM, OtelResource, PromptTemplate, RolloutConfig, Span, TraceStatus
@@ -56,10 +56,11 @@ async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None:
5656

5757

5858
@pytest_asyncio.fixture
59-
async def server_client() -> AsyncGenerator[Tuple[LightningStoreServer, LightningStoreClient], None]:
60-
store = InMemoryLightningStore()
59+
async def server_client(
60+
store_fixture: LightningStore,
61+
) -> AsyncGenerator[Tuple[LightningStoreServer, LightningStoreClient], None]:
6162
port = pick_unused_port()
62-
server = LightningStoreServer(store, "127.0.0.1", port)
63+
server = LightningStoreServer(store_fixture, "127.0.0.1", port)
6364
await server.start()
6465
client = LightningStoreClient(server.endpoint)
6566
try:

0 commit comments

Comments
 (0)