diff options
author | Fumiaki MATSUSHIMA <mtsmfm@gmail.com> | 2017-12-01 02:40:13 +0900 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-01-30 17:16:23 -0800 |
commit | dd858648a0942177995a74e1eda3468a720a3c58 (patch) | |
tree | 2248a09ac1b36bb9bf16bbc7a823741ba5ffd8ee /tests/integration/api_container_test.py | |
parent | 2e8f1f798a3d6748735481ac519978a8b18a793c (diff) | |
download | docker-py-dd858648a0942177995a74e1eda3468a720a3c58.tar.gz |
Use config.json for detachKeys
Signed-off-by: Fumiaki Matsushima <mtsmfm@gmail.com>
Diffstat (limited to 'tests/integration/api_container_test.py')
-rw-r--r-- | tests/integration/api_container_test.py | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/tests/integration/api_container_test.py b/tests/integration/api_container_test.py index 4585c44..ebb5e91 100644 --- a/tests/integration/api_container_test.py +++ b/tests/integration/api_container_test.py @@ -1,4 +1,5 @@ import os +import re import signal import tempfile from datetime import datetime @@ -15,8 +16,9 @@ import six from .base import BUSYBOX, BaseAPIIntegrationTest from .. import helpers -from ..helpers import requires_api_version -import re +from ..helpers import ( + requires_api_version, ctrl_with, assert_socket_closed_with_keys +) class ListContainersTest(BaseAPIIntegrationTest): @@ -1223,6 +1225,58 @@ class AttachContainerTest(BaseAPIIntegrationTest): output = self.client.attach(container, stream=False, logs=True) assert output == 'hello\n'.encode(encoding='ascii') + def test_detach_with_default(self): + container = self.client.create_container( + BUSYBOX, '/bin/sh', + detach=True, stdin_open=True, tty=True + ) + id = container['Id'] + self.tmp_containers.append(id) + self.client.start(id) + + sock = self.client.attach_socket( + container, + {'stdin': True, 'stream': True} + ) + + assert_socket_closed_with_keys(sock, [ctrl_with('p'), ctrl_with('q')]) + + def test_detach_with_config_file(self): + self.client._general_configs['detachKeys'] = 'ctrl-p' + + container = self.client.create_container( + BUSYBOX, '/bin/sh', + detach=True, stdin_open=True, tty=True + ) + id = container['Id'] + self.tmp_containers.append(id) + self.client.start(id) + + sock = self.client.attach_socket( + container, + {'stdin': True, 'stream': True} + ) + + assert_socket_closed_with_keys(sock, [ctrl_with('p')]) + + def test_detach_with_arg(self): + self.client._general_configs['detachKeys'] = 'ctrl-p' + + container = self.client.create_container( + BUSYBOX, '/bin/sh', + detach=True, stdin_open=True, tty=True + ) + id = container['Id'] + self.tmp_containers.append(id) + self.client.start(id) + + sock = self.client.attach_socket( + container, + {'stdin': True, 'stream': True, 'detachKeys': 'ctrl-x'} + ) + + assert_socket_closed_with_keys(sock, [ctrl_with('x')]) + class PauseTest(BaseAPIIntegrationTest): def test_pause_unpause(self): |