diff options
author | Joffrey F <joffrey@docker.com> | 2017-08-15 16:07:47 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2017-08-15 16:44:06 -0700 |
commit | 397bec68ba46e6ef771404c8aa6e7cb16ebd2e70 (patch) | |
tree | cc95fe9ee7b9f9336dadf8307096bd4311cb7a49 | |
parent | e9fab1432b974ceaa888b371e382dfcf2f6556e4 (diff) | |
download | docker-py-1686-check-api-features.tar.gz |
Handle untyped ContainerSpec dict in _check_api_features1686-check-api-features
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | docker/api/service.py | 2 | ||||
-rw-r--r-- | tests/integration/api_service_test.py | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/docker/api/service.py b/docker/api/service.py index cc16cc3..4b555a5 100644 --- a/docker/api/service.py +++ b/docker/api/service.py @@ -38,7 +38,7 @@ def _check_api_features(version, task_template, update_config): 'Placement.preferences is not supported in' ' API version < 1.27' ) - if task_template.container_spec.get('TTY'): + if task_template.get('ContainerSpec', {}).get('TTY'): if utils.version_lt(version, '1.25'): raise errors.InvalidVersion( 'ContainerSpec.TTY is not supported in API version < 1.25' diff --git a/tests/integration/api_service_test.py b/tests/integration/api_service_test.py index 54111a7..c966916 100644 --- a/tests/integration/api_service_test.py +++ b/tests/integration/api_service_test.py @@ -376,6 +376,23 @@ class ServiceTest(BaseAPIIntegrationTest): assert 'TTY' in con_spec assert con_spec['TTY'] is True + @requires_api_version('1.25') + def test_create_service_with_tty_dict(self): + container_spec = { + 'Image': BUSYBOX, + 'Command': ['true'], + 'TTY': True + } + task_tmpl = docker.types.TaskTemplate(container_spec) + name = self.get_service_name() + svc_id = self.client.create_service(task_tmpl, name=name) + svc_info = self.client.inspect_service(svc_id) + assert 'TaskTemplate' in svc_info['Spec'] + assert 'ContainerSpec' in svc_info['Spec']['TaskTemplate'] + con_spec = svc_info['Spec']['TaskTemplate']['ContainerSpec'] + assert 'TTY' in con_spec + assert con_spec['TTY'] is True + def test_create_service_global_mode(self): container_spec = docker.types.ContainerSpec( BUSYBOX, ['echo', 'hello'] |