This is an automated email from the ASF dual-hosted git repository.
eladkal 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 dae2d44695 add unit test for send_sigterm() (#36852)
dae2d44695 is described below
commit dae2d44695e0bf6eb87c184767cac26ebc5dadd8
Author: Daniel Reeves <[email protected]>
AuthorDate: Fri Jan 19 04:43:56 2024 -0500
add unit test for send_sigterm() (#36852)
---
tests/hooks/test_subprocess.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/hooks/test_subprocess.py b/tests/hooks/test_subprocess.py
index c3ee8054d7..0f625be816 100644
--- a/tests/hooks/test_subprocess.py
+++ b/tests/hooks/test_subprocess.py
@@ -17,6 +17,7 @@
# under the License.
from __future__ import annotations
+import signal
from pathlib import Path
from subprocess import PIPE, STDOUT
from tempfile import TemporaryDirectory
@@ -105,3 +106,11 @@ class TestSubprocessHook:
command = ["bash", "-c", 'printf "This will cause a coding error
\\xb1\\xa6\\x01\n"']
result = hook.run_command(command=command)
assert result.exit_code == 0
+
+ @mock.patch("os.getpgid", return_value=123)
+ @mock.patch("os.killpg")
+ def test_send_sigterm(self, mock_killpg, mock_getpgid):
+ hook = SubprocessHook()
+ hook.sub_process = MagicMock()
+ hook.send_sigterm()
+ mock_killpg.assert_called_with(123, signal.SIGTERM)