Repository navigation
Commit e8674e5
authored
test: cover the sync SSE client and bucket range serialization (#115)
* test: cover sync SSE, feature loading and bucket range serialization
The sync streaming path and feature loading had little or no direct test
coverage, so a regression in SSEClient, GrowthBook.start_auto_refresh,
_dispatch_sse_event or FeatureRepository could go unnoticed.
Adds 70 tests:
- FeatureRepository: cache hit/miss, TTL, cache key, refresh callbacks,
async fetch with decryption, ETag cache and error handling.
- GrowthBook: load_features / load_features_async, start_auto_refresh and
SSE event dispatch, including the errors raised without a client_key.
- SSEClient: event parsing in _process_response, session start/stop,
reconnect waits, URL building, custom headers, connect and disconnect.
- Serialization: bucket ranges and namespaces as arrays, round-tripping
through features and raw JSON, Experiment.to_dict fields.
Test-only, no source changes.
* test: destroy GrowthBook instances and close mocked coroutines
GrowthBook instances created with a client_key register a callback on
the shared feature_repo, and the new tests never destroyed them, so the
callbacks kept the instances alive and received updates from later
tests. They are now created through fixtures that call destroy() on
teardown.
The disconnect tests mocked asyncio.run_coroutine_threadsafe with only
a return value, leaving the _stop_session() coroutine unawaited and
producing a RuntimeWarning. The mock now closes the coroutine it gets.1 parent e1c3b6b commit e8674e5
1 file changed
Lines changed: 1001 additions & 0 deletions
0 commit comments