'Performs a delete LPAR test.'

@mock.patch('pypowervm.tasks.vterm.close_vterm', autospec=True)
def test_dlt_lpar(self, mock_vterm):

    vm.delete_lpar(self.apt, 'inst')
    self.get_pvm_uuid.assert_called_once_with('inst')
    self.apt.delete.assert_called_once_with(pvm_lpar.LPAR.schema_type, root_id=self.get_pvm_uuid.return_value)
    self.assertEqual(1, mock_vterm.call_count)
    resp = mock.Mock()
    resp.body = 'error    msg:    HSCL151B    more    text'
    self.apt.delete.side_effect = pvm_exc.Error('Mock    Error    Message', response=resp)
    self.apt.reset_mock()
    mock_vterm.reset_mock()
    self.assertRaises(pvm_exc.Error, vm.delete_lpar, self.apt, 'inst')
    self.assertEqual(1, mock_vterm.call_count)
    self.assertEqual(1, self.apt.delete.call_count)
    self.apt.reset_mock()
    mock_vterm.reset_mock()
    resp.status = 404
    self.apt.delete.side_effect = pvm_exc.HttpError(resp=resp)
    vm.delete_lpar(self.apt, 'inst')
    self.assertEqual(1, mock_vterm.call_count)
    self.assertEqual(1, self.apt.delete.call_count)
    self.apt.reset_mock()
    mock_vterm.reset_mock()
    resp.status = 111
    self.apt.delete.side_effect = pvm_exc.HttpError(resp=resp)
    self.assertRaises(pvm_exc.HttpError, vm.delete_lpar, self.apt, 'inst')
    self.assertEqual(1, mock_vterm.call_count)
    self.assertEqual(1, self.apt.delete.call_count)
    self.apt.reset_mock()
    mock_vterm.reset_mock()
    resp.status = 404
    mock_vterm.side_effect = pvm_exc.HttpError(resp=resp)
    vm.delete_lpar(self.apt, 'inst')
    self.assertEqual(1, mock_vterm.call_count)
    self.assertEqual(0, self.apt.delete.call_count)
    self.apt.reset_mock()
    mock_vterm.reset_mock()
    resp.status = 111
    mock_vterm.side_effect = pvm_exc.HttpError(resp=resp)
    self.assertRaises(pvm_exc.HttpError, vm.delete_lpar, self.apt, 'inst')
    self.assertEqual(1, mock_vterm.call_count)
    self.assertEqual(0, self.apt.delete.call_count)
