From 65bebc085ab8bb36e5d6de44399b8480e7ae3e68 Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 9 Jan 2019 10:52:50 -0800 Subject: Style fixes and removed some unused code Signed-off-by: Joffrey F --- tests/integration/api_build_test.py | 11 ++++++++--- tests/integration/api_exec_test.py | 27 ++++++++++++++++----------- 2 files changed, 24 insertions(+), 14 deletions(-) (limited to 'tests') diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py index 3c4e982..8bfc796 100644 --- a/tests/integration/api_build_test.py +++ b/tests/integration/api_build_test.py @@ -16,7 +16,8 @@ from ..helpers import random_name, requires_api_version, requires_experimental class BuildTest(BaseAPIIntegrationTest): def test_build_with_proxy(self): self.client._proxy_configs = ProxyConfig( - ftp='a', http='b', https='c', no_proxy='d') + ftp='a', http='b', https='c', no_proxy='d' + ) script = io.BytesIO('\n'.join([ 'FROM busybox', @@ -29,11 +30,13 @@ class BuildTest(BaseAPIIntegrationTest): 'RUN env | grep "NO_PROXY=d"', 'RUN env | grep "no_proxy=d"', ]).encode('ascii')) + self.client.build(fileobj=script, decode=True) def test_build_with_proxy_and_buildargs(self): self.client._proxy_configs = ProxyConfig( - ftp='a', http='b', https='c', no_proxy='d') + ftp='a', http='b', https='c', no_proxy='d' + ) script = io.BytesIO('\n'.join([ 'FROM busybox', @@ -46,10 +49,12 @@ class BuildTest(BaseAPIIntegrationTest): 'RUN env | grep "NO_PROXY=d"', 'RUN env | grep "no_proxy=d"', ]).encode('ascii')) + self.client.build( fileobj=script, decode=True, - buildargs={'FTP_PROXY': 'XXX', 'ftp_proxy': 'xxx'}) + buildargs={'FTP_PROXY': 'XXX', 'ftp_proxy': 'xxx'} + ) def test_build_streaming(self): script = io.BytesIO('\n'.join([ diff --git a/tests/integration/api_exec_test.py b/tests/integration/api_exec_test.py index 8947b41..e6079eb 100644 --- a/tests/integration/api_exec_test.py +++ b/tests/integration/api_exec_test.py @@ -9,37 +9,42 @@ from ..helpers import ( class ExecTest(BaseAPIIntegrationTest): - def test_execute_proxy_env(self): + def test_execute_command_with_proxy_env(self): # Set a custom proxy config on the client self.client._proxy_configs = ProxyConfig( - ftp='a', https='b', http='c', no_proxy='d') + ftp='a', https='b', http='c', no_proxy='d' + ) container = self.client.create_container( - BUSYBOX, 'cat', detach=True, stdin_open=True) - id = container['Id'] - self.client.start(id) - self.tmp_containers.append(id) + BUSYBOX, 'cat', detach=True, stdin_open=True, + use_config_proxy=True, + ) + self.client.start(container) + self.tmp_containers.append(container) cmd = 'sh -c "env | grep -i proxy"' # First, just make sure the environment variables from the custom # config are set - res = self.client.exec_create(id, cmd=cmd, use_config_proxy=True) + + res = self.client.exec_create(container, cmd=cmd) output = self.client.exec_start(res).decode('utf-8').split('\n') expected = [ 'ftp_proxy=a', 'https_proxy=b', 'http_proxy=c', 'no_proxy=d', - 'FTP_PROXY=a', 'HTTPS_PROXY=b', 'HTTP_PROXY=c', 'NO_PROXY=d'] + 'FTP_PROXY=a', 'HTTPS_PROXY=b', 'HTTP_PROXY=c', 'NO_PROXY=d' + ] for item in expected: assert item in output # Overwrite some variables with a custom environment env = {'https_proxy': 'xxx', 'HTTPS_PROXY': 'XXX'} - res = self.client.exec_create( - id, cmd=cmd, environment=env, use_config_proxy=True) + + res = self.client.exec_create(container, cmd=cmd, environment=env) output = self.client.exec_start(res).decode('utf-8').split('\n') expected = [ 'ftp_proxy=a', 'https_proxy=xxx', 'http_proxy=c', 'no_proxy=d', - 'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d'] + 'FTP_PROXY=a', 'HTTPS_PROXY=XXX', 'HTTP_PROXY=c', 'NO_PROXY=d' + ] for item in expected: assert item in output -- cgit v1.2.1