Skip to content

feat(dataflow): Create test_batch_process_storage.py - #15024

Open
cbonnie wants to merge 2 commits into
mainfrom
cbonnie-patch-3
Open

cbonnie wants to merge 2 commits into
mainfrom
cbonnie-patch-3

Conversation

@cbonnie

@cbonnie cbonnie commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Add automated test for the batch sample, batch_process_storage.py.

Description

Bug # http://b/589715201

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

Add automated test for the batch sample, batch_process_storage.py.
@cbonnie
cbonnie requested review from a team as code owners December 3, 2026 15:18
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Dec 3, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new integration test test_batch_process_storage.py to verify the batch_process_storage pipeline using a temporary Google Cloud Storage bucket. The review feedback recommends refactoring the module-level storage.Client() instantiation into a pytest fixture to avoid test collection failures in environments where Google Cloud credentials are not configured.

Comment on lines +31 to +43
storage_client = storage.Client()


@pytest.fixture(scope="function")
def bucket_name() -> Iterator[str]:
bucket = storage_client.create_bucket(f"test-bucket-{uuid.uuid4()}")
try:
yield bucket.name
finally:
bucket.delete(force=True)


def test_batch_process_storage(bucket_name: str) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instantiating storage.Client() at the module level can cause test collection to fail in environments where Google Cloud credentials are not configured (e.g., during local linting or dry-run test execution). It is recommended to define storage_client as a pytest fixture and pass it to the dependent fixtures and tests.

Suggested change
storage_client = storage.Client()
@pytest.fixture(scope="function")
def bucket_name() -> Iterator[str]:
bucket = storage_client.create_bucket(f"test-bucket-{uuid.uuid4()}")
try:
yield bucket.name
finally:
bucket.delete(force=True)
def test_batch_process_storage(bucket_name: str) -> None:
@pytest.fixture(scope="session")
def storage_client() -> storage.Client:
return storage.Client()
@pytest.fixture(scope="function")
def bucket_name(storage_client: storage.Client) -> Iterator[str]:
bucket = storage_client.create_bucket(f"test-bucket-{uuid.uuid4()}")
try:
yield bucket.name
finally:
bucket.delete(force=True)
def test_batch_process_storage(storage_client: storage.Client, bucket_name: str) -> None:

Improve test_batch_process_storage.py
@cbonnie cbonnie mentioned this pull request Dec 3, 2026
5 tasks done
@iennae iennae changed the title Create test_batch_process_storage.py feat(dataflow): Create test_batch_process_storage.py Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants