dabla commented on code in PR #76793:
URL: https://github.com/apache/airflow/pull/76793#discussion_r4521898311
##########
providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_powerbi.py:
##########
@@ -509,6 +510,24 @@ def
test_execute_preserves_refresh_when_execution_details_fail(
mock_cancel_dataset_refresh.assert_not_awaited()
assert task_state_store.values == {REFRESH_ID_KEY:
PREVIOUS_REFRESH_REQUEST_ID}
+ def test_durable_is_named_on_init_rather_than_left_to_kwargs(self):
+ """Below 3.3 the compat ResumableJobMixin.__init__ has no
`_apply_defaults` wrapper, so
+ `default_args` only reaches `durable` when the operator names it."""
+ init = PowerBIDatasetRefreshOperator.__init__
+ signature = inspect.signature(getattr(init, "__wrapped__", init))
+ assert "durable" in signature.parameters
+
+ @pytest.mark.parametrize("durable", [False, True])
+ def test_default_args_durable_reaches_operator(self, durable):
+ with DAG(
+ dag_id="test_powerbi_durable_default_args",
+ schedule=None,
+ start_date=DEFAULT_DATE,
+ default_args={"durable": durable},
+ ):
+ operator = PowerBIDatasetRefreshOperator(**CONFIG)
+ assert operator.durable is durable
Review Comment:
**[warning]** The `durable=True` case fails below Airflow 3.3, and neither
case can tell whether the fix is there.
Below 3.3 the compat `ResumableJobMixin.__init__` ends with `self.durable =
False` no matter what it gets
([`_resumable_job_mixin.py`](https://github.com/apache/airflow/blob/9602106f7d1e3b3b42a4e390f943d90f69c06c12/providers/common/compat/src/airflow/providers/common/compat/_resumable_job_mixin.py#L41-L51)).
So `assert operator.durable is durable` fails for `True` in the Compat 2.11 /
3.0 / 3.1 / 3.2 provider jobs. That file does run there: its other durable
tests carry `skipif(not AIRFLOW_V_3_3_PLUS)`. The siblings from #71531 avoid
this. Redshift's `test_default_args_durable_reaches_operator` lives in a class
gated on 3.3+, and Livy's checks only `False`.
The test also doesn't pin the fix in either version range:
- on 3.3+ the SDK mixin's own `_apply_defaults` already passes `durable`
through, as the PR description says, and `True` is the default anyway;
- below 3.3, `durable` comes out `False` with or without the fix.
The only thing the fix changes below 3.3 is that the warning now fires. That
is what a below-3.3 test can check. For example:
```python
@pytest.mark.skipif(AIRFLOW_V_3_3_PLUS, reason="The compat ResumableJobMixin
is only used below Airflow 3.3")
def test_default_args_durable_reaches_compat_mixin_below_3_3(self):
with pytest.warns(UserWarning, match="`durable` has no effect on Airflow
versions below 3.3"):
with DAG(dag_id="...", schedule=None, start_date=DEFAULT_DATE,
default_args={"durable": True}):
PowerBIDatasetRefreshOperator(**CONFIG)
```
Keep the `False` check you already have, gated on 3.3+, the same way
Redshift does it. The signature test above it already pins the parameter itself.
--
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]