From 2c186304a8e39162167d112af80dee7d5f962715 Mon Sep 17 00:00:00 2001 From: shin- Date: Fri, 5 Jul 2013 19:04:38 +0200 Subject: [PATCH] Added test for Client.build --- tests/test.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/test.py b/tests/test.py index dce9f766..4995e236 100644 --- a/tests/test.py +++ b/tests/test.py @@ -4,8 +4,8 @@ import time import docker # FIXME: missing tests for -# build; export; history; import_image; insert; port; push; -# remove_image; tag; kill/stop/start/wait/restart (multi) +# export; history; import_image; insert; port; push; +# tag; kill/stop/start/wait/restart (multi) class BaseTestCase(unittest.TestCase): tmp_imgs = [] @@ -272,6 +272,37 @@ class TestRemoveImage(BaseTestCase): res = [x for x in images if x['Id'].startswith(img_id)] self.assertEqual(len(res), 0) +################# +# BUILDER TESTS # +################# + +class TestBuild(BaseTestCase): + def runTest(self): + script = [ + 'MAINTAINER docker-py', + 'FROM busybox', + 'RUN mkdir -p /tmp/test', + 'EXPOSE 8080', + 'ADD https://dl.dropboxusercontent.com/u/20637798/silence.tar.gz /tmp/silence.tar.gz' + ] + img, logs = self.client.build(script) + self.assertNotEqual(img, None) + self.assertNotEqual(img, '') + self.assertNotEqual(logs, '') + container1 = self.client.create_container(img, 'test -d /tmp/test') + id1 = container1['Id'] + self.client.start(id1) + self.tmp_containers.append(id1) + exitcode1 = self.client.wait(id1) + self.assertEqual(exitcode1, 0) + container2 = self.client.create_container(img, 'test -d /tmp/test') + id2 = container2['Id'] + self.client.start(id2) + self.tmp_containers.append(id2) + exitcode2 = self.client.wait(id2) + self.assertEqual(exitcode2, 0) + self.tmp_imgs.append(img) + ####################### ## PY SPECIFIC TESTS ## #######################