jroachgolf84 opened a new issue, #72265:
URL: https://github.com/apache/airflow/issues/72265

   ## Description
   
   > This is an issue that is reserved for the Airflow Summit "Contributors" 
Workshop. This is denoted with the label `contributors-workshop`. Out of 
respect for the organizers and participants of this workshop, **please do not 
implement a PR that addresses this issue.**
   > 
   > If this issue is still open following Airflow Summit, the label will be 
removed and the issue can be picked up.
   
   Two modules in the `cncf.kubernetes` provider have no dedicated test module, 
and (unlike most entries on the `OVERLOOKED_TESTS` list) they are not covered 
indirectly. Nothing under any `providers/*/tests/` directory imports them at 
all:
   
   | Module | Expected test file |
   | --- | --- |
   | 
`providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/python_kubernetes_script.py`
 | 
`providers/cncf/kubernetes/tests/unit/cncf/kubernetes/test_python_kubernetes_script.py`
 |
   | 
`providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/utils/delete_from.py`
 | 
`providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_delete_from.py`
 |
   
   Both are currently suppressed in the `OVERLOOKED_TESTS` allowlist in 
[`airflow-core/tests/unit/always/test_project_structure.py`](https://github.com/apache/airflow/blob/main/airflow-core/tests/unit/always/test_project_structure.py).
   
   This is a scoped subset of the meta issue #35442, limited to the 
`cncf.kubernetes` provider.
   
   ### What should these tests cover?
   
   `python_kubernetes_script.py` backs the `@task.kubernetes` decorator. 
`remove_task_decorator` does string surgery on user source, stripping `@setup`, 
`@teardown` and the task decorator itself, with `_balance_parens` walking 
nested parentheses to find where a parameterised decorator ends. That is easy 
to break and the failure mode is silently corrupted user code, so it is worth 
covering directly:
   
   - a decorator with no arguments, with arguments, and with nested parentheses 
inside the arguments
   - source carrying `@setup` and `@teardown` alongside the task decorator
   - source where the decorator name never appears, which should return the 
input unchanged
   - `write_python_script` rendering the Jinja template to the target file, 
including `render_template_as_native_obj=True` selecting `NativeEnvironment`, 
and `StrictUndefined` raising on a missing context variable
   
   While writing these it is worth pinning the current behaviour of the inner 
`_remove_task_decorator`, which reads `python_source` from the enclosing scope 
rather than its own `py_source` argument. The two happen to be the same object 
on every iteration of the loop that calls it, so the result is correct today, 
but nothing stops that from silently changing.
   
   `delete_from.py` is vendored from `kubernetes_asyncio` and mirrors the 
upstream `create_from_yaml` helpers. Worth covering:
   
   - the API class name derivation in `_delete_from_yaml_single_item` from 
`apiVersion`, covering the core group, a named group, `.k8s.io` stripping, and 
DNS subdomain to CamelCase conversion
   - the kind conversion from CamelCase to snake_case
   - namespaced versus non namespaced dispatch, meaning 
`delete_namespaced_<kind>` when the API exposes it and `delete_<kind>` otherwise
   - a `namespace` in the document metadata taking precedence over the 
`namespace` argument, which the code calls out explicitly
   - `List` kinds fanning out over `items` and inheriting `apiVersion` from the 
parent document
   - `ApiException`s being collected rather than raised eagerly, then surfaced 
together as `FailToDeleteError`, plus the `FailToDeleteError.__str__` formatting
   
   These can all be driven with mocked `kubernetes.client` API classes using 
`autospec`, so no cluster is required.
   
   ## Definition of Done
   
   1. Add the two test modules at the paths in the table above.
   2. Remove the two corresponding entries from `OVERLOOKED_TESTS` in 
`airflow-core/tests/unit/always/test_project_structure.py`
   3. Both of these tests should pass:
   
   ```bash
   breeze testing providers-tests 
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/test_python_kubernetes_script.py
   
   breeze testing providers-tests 
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/utils/test_delete_from.py
   ```
   
   
   ---
   Drafted-by: Claude Code (Opus 5); reviewed and edited by @jroachgolf84 
before posting.
   


-- 
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