Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit b7ea81a

Browse files
committed
merges content from temp file to permanent file, deletes temp file
1 parent 7e9b9f9 commit b7ea81a

2 files changed

Lines changed: 44 additions & 48 deletions

File tree

tests/unit/test__pandas_helpers.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,3 +2339,47 @@ def pages_gen():
23392339
else:
23402340
results = list(iterator)
23412341
assert len(results) == 1
2342+
2343+
2344+
@pytest.mark.skipif(
2345+
bigquery_storage is None, reason="Requires `google-cloud-bigquery-storage`"
2346+
)
2347+
def test_download_arrow_bqstorage_passes_timeout_to_create_read_session(
2348+
module_under_test,
2349+
):
2350+
# Mock dependencies
2351+
project_id = "test-project"
2352+
table = mock.Mock()
2353+
table.table_id = "test_table"
2354+
table.to_bqstorage.return_value = "projects/test/datasets/test/tables/test"
2355+
2356+
bqstorage_client = mock.create_autospec(
2357+
bigquery_storage.BigQueryReadClient, instance=True
2358+
)
2359+
# Mock create_read_session to return a session with no streams so the function returns early
2360+
# (Checking start of loop logic vs empty streams return)
2361+
session = mock.Mock()
2362+
# If streams is empty, _download_table_bqstorage returns early, which is fine for this test
2363+
session.streams = []
2364+
bqstorage_client.create_read_session.return_value = session
2365+
2366+
# Call the function
2367+
timeout = 123.456
2368+
# download_arrow_bqstorage yields frames, so we need to iterate to trigger execution
2369+
list(
2370+
module_under_test.download_arrow_bqstorage(
2371+
project_id, table, bqstorage_client, timeout=timeout
2372+
)
2373+
)
2374+
2375+
# Verify timeout and retry were passed
2376+
bqstorage_client.create_read_session.assert_called_once()
2377+
_, kwargs = bqstorage_client.create_read_session.call_args
2378+
assert "timeout" in kwargs
2379+
assert kwargs["timeout"] == timeout
2380+
2381+
assert "retry" in kwargs
2382+
retry_policy = kwargs["retry"]
2383+
assert retry_policy is not None
2384+
# Check if deadline is set correctly in the retry policy
2385+
assert retry_policy._deadline == timeout

tests/unit/test_download_bqstorage_timeout.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)