def test_create_dvporgroup_task_raises_runtime_fault(self): exc = vmodl.RuntimeFault() exc.msg = 'RuntimeFault msg' self.mock_dvs_ref.CreateDVPortgroup_Task = MagicMock(side_effect=exc) with self.assertRaises(VMwareRuntimeError) as excinfo: vmware.create_dvportgroup(self.mock_dvs_ref, self.mock_pg_spec) self.assertEqual(excinfo.exception.strerror, 'RuntimeFault msg')
def test_create_dvporgroup_task_raises_no_permission(self): exc = vim.fault.NoPermission() exc.privilegeId = 'Fake privilege' self.mock_dvs_ref.CreateDVPortgroup_Task = MagicMock(side_effect=exc) with self.assertRaises(VMwareApiError) as excinfo: vmware.create_dvportgroup(self.mock_dvs_ref, self.mock_pg_spec) self.assertEqual( excinfo.exception.strerror, 'Not enough permissions. Required privilege: ' 'Fake privilege')
def test_wait_for_tasks(self): vmware.create_dvportgroup(self.mock_dvs_ref, self.mock_pg_spec) self.mock_wait_for_task.assert_called_once_with( self.mock_task, 'fake_dvs', '<class \'unit.utils.vmware.test_dvs.FakeTaskClass\'>')
def test_create_dvporgroup_task(self): vmware.create_dvportgroup(self.mock_dvs_ref, self.mock_pg_spec) self.mock_dvs_ref.CreateDVPortgroup_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.create_dvportgroup(self.mock_dvs_ref, self.mock_pg_spec) mock_get_managed_object_name.assert_called_once_with(self.mock_dvs_ref)