mirror of https://github.com/docker/docker-py.git
Merge pull request #765 from docker/api_1.20_support
Support API version 1.20
This commit is contained in:
commit
02f330d8dc
|
@ -1,4 +1,4 @@
|
|||
DEFAULT_DOCKER_API_VERSION = '1.19'
|
||||
DEFAULT_DOCKER_API_VERSION = '1.20'
|
||||
DEFAULT_TIMEOUT_SECONDS = 60
|
||||
STREAM_HEADER_SIZE_BYTES = 8
|
||||
CONTAINER_LIMITS_KEYS = [
|
||||
|
|
|
@ -264,14 +264,8 @@ class TestCreateContainerWithBinds(BaseTestCase):
|
|||
if six.PY3:
|
||||
logs = logs.decode('utf-8')
|
||||
self.assertIn(self.filename, logs)
|
||||
|
||||
# FIXME: format changes in API version >= 1.20
|
||||
inspect_data = self.client.inspect_container(container)
|
||||
self.assertEqual(
|
||||
self.mount_origin,
|
||||
inspect_data['Volumes'][self.mount_dest]
|
||||
)
|
||||
self.assertTrue(inspect_data['VolumesRW'][self.mount_dest])
|
||||
self.check_container_data(inspect_data, True)
|
||||
|
||||
def test_ro(self):
|
||||
container = self.run_with_volume(
|
||||
|
@ -285,13 +279,28 @@ class TestCreateContainerWithBinds(BaseTestCase):
|
|||
logs = logs.decode('utf-8')
|
||||
self.assertIn(self.filename, logs)
|
||||
|
||||
# FIXME: format changes in API version >= 1.20
|
||||
inspect_data = self.client.inspect_container(container)
|
||||
self.assertEqual(
|
||||
self.mount_origin,
|
||||
inspect_data['Volumes'][self.mount_dest]
|
||||
)
|
||||
self.assertFalse(inspect_data['VolumesRW'][self.mount_dest])
|
||||
self.check_container_data(inspect_data, False)
|
||||
|
||||
def check_container_data(self, inspect_data, rw):
|
||||
if docker.utils.compare_version('1.20', self.client._version) < 0:
|
||||
self.assertIn('Volumes', inspect_data)
|
||||
self.assertIn(self.mount_dest, inspect_data['Volumes'])
|
||||
self.assertEqual(
|
||||
self.mount_origin, inspect_data['Volumes'][self.mount_dest]
|
||||
)
|
||||
self.assertIn(self.mount_dest, inspect_data['VolumesRW'])
|
||||
self.assertFalse(inspect_data['VolumesRW'][self.mount_dest])
|
||||
else:
|
||||
self.assertIn('Mounts', inspect_data)
|
||||
filtered = list(filter(
|
||||
lambda x: x['Destination'] == self.mount_dest,
|
||||
inspect_data['Mounts']
|
||||
))
|
||||
self.assertEqual(len(filtered), 1)
|
||||
mount_data = filtered[0]
|
||||
self.assertEqual(mount_data['Source'], self.mount_origin)
|
||||
self.assertEqual(mount_data['RW'], rw)
|
||||
|
||||
|
||||
@requires_api_version('1.20')
|
||||
|
@ -325,6 +334,7 @@ class CreateContainerWithGroupAddTest(BaseTestCase):
|
|||
logs = self.client.logs(container)
|
||||
if six.PY3:
|
||||
logs = logs.decode('utf-8')
|
||||
|
||||
groups = logs.strip().split(' ')
|
||||
self.assertIn('1000', groups)
|
||||
self.assertIn('1001', groups)
|
||||
|
|
Loading…
Reference in New Issue