Taragolis commented on code in PR #28996:
URL: https://github.com/apache/airflow/pull/28996#discussion_r1072998615


##########
tests/providers/docker/decorators/test_docker.py:
##########
@@ -100,3 +104,29 @@ def do_run():
 
         assert len(dag.task_ids) == 21
         assert dag.task_ids[-1] == "do_run__20"
+
+    @pytest.mark.parametrize(
+        "extra_kwargs, actual_exit_code, expected_state",
+        [
+            (None, 99, TaskInstanceState.FAILED),
+            ({"skip_exit_code": 100}, 100, TaskInstanceState.SKIPPED),
+            ({"skip_exit_code": 100}, 101, TaskInstanceState.FAILED),
+            ({"skip_exit_code": None}, 0, TaskInstanceState.SUCCESS),
+        ],
+    )
+    def test_skip_docker_operator(self, extra_kwargs, actual_exit_code, 
expected_state, dag_maker):
+        @task.docker(image="python:3.9-slim", **(extra_kwargs if extra_kwargs 
else {}))

Review Comment:
   ```suggestion
           @task.docker(image="python:3.9-slim", auto_remove="force", 
**(extra_kwargs if extra_kwargs else {}))
   ```
   
   Better to remove image after test run



##########
tests/providers/docker/decorators/test_docker.py:
##########
@@ -100,3 +104,29 @@ def do_run():
 
         assert len(dag.task_ids) == 21
         assert dag.task_ids[-1] == "do_run__20"
+
+    @pytest.mark.parametrize(
+        "extra_kwargs, actual_exit_code, expected_state",
+        [
+            (None, 99, TaskInstanceState.FAILED),
+            ({"skip_exit_code": 100}, 100, TaskInstanceState.SKIPPED),
+            ({"skip_exit_code": 100}, 101, TaskInstanceState.FAILED),
+            ({"skip_exit_code": None}, 0, TaskInstanceState.SUCCESS),
+        ],
+    )
+    def test_skip_docker_operator(self, extra_kwargs, actual_exit_code, 
expected_state, dag_maker):
+        @task.docker(image="python:3.9-slim", **(extra_kwargs if extra_kwargs 
else {}))
+        def f(exit_code):
+            exit(exit_code)

Review Comment:
   ```suggestion
               raise SystemExit(exit_code)
   ```
   Better use [sys.exit()](https://docs.python.org/3/library/sys.html#sys.exit) 
or raise SystemExit(), if you don't wont to import `sys`, rather then 
[exit()](https://docs.python.org/3/library/constants.html#constants-added-by-the-site-module)



-- 
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]

Reply via email to