From 4421f4bfdebf3cca7ce0229027d388b287c0b338 Mon Sep 17 00:00:00 2001 From: Martynov Maxim Date: Fri, 22 Dec 2023 00:11:14 +0300 Subject: [PATCH] Allow SSHOperator.skip_on_exit_code to be zero --- airflow/providers/ssh/operators/ssh.py | 2 +- tests/providers/ssh/operators/test_ssh.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/airflow/providers/ssh/operators/ssh.py b/airflow/providers/ssh/operators/ssh.py index 621dc475393a3..ca5d450c0d0bd 100644 --- a/airflow/providers/ssh/operators/ssh.py +++ b/airflow/providers/ssh/operators/ssh.py @@ -114,7 +114,7 @@ def __init__( skip_on_exit_code if isinstance(skip_on_exit_code, Container) else [skip_on_exit_code] - if skip_on_exit_code + if skip_on_exit_code is not None else [] ) diff --git a/tests/providers/ssh/operators/test_ssh.py b/tests/providers/ssh/operators/test_ssh.py index 241f3c8c7bea4..0cb42544ba3b3 100644 --- a/tests/providers/ssh/operators/test_ssh.py +++ b/tests/providers/ssh/operators/test_ssh.py @@ -208,13 +208,19 @@ def test_ssh_client_managed_correctly(self): [ ({}, 0, None), ({}, 100, AirflowException), + ({}, 101, AirflowException), ({"skip_on_exit_code": None}, 0, None), ({"skip_on_exit_code": None}, 100, AirflowException), + ({"skip_on_exit_code": None}, 101, AirflowException), + ({"skip_on_exit_code": 100}, 0, None), ({"skip_on_exit_code": 100}, 100, AirflowSkipException), ({"skip_on_exit_code": 100}, 101, AirflowException), + ({"skip_on_exit_code": 0}, 0, AirflowSkipException), + ({"skip_on_exit_code": [100]}, 0, None), ({"skip_on_exit_code": [100]}, 100, AirflowSkipException), ({"skip_on_exit_code": [100]}, 101, AirflowException), ({"skip_on_exit_code": [100, 102]}, 101, AirflowException), + ({"skip_on_exit_code": (100,)}, 0, None), ({"skip_on_exit_code": (100,)}, 100, AirflowSkipException), ({"skip_on_exit_code": (100,)}, 101, AirflowException), ],