From 8acff57f6a2e806026dc03fb4a19ed507bed7a78 Mon Sep 17 00:00:00 2001 From: Tom Arnfeld Date: Wed, 23 Apr 2014 13:42:05 +0100 Subject: [PATCH] Added test for gzip compressed tar --- tests/test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test.py b/tests/test.py index bfe0addc..d7ebf068 100644 --- a/tests/test.py +++ b/tests/test.py @@ -20,6 +20,7 @@ import os import signal import tempfile import unittest +import gzip import docker import requests @@ -1245,6 +1246,26 @@ class DockerClientTest(unittest.TestCase): except Exception as e: self.fail('Command should not raise exception: {0}'.format(e)) + def test_build_container_custom_context_gzip(self): + script = io.BytesIO('\n'.join([ + 'FROM busybox', + 'MAINTAINER docker-py', + 'RUN mkdir -p /tmp/test', + 'EXPOSE 8080', + 'ADD https://dl.dropboxusercontent.com/u/20637798/silence.tar.gz' + ' /tmp/silence.tar.gz' + ]).encode('ascii')) + context = docker.utils.mkbuildcontext(script) + gz_context = gzip.GzipFile(fileobj=context) + try: + self.client.build( + fileobj=gz_context, + custom_context=True, + encoding="gzip" + ) + except Exception as e: + self.fail('Command should not raise exception: {0}'.format(e)) + ####################### # PY SPECIFIC TESTS # #######################