summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAanand Prasad <aanand.prasad@gmail.com>2015-03-20 14:26:10 -0700
committerAanand Prasad <aanand.prasad@gmail.com>2015-03-20 15:42:10 -0700
commitbd72bd13c7a49f69dcacfdf655c15b5be2aaa2ad (patch)
tree08774701b8f061470cb4fa8282cc94979b092f37 /tests
parent014dba284198e97925223bb95172281d7dd4e3e0 (diff)
downloaddocker-py-bd72bd13c7a49f69dcacfdf655c15b5be2aaa2ad.tar.gz
Finish labels implementation, add tests and docs
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test.py b/tests/test.py
index 5750c94..a363c35 100644
--- a/tests/test.py
+++ b/tests/test.py
@@ -1305,6 +1305,54 @@ class DockerClientTest(Cleanup, unittest.TestCase):
args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
)
+ def test_create_container_with_labels_dict(self):
+ labels_dict = {
+ six.text_type('foo'): six.text_type('1'),
+ six.text_type('bar'): six.text_type('2'),
+ }
+ try:
+ self.client.create_container(
+ 'busybox', 'true',
+ labels=labels_dict,
+ )
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ args = fake_request.call_args
+ self.assertEqual(args[0][0], url_prefix + 'containers/create')
+ self.assertEqual(json.loads(args[1]['data'])['Labels'], labels_dict)
+ self.assertEqual(
+ args[1]['headers'], {'Content-Type': 'application/json'}
+ )
+ self.assertEqual(
+ args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
+ )
+
+ def test_create_container_with_labels_list(self):
+ labels_list = [
+ six.text_type('foo'),
+ six.text_type('bar'),
+ ]
+ labels_dict = {
+ six.text_type('foo'): six.text_type(),
+ six.text_type('bar'): six.text_type(),
+ }
+ try:
+ self.client.create_container(
+ 'busybox', 'true',
+ labels=labels_list,
+ )
+ except Exception as e:
+ self.fail('Command should not raise exception: {0}'.format(e))
+ args = fake_request.call_args
+ self.assertEqual(args[0][0], url_prefix + 'containers/create')
+ self.assertEqual(json.loads(args[1]['data'])['Labels'], labels_dict)
+ self.assertEqual(
+ args[1]['headers'], {'Content-Type': 'application/json'}
+ )
+ self.assertEqual(
+ args[1]['timeout'], docker.client.DEFAULT_TIMEOUT_SECONDS
+ )
+
def test_resize_container(self):
try:
self.client.resize(