Fix incorrect lcmocc_id specified in "get_lcmocc"

This patch fixes incorrect lcmocc_id is specified in
"get_lcmocc" function if the lcmocc_id does not exist
in VnfLcmOpOccV2.

Closes-Bug: #2007819
Change-Id: Ic64f1916fd90888bee8bc504eb3c493f1f2d6341
This commit is contained in:
Ken Fujimoto 2023-02-21 04:59:01 +00:00
parent 0dda8d07b6
commit 7f5c3906e8
2 changed files with 8 additions and 4 deletions

View File

@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__) # not used at the moment
def get_lcmocc(context, lcmocc_id):
lcmocc = objects.VnfLcmOpOccV2.get_by_id(context, lcmocc_id)
if lcmocc is None:
raise sol_ex.VnfLcmOpOccNotFound(lcmocc_id=id)
raise sol_ex.VnfLcmOpOccNotFound(lcmocc_id=lcmocc_id)
return lcmocc

View File

@ -2358,11 +2358,15 @@ class TestLcmOpOccUtils(base.BaseTestCase):
self.assertEqual(expected_result.operation, result.operation)
@mock.patch.object(objects.base.TackerPersistentObject, 'get_by_id')
def test_get_lcmocc_error(self, mock_lcmocc):
def test_get_lcmocc_not_exist_lcmocc_id(self, mock_lcmocc):
mock_lcmocc.return_value = None
self.assertRaises(
lcmocc_id = 'f5aa2eb2-6805-439d-b93d-bb0db8d96e3b'
ex = self.assertRaises(
sol_ex.VnfLcmOpOccNotFound,
lcmocc_utils.get_lcmocc, context, 'lcmocc_id')
lcmocc_utils.get_lcmocc, context, lcmocc_id)
expected_detail = f'VnfLcmOpOcc {lcmocc_id} not found.'
self.assertEqual(expected_detail, ex.detail)
@mock.patch.object(objects.base.TackerPersistentObject, 'get_all')
def test_get_lcmocc_all(self, mock_lcmocc):