dabla commented on code in PR #62241:
URL: https://github.com/apache/airflow/pull/62241#discussion_r2883770039
##########
providers/microsoft/azure/tests/unit/microsoft/azure/sensors/test_msgraph.py:
##########
@@ -141,3 +141,24 @@ def test_template_fields(self):
for template_field in MSGraphSensor.template_fields:
getattr(sensor, template_field)
+
+ def test_execute_complete_passes_timeout_to_defer(self):
+ from datetime import timedelta
+ from unittest.mock import Mock, patch
+
+ sensor = MSGraphSensor(
+ task_id="check_timeout",
+ conn_id="powerbi",
+ url="myorg/admin/workspaces/scanStatus/{scanId}",
+ timeout=10,
+ )
+
+ context = {"ti": Mock()}
+
+ with patch.object(sensor, "defer") as mock_defer:
+ sensor.execute_complete(
+ context=context, event={"status": "success", "response":
json.dumps({"status": "running"})}
Review Comment:
Think just passing empty dict to context would be enough? No need to create
context from dict with mocked TaskInstance.
##########
providers/microsoft/azure/tests/unit/microsoft/azure/sensors/test_msgraph.py:
##########
@@ -141,3 +141,24 @@ def test_template_fields(self):
for template_field in MSGraphSensor.template_fields:
getattr(sensor, template_field)
+
+ def test_execute_complete_passes_timeout_to_defer(self):
+ from datetime import timedelta
+ from unittest.mock import Mock, patch
+
+ sensor = MSGraphSensor(
+ task_id="check_timeout",
+ conn_id="powerbi",
+ url="myorg/admin/workspaces/scanStatus/{scanId}",
+ timeout=10,
+ )
+
+ context = {"ti": Mock()}
+
+ with patch.object(sensor, "defer") as mock_defer:
+ sensor.execute_complete(
+ context=context, event={"status": "success", "response":
json.dumps({"status": "running"})}
+ )
+ mock_defer.assert_called_once()
+ call_kwargs = mock_defer.call_args.kwargs
Review Comment:
This could become oneline:
```
call_kwargs = mock_defer.call_args.kwargs
assert call_kwargs["timeout"] == timedelta(seconds=10)
```
Into:
```
assert mock_defer.call_args.kwargs["timeout"] == timedelta(seconds=10)
```
--
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]