|
@@ -7,6 +7,7 @@ from requests.exceptions import ConnectionError
|
|
|
|
|
|
from compose.cli import errors
|
|
|
from compose.cli.errors import handle_connection_errors
|
|
|
+from compose.const import IS_WINDOWS_PLATFORM
|
|
|
from tests import mock
|
|
|
|
|
|
|
|
@@ -65,3 +66,23 @@ class TestHandleConnectionErrors(object):
|
|
|
raise APIError(None, None, msg)
|
|
|
|
|
|
mock_logging.error.assert_called_once_with(msg)
|
|
|
+
|
|
|
+ @pytest.mark.skipif(not IS_WINDOWS_PLATFORM, reason='Needs pywin32')
|
|
|
+ def test_windows_pipe_error_no_data(self, mock_logging):
|
|
|
+ import pywintypes
|
|
|
+ with pytest.raises(errors.ConnectionError):
|
|
|
+ with handle_connection_errors(mock.Mock(api_version='1.22')):
|
|
|
+ raise pywintypes.error(232, 'WriteFile', 'The pipe is being closed.')
|
|
|
+
|
|
|
+ _, args, _ = mock_logging.error.mock_calls[0]
|
|
|
+ assert "The current Compose file version is not compatible with your engine version." in args[0]
|
|
|
+
|
|
|
+ @pytest.mark.skipif(not IS_WINDOWS_PLATFORM, reason='Needs pywin32')
|
|
|
+ def test_windows_pipe_error_misc(self, mock_logging):
|
|
|
+ import pywintypes
|
|
|
+ with pytest.raises(errors.ConnectionError):
|
|
|
+ with handle_connection_errors(mock.Mock(api_version='1.22')):
|
|
|
+ raise pywintypes.error(231, 'WriteFile', 'The pipe is busy.')
|
|
|
+
|
|
|
+ _, args, _ = mock_logging.error.mock_calls[0]
|
|
|
+ assert "Windows named pipe error: The pipe is busy. (code: 231)" == args[0]
|