This is an automated email from the ASF dual-hosted git repository.

potiuk 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 cbaea573b3 Update the error message for invalid use of poke-only 
sensors (#30821)
cbaea573b3 is described below

commit cbaea573b3658dd941335e21c5f29118b31cb6d8
Author: Dakshin K <[email protected]>
AuthorDate: Sun Apr 23 16:07:43 2023 +0530

    Update the error message for invalid use of poke-only sensors (#30821)
---
 airflow/sensors/base.py    | 2 +-
 tests/sensors/test_base.py | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/airflow/sensors/base.py b/airflow/sensors/base.py
index 13b386d247..d3cf6451a0 100644
--- a/airflow/sensors/base.py
+++ b/airflow/sensors/base.py
@@ -322,7 +322,7 @@ def poke_mode_only(cls):
 
         def mode_setter(_, value):
             if value != "poke":
-                raise ValueError("cannot set mode to 'poke'.")
+                raise ValueError(f"Cannot set mode to '{value}'. Only 'poke' 
is acceptable")
 
         if not issubclass(cls_type, BaseSensorOperator):
             raise ValueError(
diff --git a/tests/sensors/test_base.py b/tests/sensors/test_base.py
index 3b1571e094..6798dd9972 100644
--- a/tests/sensors/test_base.py
+++ b/tests/sensors/test_base.py
@@ -862,14 +862,14 @@ class TestPokeModeOnly:
 
     def test_poke_mode_only_bad_class_method(self):
         sensor = DummyPokeOnlySensor(task_id="foo", mode="poke", 
poke_changes_mode=False)
-        with pytest.raises(ValueError):
+        with pytest.raises(ValueError, match="Cannot set mode to 'reschedule'. 
Only 'poke' is acceptable"):
             sensor.change_mode("reschedule")
 
     def test_poke_mode_only_bad_init(self):
-        with pytest.raises(ValueError):
+        with pytest.raises(ValueError, match="Cannot set mode to 'reschedule'. 
Only 'poke' is acceptable"):
             DummyPokeOnlySensor(task_id="foo", mode="reschedule", 
poke_changes_mode=False)
 
     def test_poke_mode_only_bad_poke(self):
         sensor = DummyPokeOnlySensor(task_id="foo", mode="poke", 
poke_changes_mode=True)
-        with pytest.raises(ValueError):
+        with pytest.raises(ValueError, match="Cannot set mode to 'reschedule'. 
Only 'poke' is acceptable"):
             sensor.poke({})

Reply via email to