Skip to content

sift_py.grpc.cache_test

CLASS DESCRIPTION
AuthInterceptor

Simple auth interceptor that checks for Bearer token.

DataService

Mock data service that returns a unique response each time.

FUNCTION DESCRIPTION
server_with_service

Create a test server with a spy on the DataService.

test_basic_caching

Test basic cache hit and miss scenarios.

test_cache_helper_functions

Test the cache metadata helper functions.

test_cache_key_generation

Test deterministic cache key generation.

test_cache_metadata_resolution

Test cache metadata resolution logic.

test_cache_persists_across_channels

Test that cache persists across different channel instances.

test_custom_ttl

Test custom TTL parameter.

test_different_requests_different_cache_keys

Test that different requests use different cache entries.

test_force_refresh

Test force refresh bypasses cache and updates it.

test_grpc_cache_initialization

Test GrpcCache initialization and configuration.

test_ignore_cache

Test ignore_cache bypasses cache without updating it.

test_metadata_merging

Test that cache metadata is properly merged with API key metadata.

AuthInterceptor

Bases: ServerInterceptor

Simple auth interceptor that checks for Bearer token.

METHOD DESCRIPTION
intercept

intercept

intercept(
    method: Callable,
    request_or_iterator: Any,
    context: ServicerContext,
    method_name: str,
) -> Any

DataService

DataService()

Bases: DataServiceServicer

Mock data service that returns a unique response each time.

METHOD DESCRIPTION
GetData
ATTRIBUTE DESCRIPTION
call_count

TYPE: int

call_count instance-attribute

call_count: int = 0

GetData

GetData(request: GetDataRequest, context: ServicerContext)

server_with_service

server_with_service(mocker: MockFixture)

Create a test server with a spy on the DataService.

RETURNS DESCRIPTION

Tuple of (spy, data_service, port)

test_basic_caching async

test_basic_caching(mocker: MockFixture)

Test basic cache hit and miss scenarios.

test_cache_helper_functions

test_cache_helper_functions()

Test the cache metadata helper functions.

test_cache_key_generation

test_cache_key_generation()

Test deterministic cache key generation.

test_cache_metadata_resolution

test_cache_metadata_resolution()

Test cache metadata resolution logic.

test_cache_persists_across_channels async

test_cache_persists_across_channels(mocker: MockFixture)

Test that cache persists across different channel instances.

test_custom_ttl async

test_custom_ttl(mocker: MockFixture)

Test custom TTL parameter.

test_different_requests_different_cache_keys async

test_different_requests_different_cache_keys(
    mocker: MockFixture,
)

Test that different requests use different cache entries.

test_force_refresh async

test_force_refresh(mocker: MockFixture)

Test force refresh bypasses cache and updates it.

test_grpc_cache_initialization

test_grpc_cache_initialization()

Test GrpcCache initialization and configuration.

test_ignore_cache async

test_ignore_cache(mocker: MockFixture)

Test ignore_cache bypasses cache without updating it.

test_metadata_merging async

test_metadata_merging(mocker: MockFixture)

Test that cache metadata is properly merged with API key metadata.