Skip to content

Commit 0439cbc

Browse files
authored
Clarify cdk parity test behavior (#37407)
1 parent e3be633 commit 0439cbc

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

airbyte-cdk/python/unit_tests/sources/streams/test_stream_read.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ def test_full_refresh_read_a_single_slice_with_debug(constructor):
170170
*records,
171171
]
172172

173-
# Temporary check to only validate the final state message for synchronous sources since it has not been implemented for concurrent yet
173+
# Synchronous streams emit a final state message to indicate that the stream has finished reading
174+
# Concurrent streams don't emit their own state messages - the concurrent source observes the cursor
175+
# and emits the state messages. Therefore, we can only check the value of the cursor's state at the end
174176
if constructor == _stream:
175177
expected_records.append(
176178
AirbyteMessage(
@@ -187,6 +189,10 @@ def test_full_refresh_read_a_single_slice_with_debug(constructor):
187189

188190
actual_records = _read(stream, configured_stream, logger, slice_logger, message_repository, state_manager, internal_config)
189191

192+
if constructor == _concurrent_stream:
193+
assert hasattr(stream._cursor, "state")
194+
assert str(stream._cursor.state) == "{'__ab_full_refresh_state_message': True}"
195+
190196
assert actual_records == expected_records
191197

192198

@@ -216,7 +222,9 @@ def test_full_refresh_read_a_single_slice(constructor):
216222

217223
expected_records = [*records]
218224

219-
# Temporary check to only validate the final state message for synchronous sources since it has not been implemented for concurrent yet
225+
# Synchronous streams emit a final state message to indicate that the stream has finished reading
226+
# Concurrent streams don't emit their own state messages - the concurrent source observes the cursor
227+
# and emits the state messages. Therefore, we can only check the value of the cursor's state at the end
220228
if constructor == _stream:
221229
expected_records.append(
222230
AirbyteMessage(
@@ -233,6 +241,10 @@ def test_full_refresh_read_a_single_slice(constructor):
233241

234242
actual_records = _read(stream, configured_stream, logger, slice_logger, message_repository, state_manager, internal_config)
235243

244+
if constructor == _concurrent_stream:
245+
assert hasattr(stream._cursor, "state")
246+
assert str(stream._cursor.state) == "{'__ab_full_refresh_state_message': True}"
247+
236248
assert actual_records == expected_records
237249

238250

@@ -270,7 +282,9 @@ def test_full_refresh_read_two_slices(constructor):
270282
*records_partition_2,
271283
]
272284

273-
# Temporary check to only validate the final state message for synchronous sources since it has not been implemented for concurrent yet
285+
# Synchronous streams emit a final state message to indicate that the stream has finished reading
286+
# Concurrent streams don't emit their own state messages - the concurrent source observes the cursor
287+
# and emits the state messages. Therefore, we can only check the value of the cursor's state at the end
274288
if constructor == _stream or constructor == _stream_with_no_cursor_field:
275289
expected_records.append(
276290
AirbyteMessage(
@@ -287,6 +301,10 @@ def test_full_refresh_read_two_slices(constructor):
287301

288302
actual_records = _read(stream, configured_stream, logger, slice_logger, message_repository, state_manager, internal_config)
289303

304+
if constructor == _concurrent_stream:
305+
assert hasattr(stream._cursor, "state")
306+
assert str(stream._cursor.state) == "{'__ab_full_refresh_state_message': True}"
307+
290308
for record in expected_records:
291309
assert record in actual_records
292310
assert len(actual_records) == len(expected_records)

0 commit comments

Comments
 (0)