summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2016-02-01 14:19:43 -0800
committerJoffrey F <joffrey@docker.com>2016-02-23 16:18:36 -0800
commita710fbf60a8015a3a9acabe739d40e0a3ab894ce (patch)
treee7a8a5dfba5f1cbdc1bb4501b8808c57072c4b58
parent6f6d0890a44c17f1052782b8ccf903edb8badd67 (diff)
downloaddocker-py-a710fbf60a8015a3a9acabe739d40e0a3ab894ce.tar.gz
Unit test for Client.update_container method
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--tests/unit/container_test.py18
-rw-r--r--tests/unit/fake_api.py7
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/unit/container_test.py b/tests/unit/container_test.py
index c2b2573..621e471 100644
--- a/tests/unit/container_test.py
+++ b/tests/unit/container_test.py
@@ -1407,3 +1407,21 @@ class ContainerTest(DockerClientTest):
params={'ps_args': 'waux'},
timeout=DEFAULT_TIMEOUT_SECONDS
)
+
+ @requires_api_version('1.22')
+ def test_container_update(self):
+ self.client.update_container(
+ fake_api.FAKE_CONTAINER_ID, mem_limit='2k', cpu_shares=124,
+ blkio_weight=345
+ )
+ args = fake_request.call_args
+ self.assertEqual(
+ args[0][1], url_prefix + 'containers/3cc2351ab11b/update'
+ )
+ self.assertEqual(
+ json.loads(args[1]['data']),
+ {'Memory': 2 * 1024, 'CpuShares': 124, 'BlkioWeight': 345}
+ )
+ self.assertEqual(
+ args[1]['headers']['Content-Type'], 'application/json'
+ )
diff --git a/tests/unit/fake_api.py b/tests/unit/fake_api.py
index 8852da0..9952595 100644
--- a/tests/unit/fake_api.py
+++ b/tests/unit/fake_api.py
@@ -441,6 +441,11 @@ def get_fake_volume():
def fake_remove_volume():
return 204, None
+
+def post_fake_update_container():
+ return 200, {'Warnings': []}
+
+
# Maps real api url to fake response callback
prefix = 'http+docker://localunixsocket'
fake_responses = {
@@ -478,6 +483,8 @@ fake_responses = {
get_fake_diff,
'{1}/{0}/containers/3cc2351ab11b/export'.format(CURRENT_VERSION, prefix):
get_fake_export,
+ '{1}/{0}/containers/3cc2351ab11b/update'.format(CURRENT_VERSION, prefix):
+ post_fake_update_container,
'{1}/{0}/containers/3cc2351ab11b/exec'.format(CURRENT_VERSION, prefix):
post_fake_exec_create,
'{1}/{0}/exec/d5d177f121dc/start'.format(CURRENT_VERSION, prefix):