mirror of https://github.com/docker/docker-py.git
Merge branch 'upstream-master' into bind-mounts
Conflicts: tests/test.py
This commit is contained in:
commit
2551105320
|
@ -1,5 +1,8 @@
|
|||
build
|
||||
dist
|
||||
*.egg-info
|
||||
*.egg/
|
||||
*.pyc
|
||||
*.swp
|
||||
|
||||
.tox
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
ChangeLog
|
||||
=========
|
||||
|
||||
0.0.6
|
||||
-----
|
||||
* Added support for custom loggers in `Client.build`
|
||||
* Added `Client.attach` command
|
||||
* Added support for `ADD` command in builder
|
||||
* Fixed a bug in `Client.logs`
|
||||
* Improved unit tests
|
||||
|
||||
|
||||
0.0.5
|
||||
-----
|
||||
* Added tag support for the builder
|
||||
* Use `shlex` to parse plain string commands when creating a container
|
||||
* Fixed several bugs in the builder
|
||||
* Fixed the `quiet` option in `Client.images`
|
||||
* Unit tests
|
||||
|
||||
0.0.4
|
||||
-----
|
||||
* Improved error reporting
|
||||
|
||||
0.0.3
|
||||
-----
|
||||
* Fixed a bug in `Client.tag`
|
||||
* Fixed a bug where generated images would be removed after a successful build
|
||||
|
||||
0.0.2
|
||||
-----
|
||||
* Implemented first version of the builder client
|
|
@ -1,8 +1,13 @@
|
|||
import json
|
||||
import logging
|
||||
import re
|
||||
import six
|
||||
import shlex
|
||||
from StringIO import StringIO
|
||||
|
||||
if six.PY3:
|
||||
from io import StringIO
|
||||
else:
|
||||
from StringIO import StringIO
|
||||
|
||||
import requests
|
||||
from requests.exceptions import HTTPError
|
||||
|
@ -43,7 +48,7 @@ class Client(requests.Session):
|
|||
def _container_config(self, image, command, hostname=None, user=None,
|
||||
detach=False, stdin_open=False, tty=False, mem_limit=0, ports=None,
|
||||
environment=None, dns=None, volumes=None, volumes_from=None):
|
||||
if isinstance(command, basestring):
|
||||
if isinstance(command, six.string_types):
|
||||
command = shlex.split(command)
|
||||
return {
|
||||
'Hostname': hostname,
|
||||
|
@ -68,7 +73,7 @@ class Client(requests.Session):
|
|||
# so we do this disgusting thing here.
|
||||
data2 = {}
|
||||
if data is not None:
|
||||
for k, v in data.iteritems():
|
||||
for k, v in six.iteritems(data):
|
||||
if v is not None:
|
||||
data2[k] = v
|
||||
|
||||
|
@ -183,7 +188,7 @@ class Client(requests.Session):
|
|||
'repo': repository,
|
||||
'tag': tag
|
||||
}
|
||||
if type(src) == str or type(src) == unicode:
|
||||
if isinstance(src, six.string_types):
|
||||
params['fromSrc'] = src
|
||||
return self._result(self.post(u, None, params=params))
|
||||
|
||||
|
|
4
setup.py
4
setup.py
|
@ -8,10 +8,10 @@ SOURCE_DIR = os.path.join(ROOT_DIR)
|
|||
test_requirements = []
|
||||
setup(
|
||||
name="docker-py",
|
||||
version='0.0.5',
|
||||
version='0.0.6',
|
||||
description="Python client for Docker.",
|
||||
packages=['docker'],
|
||||
install_requires=['requests'] + test_requirements,
|
||||
install_requires=['requests', 'six'] + test_requirements,
|
||||
zip_safe=False,
|
||||
classifiers=['Development Status :: 3 - Alpha',
|
||||
'Environment :: Other Environment',
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import os
|
||||
import six
|
||||
import unittest
|
||||
|
||||
import docker
|
||||
|
||||
# FIXME: missing tests for
|
||||
# build; export; history; import_image; insert; port; push;
|
||||
# remove_image; tag; kill/stop/start/wait/restart (multi)
|
||||
# export; history; import_image; insert; port; push;
|
||||
# tag; kill/stop/start/wait/restart (multi)
|
||||
|
||||
class BaseTestCase(unittest.TestCase):
|
||||
tmp_imgs = []
|
||||
|
@ -66,7 +67,7 @@ class TestImages(BaseTestCase):
|
|||
class TestImageIds(BaseTestCase):
|
||||
def runTest(self):
|
||||
res1 = self.client.images(quiet=True)
|
||||
self.assertEqual(type(res1[0]), unicode)
|
||||
self.assertEqual(type(res1[0]), six.text_type)
|
||||
|
||||
class TestListContainers(BaseTestCase):
|
||||
def runTest(self):
|
||||
|
@ -251,7 +252,7 @@ class TestPull(BaseTestCase):
|
|||
self.assertIn('Images', info)
|
||||
img_count = info['Images']
|
||||
res = self.client.pull('joffrey/test001')
|
||||
self.assertEqual(type(res), unicode)
|
||||
self.assertEqual(type(res), six.text_type)
|
||||
self.assertEqual(img_count + 2, self.client.info()['Images'])
|
||||
img_info = self.client.inspect_image('joffrey/test001')
|
||||
self.assertIn('id', img_info)
|
||||
|
@ -293,6 +294,37 @@ class TestRemoveImage(BaseTestCase):
|
|||
res = [x for x in images if x['Id'].startswith(img_id)]
|
||||
self.assertEqual(len(res), 0)
|
||||
|
||||
#################
|
||||
# BUILDER TESTS #
|
||||
#################
|
||||
|
||||
class TestBuild(BaseTestCase):
|
||||
def runTest(self):
|
||||
script = [
|
||||
'MAINTAINER docker-py',
|
||||
'FROM busybox',
|
||||
'RUN mkdir -p /tmp/test',
|
||||
'EXPOSE 8080',
|
||||
'ADD https://dl.dropboxusercontent.com/u/20637798/silence.tar.gz /tmp/silence.tar.gz'
|
||||
]
|
||||
img, logs = self.client.build(script)
|
||||
self.assertNotEqual(img, None)
|
||||
self.assertNotEqual(img, '')
|
||||
self.assertNotEqual(logs, '')
|
||||
container1 = self.client.create_container(img, 'test -d /tmp/test')
|
||||
id1 = container1['Id']
|
||||
self.client.start(id1)
|
||||
self.tmp_containers.append(id1)
|
||||
exitcode1 = self.client.wait(id1)
|
||||
self.assertEqual(exitcode1, 0)
|
||||
container2 = self.client.create_container(img, 'test -d /tmp/test')
|
||||
id2 = container2['Id']
|
||||
self.client.start(id2)
|
||||
self.tmp_containers.append(id2)
|
||||
exitcode2 = self.client.wait(id2)
|
||||
self.assertEqual(exitcode2, 0)
|
||||
self.tmp_imgs.append(img)
|
||||
|
||||
#######################
|
||||
## PY SPECIFIC TESTS ##
|
||||
#######################
|
||||
|
|
Loading…
Reference in New Issue