Skip to content

test: cover the sync SSE client and bucket range serialization - #115

Open
vazarkevych wants to merge 1 commit into
growthbook:mainfrom
vazarkevych:test/upgrade-test-coverage
Open

vazarkevych wants to merge 1 commit into
growthbook:mainfrom
vazarkevych:test/upgrade-test-coverage

Conversation

@vazarkevych

@vazarkevych vazarkevych commented Apr 27, 2026 •

Copy link
Copy Markdown
Collaborator

The sync streaming path had no test coverage. Main exercises SSE only through
the async client, so SSEClient, GrowthBook.start_auto_refresh and
_dispatch_sse_event were untested — a regression in any of them would have
gone unnoticed.

Adds 33 tests across three areas:

SSEClient — connect idempotency, URL building (including trailing-slash
handling), custom header merging, and the disconnect paths: no loop/thread,
joining the thread, warning when it outlives the join, stopping the session only
when the loop is running, and force-stopping the loop on a future exception.

GrowthBook.start_auto_refresh / _dispatch_sse_event — delegation to the
repository, the callback that gets wired up, the ValueError raised without a
client_key, and each event type including an unknown one.

Serialization — bucket ranges as two-element arrays, namespaces as
three-element arrays, the distinction between the two, round-tripping through
features and raw JSON, and Experiment.to_dict scalar fields.

Test-only: no source changes. The original branch also carried a fix for
multi-line data: joining in _process_response, which main has since fixed
independently, so it's dropped here.

Rebuilt as a single commit on top of current main rather than merged — the old
branch had two merge commits and the stale source change tangled into the
conflicts.

1041 tests pass.

@vazarkevych
vazarkevych requested a review from madhuchavva April 27, 2026 15:17
@vazarkevych
vazarkevych force-pushed the test/upgrade-test-coverage branch from be8d13c to 629d761 Compare September 17, 2026 10:23
@vazarkevych vazarkevych changed the title test: upgrade test coverage for growthbook test: cover the sync SSE client and bucket range serialization Sep 17, 2026
Rebuilt on top of current main as a single test-only commit; the original
branch's source change (multi-line `data:` joining in `_process_response`) is
already in main, fixed there independently.

The sync streaming path had no tests at all — main exercises SSE only through
the async client, so `SSEClient`, `GrowthBook.start_auto_refresh` and
`_dispatch_sse_event` were uncovered. Adds 33 tests across three areas:

- `SSEClient`: connect idempotency, URL building (including trailing-slash
  handling), custom header merging, and the disconnect paths — no loop/thread,
  joining, warning when the thread outlives the join, stopping the session only
  when the loop is running, and force-stopping on a future exception.
- `GrowthBook.start_auto_refresh` / `_dispatch_sse_event`: delegation to the
  repository, the callback that gets wired up, the ValueError without a
  client_key, and each event type including an unknown one.
- Serialization: bucket ranges as two-element arrays, namespaces as
  three-element arrays, the distinction between the two, round-tripping through
  features and raw JSON, and `Experiment.to_dict` scalar fields.

1041 tests pass.
@vazarkevych
vazarkevych force-pushed the test/upgrade-test-coverage branch from 629d761 to a29b610 Compare October 5, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant