|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 |
|
17 | 17 | from typing import Optional |
18 | | -from unittest.mock import Mock, patch |
| 18 | +from unittest.mock import Mock |
19 | 19 |
|
20 | 20 | import pytest |
21 | 21 |
|
22 | 22 | from cylc.flow.broadcast_mgr import BroadcastMgr |
23 | | -from cylc.flow.subprocctx import SubProcContext |
24 | 23 | from cylc.flow.task_events_mgr import TaskEventsManager |
25 | 24 | from cylc.flow.task_proxy import TaskProxy |
26 | 25 | from cylc.flow.taskdef import TaskDef |
27 | 26 |
|
28 | 27 |
|
29 | | -@patch("cylc.flow.task_events_mgr.LOG") |
30 | | -def test_log_error_on_error_exit_code(cylc_log): |
31 | | - """Test that an error log is emitted when the log retrieval command |
32 | | - exited with a code different than zero. |
33 | | -
|
34 | | - :param cylc_log: mocked cylc logger |
35 | | - :type cylc_log: mock.MagicMock |
36 | | - """ |
37 | | - task_events_manager = TaskEventsManager( |
38 | | - None, None, None, None, None, None, None, None, None) |
39 | | - proc_ctx = SubProcContext( |
40 | | - cmd_key=None, cmd="error", ret_code=1, err="Error!", id_keys=[]) |
41 | | - task_events_manager._job_logs_retrieval_callback(proc_ctx, None) |
42 | | - assert cylc_log.error.call_count == 1 |
43 | | - assert cylc_log.error.call_args.contains("Error!") |
44 | | - |
45 | | - |
46 | | -@patch("cylc.flow.task_events_mgr.LOG") |
47 | | -def test_log_debug_on_noerror_exit_code(cylc_log): |
48 | | - """Test that a debug log is emitted when the log retrieval command |
49 | | - exited with an non-error code (i.e. 0). |
50 | | -
|
51 | | - :param cylc_log: mocked cylc logger |
52 | | - :type cylc_log: mock.MagicMock |
53 | | - """ |
54 | | - task_events_manager = TaskEventsManager( |
55 | | - None, None, None, None, None, None, None, None, None) |
56 | | - proc_ctx = SubProcContext( |
57 | | - cmd_key=None, cmd="ls /tmp/123", ret_code=0, err="", id_keys=[]) |
58 | | - task_events_manager._job_logs_retrieval_callback(proc_ctx, None) |
59 | | - assert cylc_log.debug.call_count == 1 |
60 | | - assert cylc_log.debug.call_args.contains("ls /tmp/123") |
61 | | - |
62 | | - |
63 | 28 | @pytest.mark.parametrize( |
64 | 29 | "broadcast, remote, platforms, expected", |
65 | 30 | [ |
|
0 commit comments