def test_reconfigure_dvporgroup_task_raises_runtime_fault(self): exc = vmodl.RuntimeFault() exc.msg = 'RuntimeFault msg' self.mock_pg_ref.ReconfigureDVPortgroup_Task = \ MagicMock(side_effect=exc) with self.assertRaises(VMwareRuntimeError) as excinfo: vmware.update_dvportgroup(self.mock_pg_ref, self.mock_pg_spec) self.assertEqual(excinfo.exception.strerror, 'RuntimeFault msg')
def test_reconfigure_dvporgroup_task_raises_no_permission(self): exc = vim.fault.NoPermission() exc.privilegeId = 'Fake privilege' self.mock_pg_ref.ReconfigureDVPortgroup_Task = \ MagicMock(side_effect=exc) with self.assertRaises(VMwareApiError) as excinfo: vmware.update_dvportgroup(self.mock_pg_ref, self.mock_pg_spec) self.assertEqual( excinfo.exception.strerror, 'Not enough permissions. Required privilege: ' 'Fake privilege')
def test_wait_for_tasks(self): vmware.update_dvportgroup(self.mock_pg_ref, self.mock_pg_spec) self.mock_wait_for_task.assert_called_once_with( self.mock_task, 'fake_pg', '<class \'unit.utils.vmware.test_dvs.FakeTaskClass\'>')
def test_reconfigure_dvporgroup_task(self): vmware.update_dvportgroup(self.mock_pg_ref, self.mock_pg_spec) self.mock_pg_ref.ReconfigureDVPortgroup_Task.assert_called_once_with( self.mock_pg_spec)
def test_get_managed_object_name_call(self): mock_get_managed_object_name = MagicMock() with patch('salt.utils.vmware.get_managed_object_name', mock_get_managed_object_name): vmware.update_dvportgroup(self.mock_pg_ref, self.mock_pg_spec) mock_get_managed_object_name.assert_called_once_with(self.mock_pg_ref)