Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions key-value/key-value-aio/tests/stores/disk/test_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@


class TestDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
@pytest.fixture(scope="session")
async def disk_store(self) -> AsyncGenerator[DiskStore, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)

@override
@pytest.fixture
async def store(self, disk_store: DiskStore) -> DiskStore:
disk_store._cache.clear() # pyright: ignore[reportPrivateUsage]

return disk_store
async def store(self) -> AsyncGenerator[DiskStore, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)

@pytest.fixture
async def disk_cache(self, disk_store: DiskStore) -> Cache:
return disk_store._cache # pyright: ignore[reportPrivateUsage]
async def disk_cache(self, store: DiskStore) -> Cache:
return store._cache # pyright: ignore[reportPrivateUsage]

async def test_value_stored(self, store: DiskStore, disk_cache: Cache):
await store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})
Expand Down
13 changes: 3 additions & 10 deletions key-value/key-value-aio/tests/stores/disk/test_multi_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@


class TestMultiDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
@pytest.fixture(scope="session")
async def multi_disk_store(self) -> AsyncGenerator[MultiDiskStore, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)

@override
@pytest.fixture
async def store(self, multi_disk_store: MultiDiskStore) -> MultiDiskStore:
for collection in multi_disk_store._cache: # pyright: ignore[reportPrivateUsage]
multi_disk_store._cache[collection].clear() # pyright: ignore[reportPrivateUsage]

return multi_disk_store
async def store(self) -> AsyncGenerator[MultiDiskStore, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)

async def test_value_stored(self, store: MultiDiskStore):
await store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})
Expand Down
12 changes: 4 additions & 8 deletions key-value/key-value-aio/tests/stores/duckdb/test_duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ def get_client_from_store(store: DuckDBStore) -> DuckDBPyConnection:
class TestDuckDBStore(ContextManagerStoreTestMixin, BaseStoreTests):
@override
@pytest.fixture
async def store(self) -> AsyncGenerator[DuckDBStore, None]:
async def store(self) -> DuckDBStore:
"""Test with in-memory DuckDB database."""
duckdb_store = DuckDBStore()
yield duckdb_store
await duckdb_store.close()
return DuckDBStore()

@pytest.mark.skip(reason="Local disk stores are unbounded")
async def test_not_unbounded(self, store: BaseStore): ...
Expand All @@ -38,9 +36,7 @@ async def store(self) -> AsyncGenerator[DuckDBStore, None]:
"""Test with persistent DuckDB database file."""
with TemporaryDirectory() as temp_dir:
db_path = Path(temp_dir) / "test.db"
duckdb_store = DuckDBStore(database_path=db_path)
yield duckdb_store
await duckdb_store.close()
yield DuckDBStore(database_path=db_path)

@pytest.mark.skip(reason="Local disk stores are unbounded")
async def test_not_unbounded(self, store: BaseStore): ...
Expand All @@ -55,7 +51,7 @@ async def store(self) -> AsyncGenerator[DuckDBStore, None]:
"""Provide DuckDB store instance."""
duckdb_store = DuckDBStore()
yield duckdb_store
await duckdb_store.close()
await duckdb_store.close() # This class doesn't use ContextManagerStoreTestMixin

async def test_native_sql_queryability(self):
"""Test that users can query the database directly with SQL."""
Expand Down
16 changes: 5 additions & 11 deletions key-value/key-value-sync/tests/code_gen/stores/disk/test_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@


class TestDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
@pytest.fixture(scope="session")
def disk_store(self) -> Generator[DiskStore, None, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)

@override
@pytest.fixture
def store(self, disk_store: DiskStore) -> DiskStore:
disk_store._cache.clear() # pyright: ignore[reportPrivateUsage]

return disk_store
def store(self) -> Generator[DiskStore, None, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)

@pytest.fixture
def disk_cache(self, disk_store: DiskStore) -> Cache:
return disk_store._cache # pyright: ignore[reportPrivateUsage]
def disk_cache(self, store: DiskStore) -> Cache:
return store._cache # pyright: ignore[reportPrivateUsage]

def test_value_stored(self, store: DiskStore, disk_cache: Cache):
store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,11 @@


class TestMultiDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
@pytest.fixture(scope="session")
def multi_disk_store(self) -> Generator[MultiDiskStore, None, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)

@override
@pytest.fixture
def store(self, multi_disk_store: MultiDiskStore) -> MultiDiskStore:
for collection in multi_disk_store._cache: # pyright: ignore[reportPrivateUsage]
multi_disk_store._cache[collection].clear() # pyright: ignore[reportPrivateUsage]

return multi_disk_store
def store(self) -> Generator[MultiDiskStore, None, None]:
with tempfile.TemporaryDirectory() as temp_dir:
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)

def test_value_stored(self, store: MultiDiskStore):
store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ def get_client_from_store(store: DuckDBStore) -> DuckDBPyConnection:
class TestDuckDBStore(ContextManagerStoreTestMixin, BaseStoreTests):
@override
@pytest.fixture
def store(self) -> Generator[DuckDBStore, None, None]:
def store(self) -> DuckDBStore:
"""Test with in-memory DuckDB database."""
duckdb_store = DuckDBStore()
yield duckdb_store
duckdb_store.close()
return DuckDBStore()

@pytest.mark.skip(reason="Local disk stores are unbounded")
def test_not_unbounded(self, store: BaseStore): ...
Expand All @@ -41,9 +39,7 @@ def store(self) -> Generator[DuckDBStore, None, None]:
"""Test with persistent DuckDB database file."""
with TemporaryDirectory() as temp_dir:
db_path = Path(temp_dir) / "test.db"
duckdb_store = DuckDBStore(database_path=db_path)
yield duckdb_store
duckdb_store.close()
yield DuckDBStore(database_path=db_path)

@pytest.mark.skip(reason="Local disk stores are unbounded")
def test_not_unbounded(self, store: BaseStore): ...
Expand All @@ -58,7 +54,7 @@ def store(self) -> Generator[DuckDBStore, None, None]:
"""Provide DuckDB store instance."""
duckdb_store = DuckDBStore()
yield duckdb_store
duckdb_store.close()
duckdb_store.close() # This class doesn't use ContextManagerStoreTestMixin

def test_native_sql_queryability(self):
"""Test that users can query the database directly with SQL."""
Expand Down