From 5a492b4129689b94b47d0aa43db962d60c286093 Mon Sep 17 00:00:00 2001 From: Issam Kadar Date: Tue, 7 Apr 2026 11:10:55 +0200 Subject: [PATCH 1/3] feat/converter : return empty list on no cisu compatible resources --- .../cisu/resources_info/resources_info_cisu_converter.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py index 2beefad90..1bc4acc95 100644 --- a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py +++ b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py @@ -201,7 +201,7 @@ def from_cisu_to_rs(cls, edxl_json: Dict[str, Any]) -> List[Dict[str, Any]]: return messages @classmethod - def from_rs_to_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]: + def from_rs_to_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any] | list[Dict[str, Any]]: logger.info("Converting from RS to CISU format for Resources Info message.") logger.debug(f"Message content: {edxl_json}") output_json = cls.copy_rs_input_content(edxl_json) @@ -214,10 +214,8 @@ def from_rs_to_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]: converted_resources = cls.convert_resources_to_cisu(resources) if len(converted_resources) < 1: - raise ValueError( - "Could not map resources to CISU. " - "At least one resource must have a CISU compatible vehicleType. " - ) + logger.info("No CISU-compatible resources remain after filtering — returning empty list.") + return [] set_value( output_use_case_json, From 6e07bb17b5dba9c91d6a6864a07f8dbce7dd97e6 Mon Sep 17 00:00:00 2001 From: Issam Kadar Date: Tue, 7 Apr 2026 11:14:05 +0200 Subject: [PATCH 2/3] feat/converter : add tests --- .../cisu/test_resources_info_converter.py | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/converter/tests/cisu/test_resources_info_converter.py b/converter/tests/cisu/test_resources_info_converter.py index c06fc080f..64226128d 100644 --- a/converter/tests/cisu/test_resources_info_converter.py +++ b/converter/tests/cisu/test_resources_info_converter.py @@ -32,19 +32,14 @@ # Dictionnaire des cas d'erreur : file_name -> message attendu ERROR_CASES = { - **{ - name: "No states found in resource, mandatory for CISU conversion." - for name in usecase_files_with_empty_state - }, - **{ - name: "At least one resource must have a CISU compatible vehicleType." - for name in usecase_files_with_unsupported_vehicle_type - }, + name: "No states found in resource, mandatory for CISU conversion." + for name in usecase_files_with_empty_state } TEST_CASES = [ (name, ValueError, ERROR_CASES[name]) if name in ERROR_CASES else (name, None, None) for name in all_file_names + if name not in usecase_files_with_unsupported_vehicle_type ] @@ -85,6 +80,21 @@ def test_rs_to_cisu(file_name, expected_exception, expected_message): ResourcesInfoCISUConverter.from_rs_to_cisu(edxl_json) +@pytest.mark.parametrize( + "file_name", + usecase_files_with_unsupported_vehicle_type, +) +def test_rs_to_cisu_returns_empty_list_when_no_cisu_compatible_resource(file_name): + """Quand toutes les ressources ont un vehicleType non supporté, from_rs_to_cisu + doit retourner [] au lieu de lever une erreur.""" + usecase_file = next(f for f in all_usecase_files if f["name"] == file_name) + edxl_json = TestHelper.create_edxl_json_from_sample( + TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH, usecase_file["path"] + ) + result = ResourcesInfoCISUConverter.from_rs_to_cisu(edxl_json) + assert result == [] + + def test_rs_to_cisu_should_delete_patient_id(): rs_raw_message = TestHelper.create_edxl_json_from_sample( TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH, From 92339c5af7dccc3b57bf58e6e9756593b6e0cca6 Mon Sep 17 00:00:00 2001 From: Issam Kadar Date: Tue, 7 Apr 2026 11:29:45 +0200 Subject: [PATCH 3/3] feat/converter : format code --- .../cisu/resources_info/resources_info_cisu_converter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py index 1bc4acc95..c7229c12a 100644 --- a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py +++ b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py @@ -201,7 +201,9 @@ def from_cisu_to_rs(cls, edxl_json: Dict[str, Any]) -> List[Dict[str, Any]]: return messages @classmethod - def from_rs_to_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any] | list[Dict[str, Any]]: + def from_rs_to_cisu( + cls, edxl_json: Dict[str, Any] + ) -> Dict[str, Any] | list[Dict[str, Any]]: logger.info("Converting from RS to CISU format for Resources Info message.") logger.debug(f"Message content: {edxl_json}") output_json = cls.copy_rs_input_content(edxl_json) @@ -214,7 +216,9 @@ def from_rs_to_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any] | list[Dic converted_resources = cls.convert_resources_to_cisu(resources) if len(converted_resources) < 1: - logger.info("No CISU-compatible resources remain after filtering — returning empty list.") + logger.info( + "No CISU-compatible resources remain after filtering — returning empty list." + ) return [] set_value(