Skip to content
Merged
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
44 changes: 44 additions & 0 deletions libs/astradb/tests/integration_tests/standard_tests/test_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pytest
from astrapy import Collection
from astrapy.authentication import StaticTokenProvider
from langchain_tests.integration_tests import AsyncCacheTestSuite, SyncCacheTestSuite

from langchain_astradb import AstraDBCache
from tests.integration_tests.conftest import (
AstraDBCredentials,
astra_db_env_vars_available,
)


class _BaseTestAstraDBCache:
@pytest.fixture(autouse=True)
def setup(
self,
astra_db_credentials: AstraDBCredentials,
empty_collection_idxall: Collection,
) -> None:
self._cache = AstraDBCache(
collection_name=empty_collection_idxall.name,
token=StaticTokenProvider(astra_db_credentials["token"]),
api_endpoint=astra_db_credentials["api_endpoint"],
namespace=astra_db_credentials["namespace"],
environment=astra_db_credentials["environment"],
)


@pytest.mark.skipif(
not astra_db_env_vars_available(), reason="Missing Astra DB env. vars"
)
class TestAstraDBCache(_BaseTestAstraDBCache, SyncCacheTestSuite):
@pytest.fixture
def cache(self) -> AstraDBCache:
return self._cache


@pytest.mark.skipif(
not astra_db_env_vars_available(), reason="Missing Astra DB env. vars"
)
class TestAstraDBCacheAsync(_BaseTestAstraDBCache, AsyncCacheTestSuite):
@pytest.fixture
async def cache(self) -> AstraDBCache:
return self._cache
Loading