Zeeshan-Chaudhry opened a new pull request, #73262:
URL: https://github.com/apache/airflow/pull/73262

   Neither `common.compat.standard.operators` nor 
`common.compat.standard.triggers` had a test module, and nothing under any 
`providers/*/tests/` directory imported them, so a broken fallback import in 
either shim would only have surfaced in a downstream provider. Both were also 
exempted in the `OVERLOOKED_TESTS` allowlist in 
`airflow-core/tests/unit/always/test_project_structure.py`.
   
   This adds the two test modules and removes those two allowlist entries, 
following the existing pattern in 
`providers/common/compat/tests/unit/common/compat/test_sdk.py` and the shape of 
the sibling PR #72487.
   
   What the tests cover:
   
   * `__all__` equals a hardcoded expected export list, so an accidentally 
removed compat export is caught. The list is deliberately hardcoded rather than 
derived from `__all__`, following the review feedback on #72487.
   * Every export resolves to a non-`None` object.
   * An unknown attribute raises `AttributeError` with the `module has no 
attribute ...` message from `_compat_utils.py`.
   * `is_async_callable` detects coroutine functions through nested 
`functools.partial` wrappers. The cases asserted are only those that hold on 
both sides of the Airflow 3.2 fork, so the local stub and the Task SDK 
implementation agree on all of them.
   * On Airflow < 3.2 only, the `BaseAsyncOperator` stub reports `is_async is 
True` and its `execute()` raises `RuntimeError`.
   
   ### How this was verified
   
   Docker is not available on my machine, so the `breeze testing 
providers-tests ...` commands in the issue's Definition of Done could not be 
run. I used the local virtualenv route documented in 
`contributing-docs/07_local_virtualenv.rst` instead:
   
   ```
   uv run --no-sync pytest 
providers/common/compat/tests/unit/common/compat/standard -v  # 19 passed, 2 
skipped
   uv run --no-sync pytest providers/common/compat/tests/unit -q                
         # 240 passed, 7 skipped
   uv run --no-sync pytest 
airflow-core/tests/unit/always/test_project_structure.py -q   # 10 passed, 1 
xfailed
   prek run --from-ref main --stage pre-commit
   uv run --no-sync mypy --config-file pyproject.toml <the four changed files>  
          # no issues
   ```
   
   Every prek hook in that stage passes except 
`check-tests-in-the-right-folders`, which exits early because `breeze` is not 
on my PATH. I ran `scripts/ci/prek/check_tests_in_right_folders.py` directly on 
the changed core test file and it passes.
   
   The provider run also reports 2 errors in `connection/test_connection.py` 
(`ModuleNotFoundError: No module named 'airflow_shared'`). They are present 
unchanged on `main` at the same commit and are an artifact of my local venv, 
not of this change.
   
   Red then green on the guard test: with the two allowlist entries removed but 
the test modules not yet added, `test_providers_modules_should_have_tests` 
fails with `Detect missing tests in providers module - please add tests` 
listing both paths. Adding the modules makes it pass.
   
   The two version-gated stub tests are skipped locally, since the checkout is 
Airflow 3.4.0. I exercised that branch in a throwaway process with 
`AIRFLOW_V_3_2_PLUS` patched to `False`, which makes `operators.py` define the 
stub: all 21 tests in the new directory then pass, including the two stub 
tests. The providers compatibility matrix jobs (Airflow 2.11.1, 3.0.6, 3.1.8) 
are what exercise that branch for real.
   
   ### One observation, not changed here
   
   The `_IMPORT_MAP` entries for `BaseAsyncOperator` and `is_async_callable` 
point at `airflow.providers.common.compat.sdk`, which exports neither name. 
They resolve only because `operators.py` binds both at module level, which 
shadows the module `__getattr__`. The tests therefore use plain `getattr`, 
which is how callers reach these names. I left the mapping alone to keep this 
PR single purpose, and am happy to follow up with a separate PR if maintainers 
want it fixed.
   
   Note on overlap: #72487 also adds 
`providers/common/compat/tests/unit/common/compat/standard/__init__.py`. If it 
merges first I will rebase and drop that file from this diff. I left its 
`OVERLOOKED_TESTS` entry for `test_utils.py` untouched.
   
   closes: #72263
   related: #35442
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes - Claude Code (Opus 5)
   
   Generated-by: Claude Code (Opus 5) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_018eXNgswooRJJY6s1cXniYB
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to