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
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -85,8 +85,9 @@ class KpiDB:
                # LOGGER.debug(f"{model.__name__} ID found: {str(entity)}")
                return entity
            else:
                LOGGER.debug(f"{model.__name__} ID not found: {str(id_to_search)}")
                raise NotFoundException (model.__name__, id_to_search, extra_details=["Row not found with ID"] )
                LOGGER.debug(f"{model.__name__} ID not found, No matching row: {str(id_to_search)}")
                print("{:} ID not found, No matching row: {:}".format(model.__name__, id_to_search))
                return None
        except Exception as e:
            session.rollback()
            LOGGER.debug(f"Failed to retrieve {model.__name__} ID. {str(e)}")
+7 −2
Original line number Diff line number Diff line
@@ -52,6 +52,11 @@ class KpiManagerServiceServicerImpl(KpiManagerServiceServicer):
        try: 
            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)
            if row is None:
                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: