Add unit test with host and service for reconfigure action

1. it should be add in I86ebb5e8a24927e43105fbfa72a405d31ab68e86,
but missing, this PS to supplement.

Change-Id: I5f2da6533c45d68d659f4706af791ecccf02c82b
This commit is contained in:
caoyuan 2019-09-06 15:06:08 +08:00
parent ea2da49ca5
commit 9b4d42a685
1 changed files with 52 additions and 0 deletions

View File

@ -28,3 +28,55 @@ class TestUnit(KollaCliUnitTest):
ret = self.run_cli_command('action reconfigure')
self.assertEqual(ret, 0)
mock_reconfigure.assert_called_once_with(1, [], [])
@mock.patch('kolla_cli.api.control_plane.ControlPlaneApi.reconfigure')
@mock.patch('kolla_cli.common.ansible.job.AnsibleJob.get_status')
@mock.patch('kolla_cli.shell.KollaCli._is_inventory_present',
return_value=True)
def test_reconfigure_with_hosts(self,
_,
mock_get_status,
mock_reconfigure):
mock_get_status.return_value = 0
mock_reconfigure.return_value = self.get_fake_job()
hostnames = ['host1', 'host2']
ret = self.run_cli_command(
'action reconfigure --hosts {hosts}'.format(
hosts=','.join(hostnames)))
self.assertEqual(ret, 0)
mock_reconfigure.assert_called_once_with(1, hostnames, [])
@mock.patch('kolla_cli.api.control_plane.ControlPlaneApi.reconfigure')
@mock.patch('kolla_cli.common.ansible.job.AnsibleJob.get_status')
@mock.patch('kolla_cli.shell.KollaCli._is_inventory_present',
return_value=True)
def test_reconfigure_with_services(self,
_,
mock_get_status,
mock_reconfigure):
mock_get_status.return_value = 0
mock_reconfigure.return_value = self.get_fake_job()
services = ['service1', 'service2']
ret = self.run_cli_command(
'action reconfigure --services {services}'.format(
services=','.join(services)))
self.assertEqual(ret, 0)
mock_reconfigure.assert_called_once_with(1, [], services)
@mock.patch('kolla_cli.api.control_plane.ControlPlaneApi.reconfigure')
@mock.patch('kolla_cli.common.ansible.job.AnsibleJob.get_status')
@mock.patch('kolla_cli.shell.KollaCli._is_inventory_present',
return_value=True)
def test_reconfigure_with_hosts_and_services(self,
_,
mock_get_status,
mock_reconfigure):
mock_get_status.return_value = 0
mock_reconfigure.return_value = self.get_fake_job()
hostnames = ['host1', 'host2']
services = ['service1', 'service2']
ret = self.run_cli_command(
'action reconfigure --hosts {hosts} --services {services}'.format(
hosts=','.join(hostnames), services=','.join(services)))
self.assertEqual(ret, 0)
mock_reconfigure.assert_called_once_with(1, hostnames, services)