From 8309ae78961fc93b87a6716d2c1fc43961dc78fc Mon Sep 17 00:00:00 2001 From: shin- Date: Fri, 8 Nov 2013 19:34:30 +0100 Subject: [PATCH] Added unit test for named containers --- tests/test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test.py b/tests/test.py index e9941326..400ec617 100644 --- a/tests/test.py +++ b/tests/test.py @@ -203,6 +203,26 @@ class DockerClientTest(unittest.TestCase): self.assertEqual(args[1]['headers'], {'Content-Type': 'application/json'}) + def test_create_named_container(self): + try: + self.client.create_container('busybox', 'true', + name='marisa-kirisame') + except Exception as e: + self.fail('Command should not raise exception: {0}'.format(e)) + + args = fake_request.call_args + self.assertEqual(args[0][0], + 'unix://var/run/docker.sock/v1.4/containers/create') + self.assertEqual(json.loads(args[0][1]), + json.loads(''' + {"Tty": false, "Image": "busybox", "Cmd": ["true"], + "AttachStdin": false, "Memory": 0, + "AttachStderr": true, "Privileged": false, + "AttachStdout": true, "OpenStdin": false}''')) + self.assertEqual(args[1]['headers'], + {'Content-Type': 'application/json'}) + self.assertEqual(args[1]['params'], {'name': 'marisa-kirisame'}) + def test_start_container(self): try: self.client.start(fake_api.FAKE_CONTAINER_ID)