self.vping.ssh = mock.Mock()
stdout = mock.Mock()
stdout.channel.recv_exit_status.return_value = ret
- self.vping.ssh.exec_command.return_value = (None, stdout, None)
+ self.vping.ssh.exec_command.return_value = (None, stdout, mock.Mock())
self.assertEqual(self.vping.execute(), ret)
self.vping.ssh.exec_command.assert_called_once_with(
'ping -c 1 {}'.format(self.vping.vm2.private_v4))
self.vping.clean()
def test_clean_exc2(self):
+ self.vping.vm2 = munch.Munch(id='vm2')
mdelete_server = self.vping.cloud.delete_server
mdelete_server.side_effect = shade.OpenStackCloudException(None)
with self.assertRaises(shade.OpenStackCloudException):
@mock.patch('functest.core.singlevm.SingleVm2.clean',
side_effect=Exception)
def test_clean_exc3(self, *args):
- self.vping.vm2 = munch.Munch()
+ self.vping.vm2 = munch.Munch(id='vm2')
with self.assertRaises(Exception):
self.vping.clean()
self.vping.cloud.delete_server.assert_called_once_with(
args[0].assert_called_once_with()
@mock.patch('functest.core.singlevm.SingleVm2.clean')
- def test_clean(self, *args):
- self.vping.vm2 = munch.Munch()
+ def test_clean1(self, *args):
+ self.vping.vm2 = None
+ self.vping.clean()
+ self.vping.cloud.delete_server.assert_not_called()
+ args[0].assert_called_once_with()
+
+ @mock.patch('functest.core.singlevm.SingleVm2.clean')
+ def test_clean2(self, *args):
+ self.vping.vm2 = munch.Munch(id='vm2')
self.vping.clean()
self.vping.cloud.delete_server.assert_called_once_with(
self.vping.vm2, wait=True,