Merge pull request #3676 from aanand/warn-for-swarm-mode

Show a warning when engine is in swarm mode
This commit is contained in:
Aanand Prasad 2016-07-27 15:38:09 +01:00 committed by GitHub
commit e9d62e8404
3 changed files with 248 additions and 0 deletions

View file

@ -510,3 +510,35 @@ class ProjectTest(unittest.TestCase):
project.down(ImageType.all, True)
self.mock_client.remove_image.assert_called_once_with("busybox:latest")
def test_warning_in_swarm_mode(self):
self.mock_client.info.return_value = {'Swarm': {'LocalNodeState': 'active'}}
project = Project('composetest', [], self.mock_client)
with mock.patch('compose.project.log') as fake_log:
project.up()
assert fake_log.warn.call_count == 1
def test_no_warning_on_stop(self):
self.mock_client.info.return_value = {'Swarm': {'LocalNodeState': 'active'}}
project = Project('composetest', [], self.mock_client)
with mock.patch('compose.project.log') as fake_log:
project.stop()
assert fake_log.warn.call_count == 0
def test_no_warning_in_normal_mode(self):
self.mock_client.info.return_value = {'Swarm': {'LocalNodeState': 'inactive'}}
project = Project('composetest', [], self.mock_client)
with mock.patch('compose.project.log') as fake_log:
project.up()
assert fake_log.warn.call_count == 0
def test_no_warning_with_no_swarm_info(self):
self.mock_client.info.return_value = {}
project = Project('composetest', [], self.mock_client)
with mock.patch('compose.project.log') as fake_log:
project.up()
assert fake_log.warn.call_count == 0