|
1 |
| -from __future__ import absolute_import |
2 |
| - |
3 |
| -import unittest |
4 |
| - |
5 |
| -from mock import mock |
6 |
| - |
7 |
| -from cwltool.command_line_tool import DEFAULT_CONTAINER_MSG, CommandLineTool |
8 |
| -from cwltool.context import RuntimeContext |
| 1 | +from cwltool import command_line_tool |
9 | 2 | from cwltool.utils import windows_default_container_id
|
| 3 | +from cwltool.context import RuntimeContext |
10 | 4 |
|
11 | 5 |
|
12 |
| -class TestDefaultDockerWarning(unittest.TestCase): |
| 6 | +# Test to check warning when default docker Container is used on Windows |
| 7 | +def test_default_docker_warning(mocker): |
| 8 | + mocker.patch("cwltool.command_line_tool.onWindows", return_value=True) |
| 9 | + mocker.patch("cwltool.command_line_tool._logger") |
13 | 10 |
|
14 |
| - # Test to check warning when default docker Container is used on Windows |
15 |
| - @mock.patch("cwltool.command_line_tool.onWindows",return_value = True) |
16 |
| - @mock.patch("cwltool.command_line_tool._logger") |
17 |
| - def test_default_docker_warning(self,mock_logger,mock_windows): |
| 11 | + class TestCommandLineTool(command_line_tool.CommandLineTool): |
| 12 | + def __init__(self, **kwargs): |
| 13 | + self.requirements = [] |
| 14 | + self.hints = [] |
18 | 15 |
|
19 |
| - class TestCommandLineTool(CommandLineTool): |
20 |
| - def __init__(self, **kwargs): |
21 |
| - self.requirements=[] |
22 |
| - self.hints=[] |
| 16 | + def find_default_container(self, args, builder): |
| 17 | + return windows_default_container_id |
23 | 18 |
|
24 |
| - def find_default_container(self, args, builder): |
25 |
| - return windows_default_container_id |
| 19 | + tool = TestCommandLineTool() |
| 20 | + tool.make_job_runner(RuntimeContext({ |
| 21 | + "find_default_container": lambda x: "frolvlad/alpine-bash"})) |
26 | 22 |
|
27 |
| - TestObject = TestCommandLineTool() |
28 |
| - TestObject.make_job_runner(RuntimeContext({ |
29 |
| - "find_default_container": lambda x: "frolvlad/alpine-bash"})) |
30 |
| - mock_logger.warning.assert_called_with(DEFAULT_CONTAINER_MSG, windows_default_container_id, windows_default_container_id) |
| 23 | + command_line_tool._logger.warning.assert_called_with( |
| 24 | + command_line_tool.DEFAULT_CONTAINER_MSG, |
| 25 | + windows_default_container_id, |
| 26 | + windows_default_container_id) |
0 commit comments