From 388f291b13fca76f4974a1ee89225ff7f3afb85b Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Fri, 26 Jan 2018 15:32:04 -0800 Subject: Update save / export methods to return data generators Signed-off-by: Joffrey F --- tests/integration/models_images_test.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/integration/models_images_test.py') diff --git a/tests/integration/models_images_test.py b/tests/integration/models_images_test.py index 8840e15..2a28e12 100644 --- a/tests/integration/models_images_test.py +++ b/tests/integration/models_images_test.py @@ -1,9 +1,10 @@ import io +import tempfile import docker import pytest -from .base import BaseIntegrationTest, TEST_API_VERSION +from .base import BaseIntegrationTest, BUSYBOX, TEST_API_VERSION class ImageCollectionTest(BaseIntegrationTest): @@ -76,6 +77,20 @@ class ImageCollectionTest(BaseIntegrationTest): with pytest.raises(docker.errors.ImageLoadError): client.images.load('abc') + def test_save_and_load(self): + client = docker.from_env(version=TEST_API_VERSION) + image = client.images.get(BUSYBOX) + with tempfile.TemporaryFile() as f: + stream = image.save() + for chunk in stream: + f.write(chunk) + + f.seek(0) + result = client.images.load(f.read()) + + assert len(result) == 1 + assert result[0].id == image.id + class ImageTest(BaseIntegrationTest): -- cgit v1.2.1