Skip to content
Snippets Groups Projects
Commit 0190accb authored by Waleed Akbar's avatar Waleed Akbar
Browse files

To resolve the "test_GetKpiDescriptor" test fail issue.

- Test was failing due to a "NotFoundException."
- Replaced with None and made approriate changes in files (Kpi_DB.py and KpiManagerServiceImpl) to handle the None value.
parent a8912315
No related branches found
No related tags found
2 merge requests!294Release TeraFlowSDN 4.0,!256Resolve "Job Failed #80694"
...@@ -85,8 +85,9 @@ class KpiDB: ...@@ -85,8 +85,9 @@ class KpiDB:
# LOGGER.debug(f"{model.__name__} ID found: {str(entity)}") # LOGGER.debug(f"{model.__name__} ID found: {str(entity)}")
return entity return entity
else: else:
LOGGER.debug(f"{model.__name__} ID not found: {str(id_to_search)}") LOGGER.debug(f"{model.__name__} ID not found, No matching row: {str(id_to_search)}")
raise NotFoundException (model.__name__, id_to_search, extra_details=["Row not found with ID"] ) print("{:} ID not found, No matching row: {:}".format(model.__name__, id_to_search))
return None
except Exception as e: except Exception as e:
session.rollback() session.rollback()
LOGGER.debug(f"Failed to retrieve {model.__name__} ID. {str(e)}") LOGGER.debug(f"Failed to retrieve {model.__name__} ID. {str(e)}")
......
...@@ -52,8 +52,13 @@ class KpiManagerServiceServicerImpl(KpiManagerServiceServicer): ...@@ -52,8 +52,13 @@ class KpiManagerServiceServicerImpl(KpiManagerServiceServicer):
try: try:
kpi_id_to_search = request.kpi_id.uuid kpi_id_to_search = request.kpi_id.uuid
row = self.kpi_db_obj.search_db_row_by_id(KpiModel, 'kpi_id', kpi_id_to_search) row = self.kpi_db_obj.search_db_row_by_id(KpiModel, 'kpi_id', kpi_id_to_search)
response = KpiModel.convert_row_to_KpiDescriptor(row) if row is None:
return response print ('No matching row found for kpi id: {:}'.format(kpi_id_to_search))
LOGGER.info('No matching row found kpi id: {:}'.format(kpi_id_to_search))
return Empty()
else:
response = KpiModel.convert_row_to_KpiDescriptor(row)
return response
except Exception as e: except Exception as e:
print ('Unable to search kpi id. {:}'.format(e)) print ('Unable to search kpi id. {:}'.format(e))
LOGGER.info('Unable to search kpi id. {:}'.format(e)) LOGGER.info('Unable to search kpi id. {:}'.format(e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment