mirror of https://github.com/docker/docker-py.git
Improves code style
This commit is contained in:
parent
844e41088e
commit
d8e0f5a66f
|
@ -156,71 +156,35 @@ def get_fake_inspect_image():
|
|||
}
|
||||
return status_code, response
|
||||
|
||||
|
||||
def get_fake_port():
|
||||
status_code = 200
|
||||
response = {'Args': [],
|
||||
'Config': {'AttachStderr': True,
|
||||
'AttachStdin': False,
|
||||
'AttachStdout': True,
|
||||
'Cmd': ['yes'],
|
||||
'CpuShares': 0,
|
||||
'Dns': None,
|
||||
'Domainname': '',
|
||||
'Entrypoint': None,
|
||||
'Env': None,
|
||||
'ExposedPorts': {'1111': {}, '2222': {}},
|
||||
'Hostname': 'a398832bc87e',
|
||||
'Image': 'ubuntu',
|
||||
'Memory': 0,
|
||||
'MemorySwap': 0,
|
||||
'NetworkDisabled': False,
|
||||
'OpenStdin': False,
|
||||
'PortSpecs': None,
|
||||
'StdinOnce': False,
|
||||
'Tty': False,
|
||||
'User': '',
|
||||
'Volumes': None,
|
||||
'VolumesFrom': '',
|
||||
'WorkingDir': ''},
|
||||
'Created': '2013-12-14T17:41:13.976760086Z',
|
||||
'Driver': 'aufs',
|
||||
'HostConfig': {'Binds': None,
|
||||
'ContainerIDFile': '',
|
||||
'Links': None,
|
||||
'LxcConf': None,
|
||||
'PortBindings': {'1111': None,
|
||||
'1111/tcp': [{'HostIp': '127.0.0.1', 'HostPort': '4567'}],
|
||||
'2222': None},
|
||||
'Privileged': False,
|
||||
'PublishAllPorts': False},
|
||||
'HostnamePath': '/var/lib/docker/containers/a398832bc87e15b220d710a98386493559df2448480fc9243e86ee5544eea767/hostname',
|
||||
'HostsPath': '/var/lib/docker/containers/a398832bc87e15b220d710a98386493559df2448480fc9243e86ee5544eea767/hosts',
|
||||
'ID': 'a398832bc87e15b220d710a98386493559df2448480fc9243e86ee5544eea767',
|
||||
'Image': '8dbd9e392a964056420e5d58ca5cc376ef18e2de93b5cc90e868a1bbc8318c1c',
|
||||
'Name': '/sad_tesla7',
|
||||
'NetworkSettings': {'Bridge': 'docker0',
|
||||
'Gateway': '172.17.42.1',
|
||||
'IPAddress': '172.17.0.19',
|
||||
'IPPrefixLen': 16,
|
||||
'PortMapping': None,
|
||||
'Ports': {'1111': None,
|
||||
'1111/tcp': [{'HostIp': '127.0.0.1', 'HostPort': '4567'}],
|
||||
'2222': None}},
|
||||
'Path': 'yes',
|
||||
'ResolvConfPath': '/var/lib/docker/containers/a398832bc87e15b220d710a98386493559df2448480fc9243e86ee5544eea767/resolv.conf',
|
||||
'State': {'ExitCode': 0,
|
||||
'FinishedAt': '0001-01-01T00:00:00Z',
|
||||
'Ghost': False,
|
||||
'Pid': 11703,
|
||||
'Running': True,
|
||||
'StartedAt': '2013-12-14T17:41:27.844076587Z'},
|
||||
'SysInitPath': '/usr/bin/docker',
|
||||
'Volumes': {},
|
||||
'VolumesRW': {}}
|
||||
|
||||
|
||||
response = {
|
||||
'HostConfig': {
|
||||
'Binds': None,
|
||||
'ContainerIDFile': '',
|
||||
'Links': None,
|
||||
'LxcConf': None,
|
||||
'PortBindings': {
|
||||
'1111': None,
|
||||
'1111/tcp': [{'HostIp': '127.0.0.1', 'HostPort': '4567'}],
|
||||
'2222': None
|
||||
},
|
||||
'Privileged': False,
|
||||
'PublishAllPorts': False
|
||||
},
|
||||
'NetworkSettings': {
|
||||
'Bridge': 'docker0',
|
||||
'PortMapping': None,
|
||||
'Ports': {
|
||||
'1111': None,
|
||||
'1111/tcp': [{'HostIp': '127.0.0.1', 'HostPort': '4567'}],
|
||||
'2222': None}
|
||||
}
|
||||
}
|
||||
return status_code, response
|
||||
|
||||
|
||||
def get_fake_insert_image():
|
||||
status_code = 200
|
||||
response = {'StatusCode': 0}
|
||||
|
|
|
@ -402,19 +402,21 @@ class TestKillWithSignal(BaseTestCase):
|
|||
self.assertIn('Running', state)
|
||||
self.assertEqual(state['Running'], False, state)
|
||||
|
||||
|
||||
class TestPort(BaseTestCase):
|
||||
def runTest(self):
|
||||
|
||||
port_bindings = {
|
||||
1111 :('127.0.0.1', '4567'),
|
||||
2222 :('192.168.0.100', '4568')
|
||||
1111: ('127.0.0.1', '4567'),
|
||||
2222: ('192.168.0.100', '4568')
|
||||
}
|
||||
|
||||
container = self.client.create_container('busybox', ['sleep', '60'],
|
||||
ports=port_bindings.keys())
|
||||
container = self.client.create_container(
|
||||
'busybox', ['sleep', '60'], ports=port_bindings.keys()
|
||||
)
|
||||
id = container['Id']
|
||||
|
||||
self.client.start(container, port_bindings= port_bindings)
|
||||
self.client.start(container, port_bindings=port_bindings)
|
||||
|
||||
#Call the port function on each biding and compare expected vs actual
|
||||
for port in port_bindings:
|
||||
|
@ -428,6 +430,7 @@ class TestPort(BaseTestCase):
|
|||
|
||||
self.client.kill(id)
|
||||
|
||||
|
||||
class TestRestart(BaseTestCase):
|
||||
def runTest(self):
|
||||
container = self.client.create_container('busybox', ['sleep', '9999'])
|
||||
|
|
|
@ -33,6 +33,7 @@ try:
|
|||
except ImportError:
|
||||
import mock
|
||||
|
||||
|
||||
def response(status_code=200, content='', headers=None, reason=None, elapsed=0,
|
||||
request=None):
|
||||
res = requests.Response()
|
||||
|
|
Loading…
Reference in New Issue