diff --git a/docker/client.py b/docker/client.py index bc04c40d..7347e31b 100644 --- a/docker/client.py +++ b/docker/client.py @@ -69,9 +69,11 @@ class Client(requests.Session): timeout=DEFAULT_TIMEOUT_SECONDS): super(Client, self).__init__() if base_url is None: - base_url = "unix://var/run/docker.sock" - if base_url.startswith('unix:///'): + base_url = "http+unix://var/run/docker.sock" + if 'unix:///' in base_url: base_url = base_url.replace('unix:/', 'unix:') + if base_url.startswith('unix:'): + base_url = "http+" + base_url if base_url.startswith('tcp:'): base_url = base_url.replace('tcp:', 'http:') if base_url.endswith('/'): @@ -81,7 +83,7 @@ class Client(requests.Session): self._timeout = timeout self._auth_configs = auth.load_config() - self.mount('unix://', unixconn.UnixAdapter(base_url, timeout)) + self.mount('http+unix://', unixconn.UnixAdapter(base_url, timeout)) def _set_request_timeout(self, kwargs): """Prepare the kwargs for an HTTP request by inserting the timeout diff --git a/docker/unixconn/unixconn.py b/docker/unixconn/unixconn.py index c9565a25..28068f3c 100644 --- a/docker/unixconn/unixconn.py +++ b/docker/unixconn/unixconn.py @@ -36,7 +36,7 @@ class UnixHTTPConnection(httplib.HTTPConnection, object): def connect(self): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.settimeout(self.timeout) - sock.connect(self.base_url.replace("unix:/", "")) + sock.connect(self.base_url.replace("http+unix:/", "")) self.sock = sock def _extract_path(self, url): diff --git a/requirements.txt b/requirements.txt index fdc5cc08..b443a749 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ mock==1.0.1 -requests==1.2.3 +requests==2.2.1 six>=1.3.0 websocket-client==0.11.0 diff --git a/tests/fake_api.py b/tests/fake_api.py index 47f44188..f206ef08 100644 --- a/tests/fake_api.py +++ b/tests/fake_api.py @@ -276,7 +276,7 @@ def post_fake_tag_image(): ## maps real api url to fake response callback -prefix = 'unix://var/run/docker.sock' +prefix = 'http+unix://var/run/docker.sock' fake_responses = { '{1}/{0}/version'.format(CURRENT_VERSION, prefix): get_fake_version, diff --git a/tests/test.py b/tests/test.py index 7b62b935..7a76384a 100644 --- a/tests/test.py +++ b/tests/test.py @@ -55,6 +55,7 @@ def fake_resp(url, data=None, **kwargs): return response(status_code=status_code, content=content) fake_request = mock.Mock(side_effect=fake_resp) +url_prefix = 'http+unix://var/run/docker.sock/v1.6/' @mock.patch.multiple('docker.Client', get=fake_request, post=fake_request, @@ -75,7 +76,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/version', + url_prefix + 'version', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -86,7 +87,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/info', + url_prefix + 'info', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -97,7 +98,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/search', + url_prefix + 'images/search', params={'term': 'busybox'}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -112,7 +113,7 @@ class DockerClientTest(unittest.TestCase): except Exception as e: self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/json', + url_prefix + 'images/json', params={'filter': None, 'only_ids': 0, 'all': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -123,7 +124,7 @@ class DockerClientTest(unittest.TestCase): except Exception as e: self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/json', + url_prefix + 'images/json', params={'filter': None, 'only_ids': 1, 'all': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -135,7 +136,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/json', + url_prefix + 'images/json', params={'filter': None, 'only_ids': 1, 'all': 0}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -147,7 +148,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/json', + url_prefix + 'containers/json', params={ 'all': 1, 'since': None, @@ -170,7 +171,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + url_prefix + 'containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", "Cmd": ["true"], @@ -193,7 +194,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + url_prefix + 'containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -215,7 +216,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + url_prefix + 'containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -241,7 +242,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + url_prefix + 'containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -264,7 +265,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + url_prefix + 'containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -287,7 +288,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + url_prefix + 'containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -329,7 +330,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + url_prefix + 'containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", "Cmd": ["true"], @@ -345,11 +346,12 @@ class DockerClientTest(unittest.TestCase): try: self.client.start(fake_api.FAKE_CONTAINER_ID) except Exception as e: + raise e self.fail('Command should not raise exception: {0}'.format(e)) args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -375,7 +377,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -401,8 +403,8 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) args = fake_request.call_args - self.assertEqual(args[0][0], 'unix://var/run/docker.sock/v1.6/' - 'containers/3cc2351ab11b/start') + self.assertEqual(args[0][0], url_prefix + + 'containers/3cc2351ab11b/start') self.assertEqual( json.loads(args[1]['data']), { @@ -428,8 +430,8 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) args = fake_request.call_args - self.assertEqual(args[0][0], 'unix://var/run/docker.sock/v1.6/' - 'containers/3cc2351ab11b/start') + self.assertEqual(args[0][0], url_prefix + + 'containers/3cc2351ab11b/start') self.assertEqual(json.loads(args[1]['data']), {"Binds": ["/tmp:/mnt"], "PublishAllPorts": False, @@ -456,8 +458,8 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) args = fake_request.call_args - self.assertEqual(args[0][0], 'unix://var/run/docker.sock/v1.6/' - 'containers/3cc2351ab11b/start') + self.assertEqual(args[0][0], url_prefix + + 'containers/3cc2351ab11b/start') data = json.loads(args[1]['data']) self.assertEqual(data['PublishAllPorts'], False) self.assertTrue('1111/tcp' in data['PortBindings']) @@ -507,7 +509,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -536,7 +538,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -585,7 +587,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual(json.loads(args[1]['data']), {"PublishAllPorts": False, "Privileged": True}) @@ -604,7 +606,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -626,7 +628,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/wait', + url_prefix + 'containers/3cc2351ab11b/wait', timeout=None ) @@ -634,13 +636,39 @@ class DockerClientTest(unittest.TestCase): try: self.client.wait({'Id': fake_api.FAKE_CONTAINER_ID}) except Exception as e: + raise e self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/wait', + url_prefix + 'containers/3cc2351ab11b/wait', timeout=None ) + def test_url_compatibility_unix(self): + c = docker.Client(base_url="unix://socket") + + assert c.base_url == "http+unix://socket" + + def test_url_compatibility_unix_triple_slash(self): + c = docker.Client(base_url="unix:///socket") + + assert c.base_url == "http+unix://socket" + + def test_url_compatibility_http_unix_triple_slash(self): + c = docker.Client(base_url="http+unix:///socket") + + assert c.base_url == "http+unix://socket" + + def test_url_compatibility_http(self): + c = docker.Client(base_url="http://hostname") + + assert c.base_url == "http://hostname" + + def test_url_compatibility_tcp(self): + c = docker.Client(base_url="tcp://hostname") + + assert c.base_url == "http://hostname" + def test_logs(self): try: self.client.logs(fake_api.FAKE_CONTAINER_ID) @@ -648,7 +676,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/attach', + url_prefix + 'containers/3cc2351ab11b/attach', params={'stream': 0, 'logs': 1, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=False @@ -661,7 +689,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/attach', + url_prefix + 'containers/3cc2351ab11b/attach', params={'stream': 0, 'logs': 1, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=False @@ -674,7 +702,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/attach', + url_prefix + 'containers/3cc2351ab11b/attach', params={'stream': 1, 'logs': 1, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=True @@ -687,7 +715,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/changes', + url_prefix + 'containers/3cc2351ab11b/changes', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -698,7 +726,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/changes', + url_prefix + 'containers/3cc2351ab11b/changes', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -709,7 +737,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/json', + url_prefix + 'containers/3cc2351ab11b/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -720,7 +748,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/stop', + url_prefix + 'containers/3cc2351ab11b/stop', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -732,7 +760,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/stop', + url_prefix + 'containers/3cc2351ab11b/stop', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -744,7 +772,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', + url_prefix + 'containers/3cc2351ab11b/kill', params={}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -756,7 +784,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', + url_prefix + 'containers/3cc2351ab11b/kill', params={}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -768,7 +796,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', + url_prefix + 'containers/3cc2351ab11b/kill', params={'signal': signal.SIGTERM}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -780,7 +808,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception : {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/restart', + url_prefix + 'containers/3cc2351ab11b/restart', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -792,7 +820,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/restart', + url_prefix + 'containers/3cc2351ab11b/restart', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -804,7 +832,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', + url_prefix + 'containers/3cc2351ab11b', params={'v': False, 'link': False}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -816,7 +844,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', + url_prefix + 'containers/3cc2351ab11b', params={'v': False, 'link': False}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -828,7 +856,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', + url_prefix + 'containers/3cc2351ab11b', params={'v': False, 'link': True}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -840,7 +868,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/export', + url_prefix + 'containers/3cc2351ab11b/export', stream=True, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -852,7 +880,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/export', + url_prefix + 'containers/3cc2351ab11b/export', stream=True, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -864,7 +892,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/json', + url_prefix + 'containers/3cc2351ab11b/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -881,7 +909,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/images/create' + url_prefix + 'images/create' ) self.assertEqual( args[1]['params'], @@ -898,7 +926,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/images/create' + url_prefix + 'images/create' ) self.assertEqual( args[1]['params'], @@ -913,7 +941,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/commit', + url_prefix + 'commit', data='{}', headers={'Content-Type': 'application/json'}, params={ @@ -933,7 +961,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/e9aa60c60128', + url_prefix + 'images/e9aa60c60128', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -944,7 +972,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/test_image/history', + url_prefix + 'images/test_image/history', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -959,7 +987,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/create', + url_prefix + 'images/create', params={ 'repo': fake_api.FAKE_REPO_NAME, 'tag': fake_api.FAKE_TAG_NAME, @@ -982,7 +1010,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/create', + url_prefix + 'images/create', params={ 'repo': fake_api.FAKE_REPO_NAME, 'tag': fake_api.FAKE_TAG_NAME, @@ -1005,7 +1033,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/create', + url_prefix + 'images/create', params={ 'repo': fake_api.FAKE_REPO_NAME, 'tag': fake_api.FAKE_TAG_NAME, @@ -1022,7 +1050,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/test_image/json', + url_prefix + 'images/test_image/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -1034,7 +1062,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/test_image/insert', + url_prefix + 'images/test_image/insert', params={ 'url': fake_api.FAKE_URL, 'path': fake_api.FAKE_PATH @@ -1049,7 +1077,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/test_image/push', + url_prefix + 'images/test_image/push', data='{}', headers={'Content-Type': 'application/json'}, stream=False, @@ -1063,7 +1091,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/test_image/push', + url_prefix + 'images/test_image/push', data='{}', headers={'Content-Type': 'application/json'}, stream=True, @@ -1077,7 +1105,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', + url_prefix + 'images/e9aa60c60128/tag', params={ 'tag': None, 'repo': 'repo', @@ -1097,7 +1125,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', + url_prefix + 'images/e9aa60c60128/tag', params={ 'tag': 'tag', 'repo': 'repo', @@ -1114,7 +1142,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', + url_prefix + 'images/e9aa60c60128/tag', params={ 'tag': None, 'repo': 'repo',