From 359b18fadc2c4730f003b32b3a80ae299790770b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 23:26:09 +0000 Subject: [PATCH 1/4] fix: make concurrent declarative source test order-agnostic The test_read_concurrent_declarative_source test was failing on Python 3.13 due to race conditions in concurrent processing that caused records to be returned in different orders. This change replaces the strict list equality assertion with a sorted comparison that validates the same records are present without caring about their order. Fixes the flaky test failure: test_no_pagination_with_partition_router-manifest4-pages4-expected_records4-expected_calls4 Co-Authored-By: AJ Steers --- .../sources/declarative/test_concurrent_declarative_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit_tests/sources/declarative/test_concurrent_declarative_source.py b/unit_tests/sources/declarative/test_concurrent_declarative_source.py index 8fadc04fd..8655d4ba3 100644 --- a/unit_tests/sources/declarative/test_concurrent_declarative_source.py +++ b/unit_tests/sources/declarative/test_concurrent_declarative_source.py @@ -3885,7 +3885,7 @@ def test_read_concurrent_declarative_source( output_data = [ message.record.data for message in _run_read(manifest, _stream_name) if message.record ] - assert output_data == expected_records + assert sorted(output_data, key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0))) == sorted(expected_records, key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0))) mock_retriever.assert_has_calls(expected_calls) From 092b4a473e5e68db8a5f5da655b9c42a9a66bdda Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 23:40:20 +0000 Subject: [PATCH 2/4] fix: apply ruff formatting to test assertion Fixes the Ruff Format Check CI failure by breaking the long assertion line into multiple lines for better readability. Co-Authored-By: AJ Steers --- .../declarative/test_concurrent_declarative_source.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unit_tests/sources/declarative/test_concurrent_declarative_source.py b/unit_tests/sources/declarative/test_concurrent_declarative_source.py index 8655d4ba3..f1e411cfc 100644 --- a/unit_tests/sources/declarative/test_concurrent_declarative_source.py +++ b/unit_tests/sources/declarative/test_concurrent_declarative_source.py @@ -3885,7 +3885,12 @@ def test_read_concurrent_declarative_source( output_data = [ message.record.data for message in _run_read(manifest, _stream_name) if message.record ] - assert sorted(output_data, key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0))) == sorted(expected_records, key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0))) + assert sorted( + output_data, key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0)) + ) == sorted( + expected_records, + key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0)), + ) mock_retriever.assert_has_calls(expected_calls) From 6d66480143efd165fb5de2c7270a4aa9593aef70 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 17:33:55 +0000 Subject: [PATCH 3/4] refactor: extract duplicated sorting key lambda to improve readability Addresses PR comment about duplicated lambda function and long line. Extracts the sorting key logic into a reusable variable to eliminate duplication and improve code readability while maintaining the same order-agnostic comparison functionality. Co-Authored-By: AJ Steers --- .../declarative/test_concurrent_declarative_source.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/unit_tests/sources/declarative/test_concurrent_declarative_source.py b/unit_tests/sources/declarative/test_concurrent_declarative_source.py index f1e411cfc..3869b26ed 100644 --- a/unit_tests/sources/declarative/test_concurrent_declarative_source.py +++ b/unit_tests/sources/declarative/test_concurrent_declarative_source.py @@ -3885,12 +3885,8 @@ def test_read_concurrent_declarative_source( output_data = [ message.record.data for message in _run_read(manifest, _stream_name) if message.record ] - assert sorted( - output_data, key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0)) - ) == sorted( - expected_records, - key=lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0)), - ) + sort_key = lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0)) + assert sorted(output_data, key=sort_key) == sorted(expected_records, key=sort_key) mock_retriever.assert_has_calls(expected_calls) From c70821e8acc6bd85632bc9014a7d3d2945621330 Mon Sep 17 00:00:00 2001 From: "Aaron (\"AJ\") Steers" Date: Wed, 3 Sep 2025 10:48:25 -0700 Subject: [PATCH 4/4] Update unit_tests/sources/declarative/test_concurrent_declarative_source.py --- .../sources/declarative/test_concurrent_declarative_source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unit_tests/sources/declarative/test_concurrent_declarative_source.py b/unit_tests/sources/declarative/test_concurrent_declarative_source.py index 3869b26ed..777910c00 100644 --- a/unit_tests/sources/declarative/test_concurrent_declarative_source.py +++ b/unit_tests/sources/declarative/test_concurrent_declarative_source.py @@ -3885,7 +3885,7 @@ def test_read_concurrent_declarative_source( output_data = [ message.record.data for message in _run_read(manifest, _stream_name) if message.record ] - sort_key = lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0)) + sort_key = lambda x: (x.get("partition", 0), x.get("ABC", 0), x.get("AED", 0), x.get("USD", 0)) assert sorted(output_data, key=sort_key) == sorted(expected_records, key=sort_key) mock_retriever.assert_has_calls(expected_calls)