From fbaea58fc1a204d676ad098f6b51ba5de1aeccf1 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 5 Oct 2015 15:50:16 -0400 Subject: [PATCH] Fix #2133 - fix call to get_client() Signed-off-by: Daniel Nephin --- compose/cli/command.py | 4 ++-- tests/unit/cli/command_test.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/unit/cli/command_test.py diff --git a/compose/cli/command.py b/compose/cli/command.py index 5c233df72..1a9bc3dcb 100644 --- a/compose/cli/command.py +++ b/compose/cli/command.py @@ -38,10 +38,10 @@ def friendly_error_message(): raise errors.DockerNotFoundUbuntu() else: raise errors.DockerNotFoundGeneric() - elif call_silently(['which', 'boot2docker']) == 0: + elif call_silently(['which', 'docker-machine']) == 0: raise errors.ConnectionErrorDockerMachine() else: - raise errors.ConnectionErrorGeneric(self.get_client().base_url) + raise errors.ConnectionErrorGeneric(get_client().base_url) def project_from_options(base_dir, options): diff --git a/tests/unit/cli/command_test.py b/tests/unit/cli/command_test.py new file mode 100644 index 000000000..0d4324e35 --- /dev/null +++ b/tests/unit/cli/command_test.py @@ -0,0 +1,22 @@ +from __future__ import absolute_import + +import pytest +from requests.exceptions import ConnectionError + +from compose.cli import errors +from compose.cli.command import friendly_error_message +from tests import mock +from tests import unittest + + +class FriendlyErrorMessageTestCase(unittest.TestCase): + + def test_dispatch_generic_connection_error(self): + with pytest.raises(errors.ConnectionErrorGeneric): + with mock.patch( + 'compose.cli.command.call_silently', + autospec=True, + side_effect=[0, 1] + ): + with friendly_error_message(): + raise ConnectionError()