Improves code style

This commit is contained in:
Ulises Reyes 2013-12-15 20:28:38 -05:00
parent 844e41088e
commit d8e0f5a66f
3 changed files with 34 additions and 66 deletions

View File

@ -156,71 +156,35 @@ def get_fake_inspect_image():
} }
return status_code, response return status_code, response
def get_fake_port(): def get_fake_port():
status_code = 200 status_code = 200
response = {'Args': [], response = {
'Config': {'AttachStderr': True, 'HostConfig': {
'AttachStdin': False, 'Binds': None,
'AttachStdout': True, 'ContainerIDFile': '',
'Cmd': ['yes'], 'Links': None,
'CpuShares': 0, 'LxcConf': None,
'Dns': None, 'PortBindings': {
'Domainname': '', '1111': None,
'Entrypoint': None, '1111/tcp': [{'HostIp': '127.0.0.1', 'HostPort': '4567'}],
'Env': None, '2222': None
'ExposedPorts': {'1111': {}, '2222': {}}, },
'Hostname': 'a398832bc87e', 'Privileged': False,
'Image': 'ubuntu', 'PublishAllPorts': False
'Memory': 0, },
'MemorySwap': 0, 'NetworkSettings': {
'NetworkDisabled': False, 'Bridge': 'docker0',
'OpenStdin': False, 'PortMapping': None,
'PortSpecs': None, 'Ports': {
'StdinOnce': False, '1111': None,
'Tty': False, '1111/tcp': [{'HostIp': '127.0.0.1', 'HostPort': '4567'}],
'User': '', '2222': None}
'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': {}}
return status_code, response return status_code, response
def get_fake_insert_image(): def get_fake_insert_image():
status_code = 200 status_code = 200
response = {'StatusCode': 0} response = {'StatusCode': 0}

View File

@ -402,19 +402,21 @@ class TestKillWithSignal(BaseTestCase):
self.assertIn('Running', state) self.assertIn('Running', state)
self.assertEqual(state['Running'], False, state) self.assertEqual(state['Running'], False, state)
class TestPort(BaseTestCase): class TestPort(BaseTestCase):
def runTest(self): def runTest(self):
port_bindings = { port_bindings = {
1111 :('127.0.0.1', '4567'), 1111: ('127.0.0.1', '4567'),
2222 :('192.168.0.100', '4568') 2222: ('192.168.0.100', '4568')
} }
container = self.client.create_container('busybox', ['sleep', '60'], container = self.client.create_container(
ports=port_bindings.keys()) 'busybox', ['sleep', '60'], ports=port_bindings.keys()
)
id = container['Id'] 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 #Call the port function on each biding and compare expected vs actual
for port in port_bindings: for port in port_bindings:
@ -428,6 +430,7 @@ class TestPort(BaseTestCase):
self.client.kill(id) self.client.kill(id)
class TestRestart(BaseTestCase): class TestRestart(BaseTestCase):
def runTest(self): def runTest(self):
container = self.client.create_container('busybox', ['sleep', '9999']) container = self.client.create_container('busybox', ['sleep', '9999'])

View File

@ -33,6 +33,7 @@ try:
except ImportError: except ImportError:
import mock import mock
def response(status_code=200, content='', headers=None, reason=None, elapsed=0, def response(status_code=200, content='', headers=None, reason=None, elapsed=0,
request=None): request=None):
res = requests.Response() res = requests.Response()