def test_delete_work_item_correct_id(self): test_work_item_id = 1 # set return values self.mock_validate_token.return_value = True self.mock_delete_WI.return_value.id = test_work_item_id response = delete_work_item( id=test_work_item_id, destroy=False, organization=self._TEST_DEVOPS_ORGANIZATION, detect='Off') # assert self.mock_validate_token.assert_not_called() self.mock_delete_WI.assert_called_once_with(test_work_item_id, False) assert response.id == test_work_item_id
def test_delete_work_item_raises_exception_invalid_id(self): test_work_item_id = 1000 self.mock_validate_token.return_value = True self.mock_delete_WI.side_effect = Exception( r'TF401232: Work item 1000 does not exist, or you do not have permissions to read it.' ) with self.assertRaises(Exception) as exc: response = delete_work_item( id=test_work_item_id, organization=self._TEST_DEVOPS_ORGANIZATION) self.assertEqual( str(exc.exception), r'TF401232: Work item 1000 does not exist, or you do not have permissions to read it.' ) self.mock_delete_WI.assert_called_once_with(test_work_item_id, False) self.mock_validate_token.assert_not_called()