Skip to content

fix: mock list_validations in config_runner tests to remove GCS dependency#1708

Merged
nj1973 merged 1 commit intoGoogleCloudPlatform:developfrom
yasumorishima:fix/mock-gcs-in-unit-tests
Apr 1, 2026
Merged

fix: mock list_validations in config_runner tests to remove GCS dependency#1708
nj1973 merged 1 commit intoGoogleCloudPlatform:developfrom
yasumorishima:fix/mock-gcs-in-unit-tests

Conversation

@yasumorishima
Copy link
Copy Markdown
Contributor

Summary

  • Mock cli_tools.list_validations in test_config_runner_2 and test_config_runner_4 to remove dependency on real GCS buckets (gs://pso-kokoro-resources)
  • Replace GCS paths in test config dicts with local paths

Issue

Fixes #1482

Root Cause

config_runner() calls cli_tools.list_validations(config_dir=args.config_dir) which reaches gcs_helper.list_gcs_directory() when the path starts with gs://. External contributors without GCS credentials get DefaultCredentialsError.

Changes

  • test_config_runner_2: Added @mock.patch("data_validation.cli_tools.list_validations") returning 3 YAML filenames
  • test_config_runner_4: Added @mock.patch("data_validation.cli_tools.list_validations") returning 4 YAML filenames
  • CONFIG_RUNNER_ARGS_2 / CONFIG_RUNNER_ARGS_4: Changed config_dir from gs://pso-kokoro-resources/... to /tmp/test/...

Testing

$ python -m pytest tests/unit/test__main.py -v
============================= 20 passed in 10.96s ==============================
$ python -m black --check tests/unit/test__main.py
All done! 1 file would be left unchanged.

$ python -m flake8 tests/unit/test__main.py
(no output)

Full unit test suite: 375 passed, 2 failed (pre-existing GCP auth failures unrelated to this change), 10 skipped.

…dency

Tests test_config_runner_2 and test_config_runner_4 were accessing real
GCS buckets (gs://pso-kokoro-resources) via cli_tools.list_validations,
causing failures for external contributors without GCS credentials.

This change:
- Mocks cli_tools.list_validations to return expected YAML file lists
- Replaces GCS paths in test config with local paths

Fixes GoogleCloudPlatform#1482
@nj1973 nj1973 self-requested a review April 1, 2026 08:07
Copy link
Copy Markdown
Collaborator

@nj1973 nj1973 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @yasumorishima , this LGTM.

@nj1973
Copy link
Copy Markdown
Collaborator

nj1973 commented Apr 1, 2026

/gcbrun

@nj1973 nj1973 merged commit 2882d50 into GoogleCloudPlatform:develop Apr 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests that read cloud storage should be refactored

2 participants