This is an automated email from the ASF dual-hosted git repository.
weilee pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 037274398d fix: HttpSensorTrigger to include `method` when serializing
(#42925)
037274398d is described below
commit 037274398d5380f1ab5e94f6fd60e742840fe8b4
Author: Kalyan R <[email protected]>
AuthorDate: Fri Oct 11 12:27:09 2024 +0530
fix: HttpSensorTrigger to include `method` when serializing (#42925)
---
.../src/airflow/providers/http/triggers/http.py | 1 +
providers/tests/http/triggers/test_http.py | 33 +++++++++++++++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/providers/src/airflow/providers/http/triggers/http.py
b/providers/src/airflow/providers/http/triggers/http.py
index 59a484b081..543cd323b8 100644
--- a/providers/src/airflow/providers/http/triggers/http.py
+++ b/providers/src/airflow/providers/http/triggers/http.py
@@ -167,6 +167,7 @@ class HttpSensorTrigger(BaseTrigger):
{
"endpoint": self.endpoint,
"data": self.data,
+ "method": self.method,
"headers": self.headers,
"extra_options": self.extra_options,
"http_conn_id": self.http_conn_id,
diff --git a/providers/tests/http/triggers/test_http.py
b/providers/tests/http/triggers/test_http.py
index a4f2559876..8af78149b2 100644
--- a/providers/tests/http/triggers/test_http.py
+++ b/providers/tests/http/triggers/test_http.py
@@ -30,7 +30,7 @@ from multidict import CIMultiDict, CIMultiDictProxy
from requests.structures import CaseInsensitiveDict
from yarl import URL
-from airflow.providers.http.triggers.http import HttpTrigger
+from airflow.providers.http.triggers.http import HttpSensorTrigger, HttpTrigger
from airflow.triggers.base import TriggerEvent
HTTP_PATH = "airflow.providers.http.triggers.http.{}"
@@ -56,6 +56,18 @@ def trigger():
)
[email protected]
+def sensor_trigger():
+ return HttpSensorTrigger(
+ http_conn_id=TEST_CONN_ID,
+ endpoint=TEST_ENDPOINT,
+ method=TEST_METHOD,
+ headers=TEST_HEADERS,
+ data=TEST_DATA,
+ extra_options=TEST_EXTRA_OPTIONS,
+ )
+
+
@pytest.fixture
def client_response():
client_response = mock.AsyncMock(ClientResponse)
@@ -153,3 +165,22 @@ class TestHttpTrigger:
assert kwargs["data"] == TEST_DATA
assert kwargs["json"] is None
assert kwargs["params"] is None
+
+
+class TestHttpSensorTrigger:
+ def test_serialization(self, sensor_trigger):
+ """
+ Asserts that the HttpSensorTrigger correctly serializes its arguments
+ and classpath.
+ """
+ classpath, kwargs = sensor_trigger.serialize()
+ assert classpath ==
"airflow.providers.http.triggers.http.HttpSensorTrigger"
+ assert kwargs == {
+ "http_conn_id": TEST_CONN_ID,
+ "endpoint": TEST_ENDPOINT,
+ "method": TEST_METHOD,
+ "headers": TEST_HEADERS,
+ "data": TEST_DATA,
+ "extra_options": TEST_EXTRA_OPTIONS,
+ "poke_interval": 5.0,
+ }