Fix leaky tests

It was mocking self.client but relying on the call to
utils.create_host_config which was not mocked. So now that function
has moved to also be on self.client we need to redefine the test
boundary, up to where we would call docker-py, not the result of
docker-py.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-09-17 15:33:58 +01:00
commit 39ba2c5a7c
2 changed files with 14 additions and 9 deletions

View file

@ -144,8 +144,11 @@ class CLITestCase(unittest.TestCase):
'--rm': None,
'--name': None,
})
_, _, call_kwargs = mock_client.create_container.mock_calls[0]
self.assertEquals(call_kwargs['host_config']['RestartPolicy']['Name'], 'always')
self.assertEquals(
mock_client.create_host_config.call_args[1]['restart_policy']['Name'],
'always'
)
command = TopLevelCommand()
mock_client = mock.create_autospec(docker.Client)
@ -170,8 +173,10 @@ class CLITestCase(unittest.TestCase):
'--rm': True,
'--name': None,
})
_, _, call_kwargs = mock_client.create_container.mock_calls[0]
self.assertFalse('RestartPolicy' in call_kwargs['host_config'])
self.assertFalse(
mock_client.create_host_config.call_args[1].get('restart_policy')
)
def test_command_manula_and_service_ports_together(self):
command = TopLevelCommand()