mirror of https://github.com/docker/compose.git
Cleanup some test case, remove unused mock return values, and use standard single underscore for unused variable
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
fc63454c99
commit
bdec7e6b52
|
@ -313,7 +313,7 @@ class CLITestCase(DockerClientTestCase):
|
||||||
self.assertEqual('moto=bobo', container.environment['allo'])
|
self.assertEqual('moto=bobo', container.environment['allo'])
|
||||||
|
|
||||||
@mock.patch('dockerpty.start')
|
@mock.patch('dockerpty.start')
|
||||||
def test_run_service_without_map_ports(self, __):
|
def test_run_service_without_map_ports(self, _):
|
||||||
# create one off container
|
# create one off container
|
||||||
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
||||||
self.command.dispatch(['run', '-d', 'simple'], None)
|
self.command.dispatch(['run', '-d', 'simple'], None)
|
||||||
|
@ -331,7 +331,7 @@ class CLITestCase(DockerClientTestCase):
|
||||||
self.assertEqual(port_assigned, None)
|
self.assertEqual(port_assigned, None)
|
||||||
|
|
||||||
@mock.patch('dockerpty.start')
|
@mock.patch('dockerpty.start')
|
||||||
def test_run_service_with_map_ports(self, __):
|
def test_run_service_with_map_ports(self, _):
|
||||||
|
|
||||||
# create one off container
|
# create one off container
|
||||||
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
||||||
|
@ -354,7 +354,7 @@ class CLITestCase(DockerClientTestCase):
|
||||||
self.assertEqual(port_range[1], "0.0.0.0:49154")
|
self.assertEqual(port_range[1], "0.0.0.0:49154")
|
||||||
|
|
||||||
@mock.patch('dockerpty.start')
|
@mock.patch('dockerpty.start')
|
||||||
def test_run_service_with_explicitly_maped_ports(self, __):
|
def test_run_service_with_explicitly_maped_ports(self, _):
|
||||||
|
|
||||||
# create one off container
|
# create one off container
|
||||||
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
||||||
|
@ -373,7 +373,7 @@ class CLITestCase(DockerClientTestCase):
|
||||||
self.assertEqual(port_full, "0.0.0.0:30001")
|
self.assertEqual(port_full, "0.0.0.0:30001")
|
||||||
|
|
||||||
@mock.patch('dockerpty.start')
|
@mock.patch('dockerpty.start')
|
||||||
def test_run_service_with_explicitly_maped_ip_ports(self, __):
|
def test_run_service_with_explicitly_maped_ip_ports(self, _):
|
||||||
|
|
||||||
# create one off container
|
# create one off container
|
||||||
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
self.command.base_dir = 'tests/fixtures/ports-composefile'
|
||||||
|
|
|
@ -99,14 +99,12 @@ class ServiceTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_split_domainname_none(self):
|
def test_split_domainname_none(self):
|
||||||
service = Service('foo', image='foo', hostname='name', client=self.mock_client)
|
service = Service('foo', image='foo', hostname='name', client=self.mock_client)
|
||||||
self.mock_client.containers.return_value = []
|
|
||||||
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
||||||
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
||||||
self.assertFalse('domainname' in opts, 'domainname')
|
self.assertFalse('domainname' in opts, 'domainname')
|
||||||
|
|
||||||
def test_memory_swap_limit(self):
|
def test_memory_swap_limit(self):
|
||||||
service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, mem_limit=1000000000, memswap_limit=2000000000)
|
service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, mem_limit=1000000000, memswap_limit=2000000000)
|
||||||
self.mock_client.containers.return_value = []
|
|
||||||
opts = service._get_container_create_options({'some': 'overrides'}, 1)
|
opts = service._get_container_create_options({'some': 'overrides'}, 1)
|
||||||
self.assertEqual(opts['host_config']['MemorySwap'], 2000000000)
|
self.assertEqual(opts['host_config']['MemorySwap'], 2000000000)
|
||||||
self.assertEqual(opts['host_config']['Memory'], 1000000000)
|
self.assertEqual(opts['host_config']['Memory'], 1000000000)
|
||||||
|
@ -114,7 +112,6 @@ class ServiceTest(unittest.TestCase):
|
||||||
def test_log_opt(self):
|
def test_log_opt(self):
|
||||||
log_opt = {'syslog-address': 'tcp://192.168.0.42:123'}
|
log_opt = {'syslog-address': 'tcp://192.168.0.42:123'}
|
||||||
service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, log_driver='syslog', log_opt=log_opt)
|
service = Service(name='foo', image='foo', hostname='name', client=self.mock_client, log_driver='syslog', log_opt=log_opt)
|
||||||
self.mock_client.containers.return_value = []
|
|
||||||
opts = service._get_container_create_options({'some': 'overrides'}, 1)
|
opts = service._get_container_create_options({'some': 'overrides'}, 1)
|
||||||
|
|
||||||
self.assertIsInstance(opts['host_config']['LogConfig'], LogConfig)
|
self.assertIsInstance(opts['host_config']['LogConfig'], LogConfig)
|
||||||
|
@ -127,7 +124,6 @@ class ServiceTest(unittest.TestCase):
|
||||||
hostname='name.domain.tld',
|
hostname='name.domain.tld',
|
||||||
image='foo',
|
image='foo',
|
||||||
client=self.mock_client)
|
client=self.mock_client)
|
||||||
self.mock_client.containers.return_value = []
|
|
||||||
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
||||||
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
||||||
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
||||||
|
@ -139,7 +135,6 @@ class ServiceTest(unittest.TestCase):
|
||||||
image='foo',
|
image='foo',
|
||||||
domainname='domain.tld',
|
domainname='domain.tld',
|
||||||
client=self.mock_client)
|
client=self.mock_client)
|
||||||
self.mock_client.containers.return_value = []
|
|
||||||
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
||||||
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
self.assertEqual(opts['hostname'], 'name', 'hostname')
|
||||||
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
||||||
|
@ -151,7 +146,6 @@ class ServiceTest(unittest.TestCase):
|
||||||
domainname='domain.tld',
|
domainname='domain.tld',
|
||||||
image='foo',
|
image='foo',
|
||||||
client=self.mock_client)
|
client=self.mock_client)
|
||||||
self.mock_client.containers.return_value = []
|
|
||||||
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
opts = service._get_container_create_options({'image': 'foo'}, 1)
|
||||||
self.assertEqual(opts['hostname'], 'name.sub', 'hostname')
|
self.assertEqual(opts['hostname'], 'name.sub', 'hostname')
|
||||||
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
self.assertEqual(opts['domainname'], 'domain.tld', 'domainname')
|
||||||
|
|
Loading…
Reference in New Issue