summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-01-08 18:11:29 -0800
committerJoffrey F <joffrey@docker.com>2018-01-23 16:59:09 -0800
commitf95b958429b38dab50929e013db3c636a12e1536 (patch)
treeb8de1cfd18d1c3c932592388143665f446e871f6 /tests
parentbf5e7702df3c835a5db4fc6b86500b4f4b659c14 (diff)
downloaddocker-py-1855-platform-option.tar.gz
Add support for experimental platform flag in build and pull1855-platform-option
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/api_build_test.py15
-rw-r--r--tests/integration/api_image_test.py11
-rw-r--r--tests/unit/models_containers_test.py2
3 files changed, 26 insertions, 2 deletions
diff --git a/tests/integration/api_build_test.py b/tests/integration/api_build_test.py
index 7cc3234..245214e 100644
--- a/tests/integration/api_build_test.py
+++ b/tests/integration/api_build_test.py
@@ -377,3 +377,18 @@ class BuildTest(BaseAPIIntegrationTest):
def test_build_gzip_custom_encoding(self):
with self.assertRaises(errors.DockerException):
self.client.build(path='.', gzip=True, encoding='text/html')
+
+ @requires_api_version('1.32')
+ @requires_experimental(until=None)
+ def test_build_invalid_platform(self):
+ script = io.BytesIO('FROM busybox\n'.encode('ascii'))
+
+ with pytest.raises(errors.APIError) as excinfo:
+ stream = self.client.build(
+ fileobj=script, stream=True, platform='foobar'
+ )
+ for _ in stream:
+ pass
+
+ assert excinfo.value.status_code == 400
+ assert 'invalid platform' in excinfo.exconly()
diff --git a/tests/integration/api_image_test.py b/tests/integration/api_image_test.py
index 14fb77a..178c34e 100644
--- a/tests/integration/api_image_test.py
+++ b/tests/integration/api_image_test.py
@@ -14,7 +14,7 @@ from six.moves import socketserver
import docker
-from ..helpers import requires_api_version
+from ..helpers import requires_api_version, requires_experimental
from .base import BaseAPIIntegrationTest, BUSYBOX
@@ -67,6 +67,15 @@ class PullImageTest(BaseAPIIntegrationTest):
img_info = self.client.inspect_image('hello-world')
self.assertIn('Id', img_info)
+ @requires_api_version('1.32')
+ @requires_experimental(until=None)
+ def test_pull_invalid_platform(self):
+ with pytest.raises(docker.errors.APIError) as excinfo:
+ self.client.pull('hello-world', platform='foobar')
+
+ assert excinfo.value.status_code == 500
+ assert 'invalid platform' in excinfo.exconly()
+
class CommitTest(BaseAPIIntegrationTest):
def test_commit(self):
diff --git a/tests/unit/models_containers_test.py b/tests/unit/models_containers_test.py
index a479e83..95295a9 100644
--- a/tests/unit/models_containers_test.py
+++ b/tests/unit/models_containers_test.py
@@ -225,7 +225,7 @@ class ContainerCollectionTest(unittest.TestCase):
container = client.containers.run('alpine', 'sleep 300', detach=True)
assert container.id == FAKE_CONTAINER_ID
- client.api.pull.assert_called_with('alpine', tag=None)
+ client.api.pull.assert_called_with('alpine', platform=None, tag=None)
def test_run_with_error(self):
client = make_fake_client()