From d01f712376f5ac6d41284fbf158ecb914fba5232 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 22 Sep 2015 12:24:56 -0400 Subject: [PATCH] Fix a test case that assumes busybox image id. Signed-off-by: Daniel Nephin --- tests/integration/service_test.py | 7 +++++-- tests/integration/testcases.py | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index ec6428200..aec2caf1d 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -10,6 +10,7 @@ import shutil from six import StringIO, text_type from .testcases import DockerClientTestCase +from .testcases import pull_busybox from compose import __version__ from compose.const import ( LABEL_CONTAINER_NUMBER, @@ -577,8 +578,10 @@ class ServiceTest(DockerClientTestCase): }) def test_create_with_image_id(self): - # Image id for the current busybox:latest - service = self.create_service('foo', image='8c2e06607696') + # Get image id for the current busybox:latest + pull_busybox(self.client) + image_id = self.client.inspect_image('busybox:latest')['Id'][:12] + service = self.create_service('foo', image=image_id) service.create_container() def test_scale(self): diff --git a/tests/integration/testcases.py b/tests/integration/testcases.py index 2a7c0a440..41b50a815 100644 --- a/tests/integration/testcases.py +++ b/tests/integration/testcases.py @@ -1,5 +1,8 @@ from __future__ import unicode_literals from __future__ import absolute_import + +from docker import errors + from compose.service import Service from compose.config import ServiceLoader from compose.const import LABEL_PROJECT @@ -8,6 +11,13 @@ from compose.progress_stream import stream_output from .. import unittest +def pull_busybox(client): + try: + client.inspect_image('busybox:latest') + except errors.APIError: + client.pull('busybox:latest', stream=False) + + class DockerClientTestCase(unittest.TestCase): @classmethod def setUpClass(cls):