Skip to content

Add tests for the Google Cloud Tasks links - #72846

Merged
shahar1 merged 1 commit into
apache:mainfrom
xlsongc:add-tests-google-cloud-tasks-links
Sep 27, 2026
Merged

shahar1 merged 1 commit into
apache:mainfrom
xlsongc:add-tests-google-cloud-tasks-links

Conversation

@xlsongc

@xlsongc xlsongc commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

google.cloud.links.cloud_tasks had no unit tests and was suppressed by the
OVERLOOKED_TESTS allowlist in airflow-core/tests/unit/always/test_project_structure.py.

CloudTasksQueueLink is attached to eleven operators in google.cloud.operators.tasks,
and its extract_parts() helper parses the
projects/<project>/locations/<location>/queues/<queue> resource name that every one of
those links is built from — none of which was exercised by a test.

This adds providers/google/tests/unit/google/cloud/links/test_cloud_tasks.py and removes
the allowlist entry. The tests follow the existing shape of the link tests in that
directory (test_cloud_run.py, test_dataplex.py).

Covered:

  • class attributes (name / key / format_str) for CloudTasksQueueLink and CloudTasksLink
  • CloudTasksQueueLink.extract_parts() — full resource name, None, and empty string
  • CloudTasksQueueLink.persist() with and without a queue_name, asserting what is pushed to XCom
  • get_link() end to end for both links, asserting the rendered console URL

No production code is changed.

One thing I noticed but deliberately left alone: extract_parts() guards against a falsy
queue_name but indexes parts[1], parts[3], parts[5] unconditionally otherwise, so a
name that is not a full queue resource path raises IndexError. In practice the value comes
straight from the Cloud Tasks API, so I did not want to bake current behaviour into a test or
change it in a test-only PR. Happy to follow up separately if maintainers think it is worth
hardening.

Verified locally:

pytest providers/google/tests/unit/google/cloud/links/            # 84 passed
pytest airflow-core/tests/unit/always/test_project_structure.py   # 10 passed, 1 xfailed
ruff check / ruff format                                          # clean

related: #35442


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines


🤖 Generated with Claude Code

@xlsongc
xlsongc requested a review from shahar1 as a code owner September 9, 2026 21:05
@boring-cyborg boring-cyborg Bot added area:providers provider:google Google (including GCP) related issues labels Sep 9, 2026
@boring-cyborg

boring-cyborg Bot commented Sep 9, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

`CloudTasksQueueLink` and `CloudTasksLink` had no unit tests, so they were
suppressed by the `OVERLOOKED_TESTS` allowlist. `CloudTasksQueueLink` is
attached to eleven operators in `google.cloud.operators.tasks` and its
`extract_parts()` helper parses the queue resource name that every one of
those links is built from, but none of that ran under test.

@shahar1 shahar1 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.

Thanks for the added tests!
Wlecome to Apache Airflow :)

@shahar1
shahar1 merged commit 5bc738e into apache:main Sep 27, 2026
85 checks passed
@boring-cyborg

boring-cyborg Bot commented Sep 27, 2026

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:google Google (including GCP) related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants