summaryrefslogtreecommitdiff
path: root/tests/unit/models_images_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/models_images_test.py')
-rw-r--r--tests/unit/models_images_test.py47
1 files changed, 42 insertions, 5 deletions
diff --git a/tests/unit/models_images_test.py b/tests/unit/models_images_test.py
index 6783279..f3ca0be 100644
--- a/tests/unit/models_images_test.py
+++ b/tests/unit/models_images_test.py
@@ -1,6 +1,8 @@
+import unittest
+import warnings
+
from docker.constants import DEFAULT_DATA_CHUNK_SIZE
from docker.models.images import Image
-import unittest
from .fake_api import FAKE_IMAGE_ID
from .fake_api_client import make_fake_client
@@ -42,16 +44,36 @@ class ImageCollectionTest(unittest.TestCase):
def test_pull(self):
client = make_fake_client()
- image = client.images.pull('test_image:latest')
- client.api.pull.assert_called_with('test_image', tag='latest')
+ image = client.images.pull('test_image:test')
+ client.api.pull.assert_called_with(
+ 'test_image', tag='test', all_tags=False, stream=True
+ )
+ client.api.inspect_image.assert_called_with('test_image:test')
+ assert isinstance(image, Image)
+ assert image.id == FAKE_IMAGE_ID
+
+ def test_pull_tag_precedence(self):
+ client = make_fake_client()
+ image = client.images.pull('test_image:latest', tag='test')
+ client.api.pull.assert_called_with(
+ 'test_image', tag='test', all_tags=False, stream=True
+ )
+ client.api.inspect_image.assert_called_with('test_image:test')
+
+ image = client.images.pull('test_image')
+ client.api.pull.assert_called_with(
+ 'test_image', tag='latest', all_tags=False, stream=True
+ )
client.api.inspect_image.assert_called_with('test_image:latest')
assert isinstance(image, Image)
assert image.id == FAKE_IMAGE_ID
def test_pull_multiple(self):
client = make_fake_client()
- images = client.images.pull('test_image')
- client.api.pull.assert_called_with('test_image', tag=None)
+ images = client.images.pull('test_image', all_tags=True)
+ client.api.pull.assert_called_with(
+ 'test_image', tag='latest', all_tags=True, stream=True
+ )
client.api.images.assert_called_with(
all=False, name='test_image', filters=None
)
@@ -61,6 +83,16 @@ class ImageCollectionTest(unittest.TestCase):
assert isinstance(image, Image)
assert image.id == FAKE_IMAGE_ID
+ def test_pull_with_stream_param(self):
+ client = make_fake_client()
+ with warnings.catch_warnings(record=True) as w:
+ client.images.pull('test_image', stream=True)
+
+ assert len(w) == 1
+ assert str(w[0].message).startswith(
+ '`stream` is not a valid parameter'
+ )
+
def test_push(self):
client = make_fake_client()
client.images.push('foobar', insecure_registry=True)
@@ -80,6 +112,11 @@ class ImageCollectionTest(unittest.TestCase):
client.images.search('test')
client.api.search.assert_called_with('test')
+ def test_search_limit(self):
+ client = make_fake_client()
+ client.images.search('test', limit=5)
+ client.api.search.assert_called_with('test', limit=5)
+
class ImageTest(unittest.TestCase):
def test_short_id(self):