From 89922efbac0d26c145992be8eb8f4c5fe5f5bd01 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 26 Jan 2014 16:27:27 -0700 Subject: [PATCH 1/3] Support requests >=2.1.0 Starting with requests 2.1.0 non-HTTP scheme URLs are not parsed anymore. The net effect of this is that when using the unix socket in docker-py no query string params are passed in the URL. This change makes docker-py internally use the scheme http+unix to indicate to requests that this is still a HTTP URL and should be parsed. Users of docker-py can still specify 'unix:' as the base_url. The following forms of base_url are accepted. http+unix://var/run/docker.sock unix://var/run/docker.sock unix:///var/run/docker.sock http://hostname tcp://hostname --- docker/client.py | 8 +- docker/unixconn/unixconn.py | 2 +- tests/fake_api.py | 2 +- tests/test.py | 145 +++++++++++++++++++++--------------- 4 files changed, 93 insertions(+), 64 deletions(-) diff --git a/docker/client.py b/docker/client.py index 3fc2b084..a22ac53e 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/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 d92ffddc..ba5e0482 100644 --- a/tests/test.py +++ b/tests/test.py @@ -75,7 +75,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', + 'http+unix://var/run/docker.sock/v1.6/version', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -86,7 +86,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', + 'http+unix://var/run/docker.sock/v1.6/info', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -97,7 +97,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', + 'http+unix://var/run/docker.sock/v1.6/images/search', params={'term': 'busybox'}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -112,7 +112,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', + 'http+unix://var/run/docker.sock/v1.6/images/json', params={'filter': None, 'only_ids': 0, 'all': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -123,7 +123,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', + 'http+unix://var/run/docker.sock/v1.6/images/json', params={'filter': None, 'only_ids': 1, 'all': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -135,7 +135,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', + 'http+unix://var/run/docker.sock/v1.6/images/json', params={'filter': None, 'only_ids': 1, 'all': 0}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -147,7 +147,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', + 'http+unix://var/run/docker.sock/v1.6/containers/json', params={ 'all': 1, 'since': None, @@ -170,7 +170,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + 'http+unix://var/run/docker.sock/v1.6/containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", "Cmd": ["true"], @@ -192,7 +192,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + 'http+unix://var/run/docker.sock/v1.6/containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -213,7 +213,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + 'http+unix://var/run/docker.sock/v1.6/containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -238,7 +238,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + 'http+unix://var/run/docker.sock/v1.6/containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -260,7 +260,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + 'http+unix://var/run/docker.sock/v1.6/containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -282,7 +282,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + 'http+unix://var/run/docker.sock/v1.6/containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", @@ -304,7 +304,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'unix://var/run/docker.sock/v1.6/containers/create') + 'http+unix://var/run/docker.sock/v1.6/containers/create') self.assertEqual(json.loads(args[1]['data']), json.loads(''' {"Tty": false, "Image": "busybox", "Cmd": ["true"], @@ -319,11 +319,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' + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -349,7 +350,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' + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -375,7 +376,7 @@ 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/' + self.assertEqual(args[0][0], 'http+unix://var/run/docker.sock/v1.6/' 'containers/3cc2351ab11b/start') self.assertEqual( json.loads(args[1]['data']), @@ -402,7 +403,7 @@ 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/' + self.assertEqual(args[0][0], 'http+unix://var/run/docker.sock/v1.6/' 'containers/3cc2351ab11b/start') self.assertEqual(json.loads(args[1]['data']), {"Binds": ["/tmp:/mnt"], @@ -430,7 +431,7 @@ 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/' + self.assertEqual(args[0][0], 'http+unix://var/run/docker.sock/v1.6/' 'containers/3cc2351ab11b/start') data = json.loads(args[1]['data']) self.assertEqual(data['PublishAllPorts'], False) @@ -481,7 +482,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' + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -510,7 +511,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' + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -534,7 +535,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' + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' ) self.assertEqual(json.loads(args[1]['data']), {"PublishAllPorts": False, "Privileged": True}) @@ -553,7 +554,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' + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -575,7 +576,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/wait', timeout=None ) @@ -583,13 +584,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', + 'http+unix://var/run/docker.sock/v1.6/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) @@ -597,7 +624,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/attach', params={'stream': 0, 'logs': 1, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=False @@ -610,7 +637,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/attach', params={'stream': 0, 'logs': 1, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=False @@ -623,7 +650,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/attach', params={'stream': 1, 'logs': 1, 'stderr': 1, 'stdout': 1}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS, stream=True @@ -636,7 +663,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/changes', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -647,7 +674,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/changes', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -658,7 +685,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -669,7 +696,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/stop', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -681,7 +708,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/stop', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -693,7 +720,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', params={}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -705,7 +732,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', params={}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -717,7 +744,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', params={'signal': signal.SIGTERM}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -729,7 +756,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/restart', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -741,7 +768,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/restart', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -753,7 +780,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', params={'v': False, 'link': False}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -765,7 +792,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', params={'v': False, 'link': False}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -777,7 +804,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', params={'v': False, 'link': True}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -789,7 +816,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/export', stream=True, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -801,7 +828,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/export', stream=True, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -813,7 +840,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', + 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -830,7 +857,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/images/create' + 'http+unix://var/run/docker.sock/v1.6/images/create' ) self.assertEqual( args[1]['params'], @@ -847,7 +874,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'unix://var/run/docker.sock/v1.6/images/create' + 'http+unix://var/run/docker.sock/v1.6/images/create' ) self.assertEqual( args[1]['params'], @@ -862,7 +889,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', + 'http+unix://var/run/docker.sock/v1.6/commit', data='{}', headers={'Content-Type': 'application/json'}, params={ @@ -882,7 +909,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', + 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -893,7 +920,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', + 'http+unix://var/run/docker.sock/v1.6/images/test_image/history', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -908,7 +935,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', + 'http+unix://var/run/docker.sock/v1.6/images/create', params={ 'repo': fake_api.FAKE_REPO_NAME, 'tag': fake_api.FAKE_TAG_NAME, @@ -931,7 +958,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', + 'http+unix://var/run/docker.sock/v1.6/images/create', params={ 'repo': fake_api.FAKE_REPO_NAME, 'tag': fake_api.FAKE_TAG_NAME, @@ -954,7 +981,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', + 'http+unix://var/run/docker.sock/v1.6/images/create', params={ 'repo': fake_api.FAKE_REPO_NAME, 'tag': fake_api.FAKE_TAG_NAME, @@ -971,7 +998,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', + 'http+unix://var/run/docker.sock/v1.6/images/test_image/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -983,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/test_image/insert', + 'http+unix://var/run/docker.sock/v1.6/images/test_image/insert', params={ 'url': fake_api.FAKE_URL, 'path': fake_api.FAKE_PATH @@ -998,7 +1025,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', + 'http+unix://var/run/docker.sock/v1.6/images/test_image/push', data='{}', headers={'Content-Type': 'application/json'}, stream=False, @@ -1012,7 +1039,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', + 'http+unix://var/run/docker.sock/v1.6/images/test_image/push', data='{}', headers={'Content-Type': 'application/json'}, stream=True, @@ -1026,7 +1053,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', + 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', params={ 'tag': None, 'repo': 'repo', @@ -1046,7 +1073,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', + 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', params={ 'tag': 'tag', 'repo': 'repo', @@ -1063,7 +1090,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', + 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', params={ 'tag': None, 'repo': 'repo', From cf946ff27b3769868b1ae686b4417e4fc6631ade Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 26 Jan 2014 16:52:14 -0700 Subject: [PATCH 2/3] flake8 fixes Additionally this change should make moving to /v1.8 slightly less painful --- tests/test.py | 125 +++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/tests/test.py b/tests/test.py index ba5e0482..f2fa9259 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( - 'http+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( - 'http+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( - 'http+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( - 'http+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( - 'http+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( - 'http+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( - 'http+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], - 'http+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"], @@ -192,7 +193,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'http+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", @@ -213,7 +214,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'http+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", @@ -238,7 +239,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'http+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", @@ -260,7 +261,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'http+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", @@ -282,7 +283,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'http+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", @@ -304,7 +305,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual(args[0][0], - 'http+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"], @@ -324,7 +325,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -350,7 +351,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -376,8 +377,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], 'http+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']), { @@ -403,8 +404,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], 'http+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, @@ -431,8 +432,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], 'http+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']) @@ -482,7 +483,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -511,7 +512,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -535,7 +536,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+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}) @@ -554,7 +555,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/start' + url_prefix + 'containers/3cc2351ab11b/start' ) self.assertEqual( json.loads(args[1]['data']), @@ -576,7 +577,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/wait', + url_prefix + 'containers/3cc2351ab11b/wait', timeout=None ) @@ -588,7 +589,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/wait', + url_prefix + 'containers/3cc2351ab11b/wait', timeout=None ) @@ -624,7 +625,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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 @@ -637,7 +638,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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 @@ -650,7 +651,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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 @@ -663,7 +664,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/changes', + url_prefix + 'containers/3cc2351ab11b/changes', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -674,7 +675,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/changes', + url_prefix + 'containers/3cc2351ab11b/changes', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -685,7 +686,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/json', + url_prefix + 'containers/3cc2351ab11b/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -696,7 +697,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/stop', + url_prefix + 'containers/3cc2351ab11b/stop', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -708,7 +709,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/stop', + url_prefix + 'containers/3cc2351ab11b/stop', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -720,7 +721,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', + url_prefix + 'containers/3cc2351ab11b/kill', params={}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -732,7 +733,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/kill', + url_prefix + 'containers/3cc2351ab11b/kill', params={}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -744,7 +745,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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 ) @@ -756,7 +757,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception : {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/restart', + url_prefix + 'containers/3cc2351ab11b/restart', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -768,7 +769,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/restart', + url_prefix + 'containers/3cc2351ab11b/restart', params={'t': 2}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -780,7 +781,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', + url_prefix + 'containers/3cc2351ab11b', params={'v': False, 'link': False}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -792,7 +793,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', + url_prefix + 'containers/3cc2351ab11b', params={'v': False, 'link': False}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -804,7 +805,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b', + url_prefix + 'containers/3cc2351ab11b', params={'v': False, 'link': True}, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -816,7 +817,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/export', + url_prefix + 'containers/3cc2351ab11b/export', stream=True, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -828,7 +829,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/export', + url_prefix + 'containers/3cc2351ab11b/export', stream=True, timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -840,7 +841,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/containers/3cc2351ab11b/json', + url_prefix + 'containers/3cc2351ab11b/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -857,7 +858,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+unix://var/run/docker.sock/v1.6/images/create' + url_prefix + 'images/create' ) self.assertEqual( args[1]['params'], @@ -874,7 +875,7 @@ class DockerClientTest(unittest.TestCase): args = fake_request.call_args self.assertEqual( args[0][0], - 'http+unix://var/run/docker.sock/v1.6/images/create' + url_prefix + 'images/create' ) self.assertEqual( args[1]['params'], @@ -889,7 +890,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/commit', + url_prefix + 'commit', data='{}', headers={'Content-Type': 'application/json'}, params={ @@ -909,7 +910,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128', + url_prefix + 'images/e9aa60c60128', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -920,7 +921,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/images/test_image/history', + url_prefix + 'images/test_image/history', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -935,7 +936,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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, @@ -958,7 +959,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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, @@ -981,7 +982,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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, @@ -998,7 +999,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/images/test_image/json', + url_prefix + 'images/test_image/json', timeout=docker.client.DEFAULT_TIMEOUT_SECONDS ) @@ -1010,7 +1011,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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 @@ -1025,7 +1026,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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, @@ -1039,7 +1040,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+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, @@ -1053,7 +1054,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', + url_prefix + 'images/e9aa60c60128/tag', params={ 'tag': None, 'repo': 'repo', @@ -1073,7 +1074,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', + url_prefix + 'images/e9aa60c60128/tag', params={ 'tag': 'tag', 'repo': 'repo', @@ -1090,7 +1091,7 @@ class DockerClientTest(unittest.TestCase): self.fail('Command should not raise exception: {0}'.format(e)) fake_request.assert_called_with( - 'http+unix://var/run/docker.sock/v1.6/images/e9aa60c60128/tag', + url_prefix + 'images/e9aa60c60128/tag', params={ 'tag': None, 'repo': 'repo', From 31f48d718dc415d9ebe04ad921286b57cc0a8093 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Mon, 27 Jan 2014 09:09:16 -0700 Subject: [PATCH 3/3] Update to requests==2.2.1 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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