Cache integration tests¶
SyncCacheTestSuite
¶
Bases: BaseStandardTests
Test suite for checking the BaseCache API of a caching layer for LLMs.
This test suite verifies the basic caching API of a caching layer for LLMs.
The test suite is designed for synchronous caching layers.
Implementers should subclass this test suite and provide a fixture that returns an empty cache for each test.
| METHOD | DESCRIPTION |
|---|---|
test_no_overrides_DO_NOT_OVERRIDE |
Test that no standard tests are overridden. |
cache |
Get the cache class to test. |
get_sample_prompt |
Return a sample prompt for testing. |
get_sample_llm_string |
Return a sample LLM string for testing. |
get_sample_generation |
Return a sample |
test_cache_is_empty |
Test that the cache is empty. |
test_update_cache |
Test updating the cache. |
test_cache_still_empty |
Test that the cache is still empty. |
test_clear_cache |
Test clearing the cache. |
test_cache_miss |
Test cache miss. |
test_cache_hit |
Test cache hit. |
test_update_cache_with_multiple_generations |
Test updating the cache with multiple |
test_no_overrides_DO_NOT_OVERRIDE
¶
Test that no standard tests are overridden.
cache
abstractmethod
¶
cache() -> BaseCache
Get the cache class to test.
The returned cache should be EMPTY.
get_sample_generation
¶
Return a sample Generation object for testing.
AsyncCacheTestSuite
¶
Bases: BaseStandardTests
Test suite for checking the BaseCache API of a caching layer for LLMs.
Verifies the basic caching API of a caching layer for LLMs.
The test suite is designed for synchronous caching layers.
Implementers should subclass this test suite and provide a fixture that returns an empty cache for each test.
| METHOD | DESCRIPTION |
|---|---|
test_no_overrides_DO_NOT_OVERRIDE |
Test that no standard tests are overridden. |
cache |
Get the cache class to test. |
get_sample_prompt |
Return a sample prompt for testing. |
get_sample_llm_string |
Return a sample LLM string for testing. |
get_sample_generation |
Return a sample |
test_cache_is_empty |
Test that the cache is empty. |
test_update_cache |
Test updating the cache. |
test_cache_still_empty |
Test that the cache is still empty. |
test_clear_cache |
Test clearing the cache. |
test_cache_miss |
Test cache miss. |
test_cache_hit |
Test cache hit. |
test_update_cache_with_multiple_generations |
Test updating the cache with multiple |
test_no_overrides_DO_NOT_OVERRIDE
¶
Test that no standard tests are overridden.
cache
abstractmethod
async
¶
cache() -> BaseCache
Get the cache class to test.
The returned cache should be EMPTY.
get_sample_generation
¶
Return a sample Generation object for testing.
test_cache_is_empty
async
¶
test_cache_is_empty(cache: BaseCache) -> None
Test that the cache is empty.