Skip to content

Commit 63bfe41

Browse files
matthewelwellclaude
andcommitted
test(Segment Membership): Cover the all-ineligible seed batch
One identity per batch, so the traitless one forms a batch with nothing left to write, and assert no INSERT is issued with an empty row list. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 815cb66 commit 63bfe41

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

api/tests/unit/segment_membership/test_unit_segment_membership_tasks.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ def test_seed_organisation_identities__traitless_identities__are_not_mirrored(
164164
# Given
165165
enable_features("segment_membership_inspection")
166166
settings.CLICKHOUSE_ENABLED = True
167+
# One identity per batch, so `dave` forms a batch with nothing left to write.
168+
mocker.patch.object(tasks, "_INSERT_BATCH_SIZE", 1)
167169
for identifier, extra in (
168170
("dave", {}),
169171
("erin", {"system_traits": {"flagsmith_cohort_e2b1": True}}),
@@ -189,10 +191,11 @@ def test_seed_organisation_identities__traitless_identities__are_not_mirrored(
189191
# Then
190192
# `dave` has nothing on him at all; `erin`'s cohort membership lives in
191193
# `system_traits`, so she stays in the mirror.
192-
mirrored_identifiers = sorted(
193-
row[1] for call in cursor.executemany.call_args_list for row in call.args[1]
194-
)
194+
payloads = [call.args[1] for call in cursor.executemany.call_args_list]
195+
mirrored_identifiers = sorted(row[1] for payload in payloads for row in payload)
195196
assert mirrored_identifiers == ["alice", "carol", "erin"]
197+
# `dave`'s batch is skipped outright rather than written as an empty INSERT.
198+
assert all(payloads)
196199

197200

198201
@pytest.mark.clickhouse

0 commit comments

Comments
 (0)