From ec05d5d2c0dcb4b864fcc186ea4081ebfc6e8f5c Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Wed, 23 Mar 2016 11:20:07 -0700 Subject: [PATCH] gzip build test Signed-off-by: Joffrey F --- tests/integration/build_test.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/integration/build_test.py b/tests/integration/build_test.py index 26164ae0..cc8a8626 100644 --- a/tests/integration/build_test.py +++ b/tests/integration/build_test.py @@ -6,6 +6,8 @@ import tempfile import six +from docker import errors + from .. import helpers from ..base import requires_api_version @@ -138,3 +140,29 @@ class BuildTest(helpers.BaseTestCase): control_chars[0], control_chars[1], snippet ) self.assertTrue(any([line == expected for line in lines])) + + def test_build_gzip_encoding(self): + base_dir = tempfile.mkdtemp() + self.addCleanup(shutil.rmtree, base_dir) + + with open(os.path.join(base_dir, 'Dockerfile'), 'w') as f: + f.write("\n".join([ + 'FROM busybox', + 'MAINTAINER docker-py', + 'ADD . /test', + ])) + + stream = self.client.build( + path=base_dir, stream=True, decode=True, nocache=True, + gzip=True + ) + + lines = [] + for chunk in stream: + lines.append(chunk) + + assert 'Successfully built' in lines[-1]['stream'] + + def test_build_gzip_custom_encoding(self): + with self.assertRaises(errors.DockerException): + self.client.build(path='.', gzip=True, encoding='text/html')