From 862aa110d08b0aed8678f288d47e6bd03b875c01 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 14:47:23 +0200 Subject: [PATCH 01/27] feat(converter): refactor "versions" to "health_version_converters" and "cisu" to "cisu_transcoders" --- .../{cisu => cisu_transcoders}/__init__.py | 0 .../base_cisu_converter.py | 0 .../{cisu => cisu_transcoders}/constants.py | 0 .../create_case/create_case_cisu_constants.py | 0 .../create_case/create_case_cisu_converter.py | 7 ++--- .../identical_cisu_converter.py | 2 +- .../reference/reference_converter.py | 2 +- .../resources_info_cisu_constants.py | 0 .../resources_info_cisu_converter.py | 6 ++-- .../resources_info_cisu_helper.py | 2 +- .../resources_status_constants.py | 0 .../resources_status_converter.py | 10 +++---- .../{cisu => cisu_transcoders}/utils.py | 0 .../cisu_conversion_strategy.py | 10 +++---- .../health_conversion_strategy.py | 28 +++++++++++-------- .../base_message_converter.py | 0 .../create_case_health/constants.py | 0 .../create_case_health_converter.py | 16 +++++++---- .../create_case_health_update_converter.py | 2 +- .../create_case_health/v1_v2/constants.py | 0 .../create_case_health/v1_v2/utils.py | 6 ++-- .../create_case_health/v2_v3/constants.py | 0 .../error_converter.py | 4 ++- .../geo_positions_update_constants.py | 0 .../geo_positions_update_converter.py | 8 ++++-- .../geo_resources_details_constants.py | 0 .../geo_resources_details_converter.py | 8 ++++-- .../identical_message_converter.py | 4 ++- .../reference/reference_constants.py | 0 .../reference/reference_converter.py | 8 ++++-- .../resources_engagement_constants.py | 0 .../resources_engagement_converter.py | 6 ++-- .../resources_info_constants.py | 0 .../resources_info_converter.py | 8 ++++-- .../resources_request_constants.py | 0 .../resources_request_converter.py | 8 ++++-- .../resources_response_constants.py | 0 .../resources_response_converter.py | 6 ++-- .../resources_status_constants.py | 0 .../resources_status_converter.py | 8 ++++-- .../utils.py | 0 converter/tests/cisu/test_cisu_utils.py | 2 +- .../tests/cisu/test_create_case_converter.py | 20 ++++++------- .../cisu/test_identical_cisu_converter.py | 2 +- .../tests/cisu/test_reference_converter.py | 2 +- .../cisu/test_resources_info_cisu_helper.py | 2 +- .../cisu/test_resources_info_converter.py | 8 +++--- .../cisu/test_resources_status_converter.py | 4 +-- .../test_cisu_conversion_strategy.py | 16 +++++------ .../test_health_conversion_strategy.py | 24 ++++++++-------- .../test_v1_v2_converter.py | 6 ++-- .../create_health_case/test_v1_v2_utils.py | 12 +++++--- .../test_v2_v3_converter.py | 2 +- .../test_geo_positions_update_converter.py | 2 +- .../test_geo_resources_details_converter.py | 2 +- .../test_geo_resources_request_converter.py | 4 ++- .../versions/test_identical_converter.py | 4 ++- .../versions/test_reference_converter.py | 4 ++- .../test_resources_engagement_converter.py | 2 +- .../versions/test_resources_info_converter.py | 2 +- .../test_resources_request_converter.py | 2 +- .../test_resources_response_converter.py | 2 +- .../test_resources_status_converter.py | 2 +- .../versions/test_rs_eda_maj_converter.py | 2 +- converter/tests/versions/test_utils.py | 2 +- 65 files changed, 167 insertions(+), 122 deletions(-) rename converter/converter/{cisu => cisu_transcoders}/__init__.py (100%) rename converter/converter/{cisu => cisu_transcoders}/base_cisu_converter.py (100%) rename converter/converter/{cisu => cisu_transcoders}/constants.py (100%) rename converter/converter/{cisu => cisu_transcoders}/create_case/create_case_cisu_constants.py (100%) rename converter/converter/{cisu => cisu_transcoders}/create_case/create_case_cisu_converter.py (98%) rename converter/converter/{cisu => cisu_transcoders}/identical_cisu_converter.py (79%) rename converter/converter/{cisu => cisu_transcoders}/reference/reference_converter.py (77%) rename converter/converter/{cisu => cisu_transcoders}/resources_info/resources_info_cisu_constants.py (100%) rename converter/converter/{cisu => cisu_transcoders}/resources_info/resources_info_cisu_converter.py (98%) rename converter/converter/{cisu => cisu_transcoders}/resources_info/resources_info_cisu_helper.py (97%) rename converter/converter/{cisu => cisu_transcoders}/resources_status/resources_status_constants.py (100%) rename converter/converter/{cisu => cisu_transcoders}/resources_status/resources_status_converter.py (86%) rename converter/converter/{cisu => cisu_transcoders}/utils.py (100%) rename converter/converter/{versions => health_version_converters}/base_message_converter.py (100%) rename converter/converter/{versions => health_version_converters}/create_case_health/constants.py (100%) rename converter/converter/{versions => health_version_converters}/create_case_health/create_case_health_converter.py (97%) rename converter/converter/{versions => health_version_converters}/create_case_health/create_case_health_update_converter.py (74%) rename converter/converter/{versions => health_version_converters}/create_case_health/v1_v2/constants.py (100%) rename converter/converter/{versions => health_version_converters}/create_case_health/v1_v2/utils.py (94%) rename converter/converter/{versions => health_version_converters}/create_case_health/v2_v3/constants.py (100%) rename converter/converter/{versions => health_version_converters}/error_converter.py (51%) rename converter/converter/{versions => health_version_converters}/geo_positions_update/geo_positions_update_constants.py (100%) rename converter/converter/{versions => health_version_converters}/geo_positions_update/geo_positions_update_converter.py (91%) rename converter/converter/{versions => health_version_converters}/geo_resources_details/geo_resources_details_constants.py (100%) rename converter/converter/{versions => health_version_converters}/geo_resources_details/geo_resources_details_converter.py (86%) rename converter/converter/{versions => health_version_converters}/identical_message_converter.py (84%) rename converter/converter/{versions => health_version_converters}/reference/reference_constants.py (100%) rename converter/converter/{versions => health_version_converters}/reference/reference_converter.py (70%) rename converter/converter/{versions => health_version_converters}/resources_engagement/resources_engagement_constants.py (100%) rename converter/converter/{versions => health_version_converters}/resources_engagement/resources_engagement_converter.py (86%) rename converter/converter/{versions => health_version_converters}/resources_info/resources_info_constants.py (100%) rename converter/converter/{versions => health_version_converters}/resources_info/resources_info_converter.py (97%) rename converter/converter/{versions => health_version_converters}/resources_request/resources_request_constants.py (100%) rename converter/converter/{versions => health_version_converters}/resources_request/resources_request_converter.py (80%) rename converter/converter/{versions => health_version_converters}/resources_response/resources_response_constants.py (100%) rename converter/converter/{versions => health_version_converters}/resources_response/resources_response_converter.py (82%) rename converter/converter/{versions => health_version_converters}/resources_status/resources_status_constants.py (100%) rename converter/converter/{versions => health_version_converters}/resources_status/resources_status_converter.py (92%) rename converter/converter/{versions => health_version_converters}/utils.py (100%) diff --git a/converter/converter/cisu/__init__.py b/converter/converter/cisu_transcoders/__init__.py similarity index 100% rename from converter/converter/cisu/__init__.py rename to converter/converter/cisu_transcoders/__init__.py diff --git a/converter/converter/cisu/base_cisu_converter.py b/converter/converter/cisu_transcoders/base_cisu_converter.py similarity index 100% rename from converter/converter/cisu/base_cisu_converter.py rename to converter/converter/cisu_transcoders/base_cisu_converter.py diff --git a/converter/converter/cisu/constants.py b/converter/converter/cisu_transcoders/constants.py similarity index 100% rename from converter/converter/cisu/constants.py rename to converter/converter/cisu_transcoders/constants.py diff --git a/converter/converter/cisu/create_case/create_case_cisu_constants.py b/converter/converter/cisu_transcoders/create_case/create_case_cisu_constants.py similarity index 100% rename from converter/converter/cisu/create_case/create_case_cisu_constants.py rename to converter/converter/cisu_transcoders/create_case/create_case_cisu_constants.py diff --git a/converter/converter/cisu/create_case/create_case_cisu_converter.py b/converter/converter/cisu_transcoders/create_case/create_case_cisu_converter.py similarity index 98% rename from converter/converter/cisu/create_case/create_case_cisu_converter.py rename to converter/converter/cisu_transcoders/create_case/create_case_cisu_converter.py index f7d7cefc3a..0609667d70 100644 --- a/converter/converter/cisu/create_case/create_case_cisu_converter.py +++ b/converter/converter/cisu_transcoders/create_case/create_case_cisu_converter.py @@ -6,11 +6,10 @@ from yaml import dump -from converter.cisu.create_case.create_case_cisu_constants import ( +from converter.cisu_transcoders.create_case.create_case_cisu_constants import ( CreateCaseCISUConstants, ) - -from converter.cisu.utils import add_to_initial_alert_notes +from converter.cisu_transcoders.utils import add_to_initial_alert_notes from converter.constants import Constants from pydantic import BaseModel, Field @@ -23,7 +22,7 @@ translate_key_words, set_value, ) -from converter.cisu.base_cisu_converter import BaseCISUConverter +from converter.cisu_transcoders.base_cisu_converter import BaseCISUConverter import logging logger = logging.getLogger(__name__) diff --git a/converter/converter/cisu/identical_cisu_converter.py b/converter/converter/cisu_transcoders/identical_cisu_converter.py similarity index 79% rename from converter/converter/cisu/identical_cisu_converter.py rename to converter/converter/cisu_transcoders/identical_cisu_converter.py index cc3de26a65..fcfa6cd4fb 100644 --- a/converter/converter/cisu/identical_cisu_converter.py +++ b/converter/converter/cisu_transcoders/identical_cisu_converter.py @@ -1,6 +1,6 @@ from typing import Dict, Any -from converter.cisu.base_cisu_converter import BaseCISUConverter +from converter.cisu_transcoders.base_cisu_converter import BaseCISUConverter class IdenticalCISUConverter(BaseCISUConverter): diff --git a/converter/converter/cisu/reference/reference_converter.py b/converter/converter/cisu_transcoders/reference/reference_converter.py similarity index 77% rename from converter/converter/cisu/reference/reference_converter.py rename to converter/converter/cisu_transcoders/reference/reference_converter.py index d20e063d27..2f9130d5ca 100644 --- a/converter/converter/cisu/reference/reference_converter.py +++ b/converter/converter/cisu_transcoders/reference/reference_converter.py @@ -1,4 +1,4 @@ -from converter.cisu.identical_cisu_converter import IdenticalCISUConverter +from converter.cisu_transcoders.identical_cisu_converter import IdenticalCISUConverter class ReferenceConverter(IdenticalCISUConverter): diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_constants.py b/converter/converter/cisu_transcoders/resources_info/resources_info_cisu_constants.py similarity index 100% rename from converter/converter/cisu/resources_info/resources_info_cisu_constants.py rename to converter/converter/cisu_transcoders/resources_info/resources_info_cisu_constants.py diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py b/converter/converter/cisu_transcoders/resources_info/resources_info_cisu_converter.py similarity index 98% rename from converter/converter/cisu/resources_info/resources_info_cisu_converter.py rename to converter/converter/cisu_transcoders/resources_info/resources_info_cisu_converter.py index 322a61fe84..439b18c110 100644 --- a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py +++ b/converter/converter/cisu_transcoders/resources_info/resources_info_cisu_converter.py @@ -1,12 +1,12 @@ import uuid -from converter.cisu.base_cisu_converter import BaseCISUConverter +from converter.cisu_transcoders.base_cisu_converter import BaseCISUConverter from typing import Any, Dict, List, TypedDict -from converter.cisu.resources_info.resources_info_cisu_constants import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_constants import ( ResourcesInfoCISUConstants, ) -from converter.cisu.resources_info.resources_info_cisu_helper import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_helper import ( enrich_rs_ri_with_rs_srs, get_latest_state, log_cisu_to_rs_converted_messages_ids, diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_helper.py b/converter/converter/cisu_transcoders/resources_info/resources_info_cisu_helper.py similarity index 97% rename from converter/converter/cisu/resources_info/resources_info_cisu_helper.py rename to converter/converter/cisu_transcoders/resources_info/resources_info_cisu_helper.py index 6b8a54e28e..ac319cf462 100644 --- a/converter/converter/cisu/resources_info/resources_info_cisu_helper.py +++ b/converter/converter/cisu_transcoders/resources_info/resources_info_cisu_helper.py @@ -1,6 +1,6 @@ from converter.conversion_mixin import ConversionMixin from converter.utils import get_field_value, set_value -from converter.cisu.resources_info.resources_info_cisu_constants import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_constants import ( ResourcesInfoCISUConstants, ) import logging diff --git a/converter/converter/cisu/resources_status/resources_status_constants.py b/converter/converter/cisu_transcoders/resources_status/resources_status_constants.py similarity index 100% rename from converter/converter/cisu/resources_status/resources_status_constants.py rename to converter/converter/cisu_transcoders/resources_status/resources_status_constants.py diff --git a/converter/converter/cisu/resources_status/resources_status_converter.py b/converter/converter/cisu_transcoders/resources_status/resources_status_converter.py similarity index 86% rename from converter/converter/cisu/resources_status/resources_status_converter.py rename to converter/converter/cisu_transcoders/resources_status/resources_status_converter.py index 1cd3718d78..dc1c409e18 100644 --- a/converter/converter/cisu/resources_status/resources_status_converter.py +++ b/converter/converter/cisu_transcoders/resources_status/resources_status_converter.py @@ -1,17 +1,17 @@ -from converter.cisu.base_cisu_converter import BaseCISUConverter +from converter.cisu_transcoders.base_cisu_converter import BaseCISUConverter from converter.repositories.message_repository import ( get_rs_messages_by_case_id, ) -from converter.cisu.resources_info.resources_info_cisu_helper import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_helper import ( enrich_rs_ri_with_rs_srs, ) -from converter.cisu.resources_info.resources_info_cisu_converter import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_converter import ( ResourcesInfoCISUConverter, ) -from converter.cisu.resources_info.resources_info_cisu_constants import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_constants import ( ResourcesInfoCISUConstants, ) -from converter.cisu.resources_status.resources_status_constants import ( +from converter.cisu_transcoders.resources_status.resources_status_constants import ( ResourcesStatusConstants, ) from typing import Any, Dict diff --git a/converter/converter/cisu/utils.py b/converter/converter/cisu_transcoders/utils.py similarity index 100% rename from converter/converter/cisu/utils.py rename to converter/converter/cisu_transcoders/utils.py diff --git a/converter/converter/conversion_strategy/cisu_conversion_strategy.py b/converter/converter/conversion_strategy/cisu_conversion_strategy.py index 7e2f1f727a..da34c0a51d 100644 --- a/converter/converter/conversion_strategy/cisu_conversion_strategy.py +++ b/converter/converter/conversion_strategy/cisu_conversion_strategy.py @@ -1,17 +1,17 @@ import logging -from converter.cisu.create_case.create_case_cisu_converter import ( +from converter.cisu_transcoders.create_case.create_case_cisu_converter import ( CreateCaseCISUConverter, ) -from converter.cisu.reference.reference_converter import ReferenceConverter -from converter.cisu.resources_info.resources_info_cisu_converter import ( +from converter.cisu_transcoders.reference.reference_converter import ReferenceConverter +from converter.cisu_transcoders.resources_info.resources_info_cisu_converter import ( ResourcesInfoCISUConverter, ) -from converter.cisu.resources_status.resources_status_converter import ( +from converter.cisu_transcoders.resources_status.resources_status_converter import ( ResourcesStatusConverter, ) from converter.constants import Constants -from converter.cisu.constants import CISUConstants +from converter.cisu_transcoders.constants import CISUConstants from converter.conversion_strategy.health_conversion_strategy import ( health_conversion_strategy, ) diff --git a/converter/converter/conversion_strategy/health_conversion_strategy.py b/converter/converter/conversion_strategy/health_conversion_strategy.py index aea32740e9..2de7a8f5c3 100644 --- a/converter/converter/conversion_strategy/health_conversion_strategy.py +++ b/converter/converter/conversion_strategy/health_conversion_strategy.py @@ -1,31 +1,35 @@ -from converter.versions.create_case_health.create_case_health_update_converter import ( +from converter.health_version_converters.create_case_health.create_case_health_update_converter import ( CreateHealthUpdateCaseConverter, ) -from converter.versions.error_converter import ErrorConverter -from converter.versions.identical_message_converter import IdenticalMessageConverter -from converter.versions.geo_resources_details.geo_resources_details_converter import ( +from converter.health_version_converters.error_converter import ErrorConverter +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) +from converter.health_version_converters.geo_resources_details.geo_resources_details_converter import ( GeoResourcesDetailsConverter, ) -from converter.versions.reference.reference_converter import ReferenceConverter -from converter.versions.create_case_health.create_case_health_converter import ( +from converter.health_version_converters.reference.reference_converter import ( + ReferenceConverter, +) +from converter.health_version_converters.create_case_health.create_case_health_converter import ( CreateHealthCaseConverter, ) -from converter.versions.resources_info.resources_info_converter import ( +from converter.health_version_converters.resources_info.resources_info_converter import ( ResourcesInfoConverter, ) -from converter.versions.resources_request.resources_request_converter import ( +from converter.health_version_converters.resources_request.resources_request_converter import ( ResourcesRequestConverter, ) -from converter.versions.resources_response.resources_response_converter import ( +from converter.health_version_converters.resources_response.resources_response_converter import ( ResourcesResponseConverter, ) -from converter.versions.resources_status.resources_status_converter import ( +from converter.health_version_converters.resources_status.resources_status_converter import ( ResourcesStatusConverter, ) -from converter.versions.resources_engagement.resources_engagement_converter import ( +from converter.health_version_converters.resources_engagement.resources_engagement_converter import ( ResourcesEngagementConverter, ) -from converter.versions.geo_positions_update.geo_positions_update_converter import ( +from converter.health_version_converters.geo_positions_update.geo_positions_update_converter import ( GeoPositionsUpdateConverter, ) import logging diff --git a/converter/converter/versions/base_message_converter.py b/converter/converter/health_version_converters/base_message_converter.py similarity index 100% rename from converter/converter/versions/base_message_converter.py rename to converter/converter/health_version_converters/base_message_converter.py diff --git a/converter/converter/versions/create_case_health/constants.py b/converter/converter/health_version_converters/create_case_health/constants.py similarity index 100% rename from converter/converter/versions/create_case_health/constants.py rename to converter/converter/health_version_converters/create_case_health/constants.py diff --git a/converter/converter/versions/create_case_health/create_case_health_converter.py b/converter/converter/health_version_converters/create_case_health/create_case_health_converter.py similarity index 97% rename from converter/converter/versions/create_case_health/create_case_health_converter.py rename to converter/converter/health_version_converters/create_case_health/create_case_health_converter.py index af56cfeb0c..d4331d8f24 100644 --- a/converter/converter/versions/create_case_health/create_case_health_converter.py +++ b/converter/converter/health_version_converters/create_case_health/create_case_health_converter.py @@ -8,14 +8,20 @@ map_to_new_value, switch_field_name, ) -from converter.versions.base_message_converter import BaseMessageConverter -from converter.versions.create_case_health.v1_v2.constants import V1V2Constants -from converter.versions.create_case_health.v1_v2.utils import ( +from converter.health_version_converters.base_message_converter import ( + BaseMessageConverter, +) +from converter.health_version_converters.create_case_health.v1_v2.constants import ( + V1V2Constants, +) +from converter.health_version_converters.create_case_health.v1_v2.utils import ( update_language, validate_diagnosis_code, ) -from converter.versions.create_case_health.v2_v3.constants import V2V3Constants -from converter.versions.utils import ( +from converter.health_version_converters.create_case_health.v2_v3.constants import ( + V2V3Constants, +) +from converter.health_version_converters.utils import ( reverse_map_to_new_value, ) diff --git a/converter/converter/versions/create_case_health/create_case_health_update_converter.py b/converter/converter/health_version_converters/create_case_health/create_case_health_update_converter.py similarity index 74% rename from converter/converter/versions/create_case_health/create_case_health_update_converter.py rename to converter/converter/health_version_converters/create_case_health/create_case_health_update_converter.py index 9a3d019698..75d8f3416c 100644 --- a/converter/converter/versions/create_case_health/create_case_health_update_converter.py +++ b/converter/converter/health_version_converters/create_case_health/create_case_health_update_converter.py @@ -1,4 +1,4 @@ -from converter.versions.create_case_health.create_case_health_converter import ( +from converter.health_version_converters.create_case_health.create_case_health_converter import ( CreateHealthCaseConverter, ) diff --git a/converter/converter/versions/create_case_health/v1_v2/constants.py b/converter/converter/health_version_converters/create_case_health/v1_v2/constants.py similarity index 100% rename from converter/converter/versions/create_case_health/v1_v2/constants.py rename to converter/converter/health_version_converters/create_case_health/v1_v2/constants.py diff --git a/converter/converter/versions/create_case_health/v1_v2/utils.py b/converter/converter/health_version_converters/create_case_health/v1_v2/utils.py similarity index 94% rename from converter/converter/versions/create_case_health/v1_v2/utils.py rename to converter/converter/health_version_converters/create_case_health/v1_v2/utils.py index aa5cdf452c..582ea8a992 100644 --- a/converter/converter/versions/create_case_health/v1_v2/utils.py +++ b/converter/converter/health_version_converters/create_case_health/v1_v2/utils.py @@ -1,6 +1,6 @@ import datetime -from converter.versions.create_case_health.constants import Constants +from converter.health_version_converters.create_case_health.constants import Constants from converter.utils import get_field_value, map_to_new_value, delete_paths, set_value import re from typing import Any, Dict @@ -8,7 +8,9 @@ from converter.utils import ( add_to_medical_notes, ) -from converter.versions.create_case_health.v1_v2.constants import V1V2Constants +from converter.health_version_converters.create_case_health.v1_v2.constants import ( + V1V2Constants, +) def validate_diagnosis_code( diff --git a/converter/converter/versions/create_case_health/v2_v3/constants.py b/converter/converter/health_version_converters/create_case_health/v2_v3/constants.py similarity index 100% rename from converter/converter/versions/create_case_health/v2_v3/constants.py rename to converter/converter/health_version_converters/create_case_health/v2_v3/constants.py diff --git a/converter/converter/versions/error_converter.py b/converter/converter/health_version_converters/error_converter.py similarity index 51% rename from converter/converter/versions/error_converter.py rename to converter/converter/health_version_converters/error_converter.py index fabb90623e..ae190b64a7 100644 --- a/converter/converter/versions/error_converter.py +++ b/converter/converter/health_version_converters/error_converter.py @@ -1,4 +1,6 @@ -from converter.versions.identical_message_converter import IdenticalMessageConverter +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) class ErrorConverter(IdenticalMessageConverter): diff --git a/converter/converter/versions/geo_positions_update/geo_positions_update_constants.py b/converter/converter/health_version_converters/geo_positions_update/geo_positions_update_constants.py similarity index 100% rename from converter/converter/versions/geo_positions_update/geo_positions_update_constants.py rename to converter/converter/health_version_converters/geo_positions_update/geo_positions_update_constants.py diff --git a/converter/converter/versions/geo_positions_update/geo_positions_update_converter.py b/converter/converter/health_version_converters/geo_positions_update/geo_positions_update_converter.py similarity index 91% rename from converter/converter/versions/geo_positions_update/geo_positions_update_converter.py rename to converter/converter/health_version_converters/geo_positions_update/geo_positions_update_converter.py index 268ab1b96a..863a2e6b69 100644 --- a/converter/converter/versions/geo_positions_update/geo_positions_update_converter.py +++ b/converter/converter/health_version_converters/geo_positions_update/geo_positions_update_converter.py @@ -1,11 +1,13 @@ from typing import Dict, Any from converter.utils import get_field_value, update_json_value, delete_paths -from converter.versions.base_message_converter import BaseMessageConverter -from converter.versions.geo_positions_update.geo_positions_update_constants import ( +from converter.health_version_converters.base_message_converter import ( + BaseMessageConverter, +) +from converter.health_version_converters.geo_positions_update.geo_positions_update_constants import ( GeoPositionsUpdateConstants, ) -from converter.versions.utils import convert_to_float, convert_to_str +from converter.health_version_converters.utils import convert_to_float, convert_to_str class GeoPositionsUpdateConverter(BaseMessageConverter): diff --git a/converter/converter/versions/geo_resources_details/geo_resources_details_constants.py b/converter/converter/health_version_converters/geo_resources_details/geo_resources_details_constants.py similarity index 100% rename from converter/converter/versions/geo_resources_details/geo_resources_details_constants.py rename to converter/converter/health_version_converters/geo_resources_details/geo_resources_details_constants.py diff --git a/converter/converter/versions/geo_resources_details/geo_resources_details_converter.py b/converter/converter/health_version_converters/geo_resources_details/geo_resources_details_converter.py similarity index 86% rename from converter/converter/versions/geo_resources_details/geo_resources_details_converter.py rename to converter/converter/health_version_converters/geo_resources_details/geo_resources_details_converter.py index f4224df213..8af2623c38 100644 --- a/converter/converter/versions/geo_resources_details/geo_resources_details_converter.py +++ b/converter/converter/health_version_converters/geo_resources_details/geo_resources_details_converter.py @@ -1,11 +1,13 @@ from typing import Dict, Any from converter.utils import get_field_value, map_to_new_value, update_json_value -from converter.versions.base_message_converter import BaseMessageConverter -from converter.versions.geo_resources_details.geo_resources_details_constants import ( +from converter.health_version_converters.base_message_converter import ( + BaseMessageConverter, +) +from converter.health_version_converters.geo_resources_details.geo_resources_details_constants import ( GeoResourcesDetailsConstants, ) -from converter.versions.utils import reverse_map_to_new_value +from converter.health_version_converters.utils import reverse_map_to_new_value class GeoResourcesDetailsConverter(BaseMessageConverter): diff --git a/converter/converter/versions/identical_message_converter.py b/converter/converter/health_version_converters/identical_message_converter.py similarity index 84% rename from converter/converter/versions/identical_message_converter.py rename to converter/converter/health_version_converters/identical_message_converter.py index b8875bff9c..e1bad75b96 100644 --- a/converter/converter/versions/identical_message_converter.py +++ b/converter/converter/health_version_converters/identical_message_converter.py @@ -1,6 +1,8 @@ from typing import Dict, Any -from converter.versions.base_message_converter import BaseMessageConverter +from converter.health_version_converters.base_message_converter import ( + BaseMessageConverter, +) class IdenticalMessageConverter(BaseMessageConverter): diff --git a/converter/converter/versions/reference/reference_constants.py b/converter/converter/health_version_converters/reference/reference_constants.py similarity index 100% rename from converter/converter/versions/reference/reference_constants.py rename to converter/converter/health_version_converters/reference/reference_constants.py diff --git a/converter/converter/versions/reference/reference_converter.py b/converter/converter/health_version_converters/reference/reference_converter.py similarity index 70% rename from converter/converter/versions/reference/reference_converter.py rename to converter/converter/health_version_converters/reference/reference_converter.py index 100ef9dedc..1cebf7ee7c 100644 --- a/converter/converter/versions/reference/reference_converter.py +++ b/converter/converter/health_version_converters/reference/reference_converter.py @@ -1,6 +1,10 @@ from converter.utils import delete_paths -from converter.versions.identical_message_converter import IdenticalMessageConverter -from converter.versions.reference.reference_constants import ReferenceConstants +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) +from converter.health_version_converters.reference.reference_constants import ( + ReferenceConstants, +) class ReferenceConverter(IdenticalMessageConverter): diff --git a/converter/converter/versions/resources_engagement/resources_engagement_constants.py b/converter/converter/health_version_converters/resources_engagement/resources_engagement_constants.py similarity index 100% rename from converter/converter/versions/resources_engagement/resources_engagement_constants.py rename to converter/converter/health_version_converters/resources_engagement/resources_engagement_constants.py diff --git a/converter/converter/versions/resources_engagement/resources_engagement_converter.py b/converter/converter/health_version_converters/resources_engagement/resources_engagement_converter.py similarity index 86% rename from converter/converter/versions/resources_engagement/resources_engagement_converter.py rename to converter/converter/health_version_converters/resources_engagement/resources_engagement_converter.py index ef8b8a82d2..4db2450057 100644 --- a/converter/converter/versions/resources_engagement/resources_engagement_converter.py +++ b/converter/converter/health_version_converters/resources_engagement/resources_engagement_converter.py @@ -1,6 +1,8 @@ from converter.utils import map_to_new_value, get_field_value, update_json_value -from converter.versions.identical_message_converter import IdenticalMessageConverter -from converter.versions.resources_engagement.resources_engagement_constants import ( +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) +from converter.health_version_converters.resources_engagement.resources_engagement_constants import ( ResourcesEngagementConstants, ) diff --git a/converter/converter/versions/resources_info/resources_info_constants.py b/converter/converter/health_version_converters/resources_info/resources_info_constants.py similarity index 100% rename from converter/converter/versions/resources_info/resources_info_constants.py rename to converter/converter/health_version_converters/resources_info/resources_info_constants.py diff --git a/converter/converter/versions/resources_info/resources_info_converter.py b/converter/converter/health_version_converters/resources_info/resources_info_converter.py similarity index 97% rename from converter/converter/versions/resources_info/resources_info_converter.py rename to converter/converter/health_version_converters/resources_info/resources_info_converter.py index b3f36af06e..3b982cca84 100644 --- a/converter/converter/versions/resources_info/resources_info_converter.py +++ b/converter/converter/health_version_converters/resources_info/resources_info_converter.py @@ -8,11 +8,13 @@ set_value, switch_field_name, ) -from converter.versions.base_message_converter import BaseMessageConverter -from converter.versions.resources_info.resources_info_constants import ( +from converter.health_version_converters.base_message_converter import ( + BaseMessageConverter, +) +from converter.health_version_converters.resources_info.resources_info_constants import ( ResourcesInfoConstants, ) -from converter.versions.utils import reverse_map_to_new_value +from converter.health_version_converters.utils import reverse_map_to_new_value logger = logging.getLogger(__name__) diff --git a/converter/converter/versions/resources_request/resources_request_constants.py b/converter/converter/health_version_converters/resources_request/resources_request_constants.py similarity index 100% rename from converter/converter/versions/resources_request/resources_request_constants.py rename to converter/converter/health_version_converters/resources_request/resources_request_constants.py diff --git a/converter/converter/versions/resources_request/resources_request_converter.py b/converter/converter/health_version_converters/resources_request/resources_request_converter.py similarity index 80% rename from converter/converter/versions/resources_request/resources_request_converter.py rename to converter/converter/health_version_converters/resources_request/resources_request_converter.py index 635e37e67e..7779744d38 100644 --- a/converter/converter/versions/resources_request/resources_request_converter.py +++ b/converter/converter/health_version_converters/resources_request/resources_request_converter.py @@ -1,11 +1,13 @@ from typing import Dict, Any from converter.utils import map_to_new_value -from converter.versions.identical_message_converter import IdenticalMessageConverter -from converter.versions.resources_request.resources_request_constants import ( +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) +from converter.health_version_converters.resources_request.resources_request_constants import ( ResourcesRequestConstants, ) -from converter.versions.utils import reverse_map_to_new_value +from converter.health_version_converters.utils import reverse_map_to_new_value class ResourcesRequestConverter(IdenticalMessageConverter): diff --git a/converter/converter/versions/resources_response/resources_response_constants.py b/converter/converter/health_version_converters/resources_response/resources_response_constants.py similarity index 100% rename from converter/converter/versions/resources_response/resources_response_constants.py rename to converter/converter/health_version_converters/resources_response/resources_response_constants.py diff --git a/converter/converter/versions/resources_response/resources_response_converter.py b/converter/converter/health_version_converters/resources_response/resources_response_converter.py similarity index 82% rename from converter/converter/versions/resources_response/resources_response_converter.py rename to converter/converter/health_version_converters/resources_response/resources_response_converter.py index c55399a0cc..9a653fc777 100644 --- a/converter/converter/versions/resources_response/resources_response_converter.py +++ b/converter/converter/health_version_converters/resources_response/resources_response_converter.py @@ -1,8 +1,10 @@ from typing import Dict, Any from converter.utils import get_field_value, set_value -from converter.versions.identical_message_converter import IdenticalMessageConverter -from converter.versions.resources_response.resources_response_constants import ( +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) +from converter.health_version_converters.resources_response.resources_response_constants import ( ResourcesResponseConstants, ) diff --git a/converter/converter/versions/resources_status/resources_status_constants.py b/converter/converter/health_version_converters/resources_status/resources_status_constants.py similarity index 100% rename from converter/converter/versions/resources_status/resources_status_constants.py rename to converter/converter/health_version_converters/resources_status/resources_status_constants.py diff --git a/converter/converter/versions/resources_status/resources_status_converter.py b/converter/converter/health_version_converters/resources_status/resources_status_converter.py similarity index 92% rename from converter/converter/versions/resources_status/resources_status_converter.py rename to converter/converter/health_version_converters/resources_status/resources_status_converter.py index e4752f2b88..125fc60568 100644 --- a/converter/converter/versions/resources_status/resources_status_converter.py +++ b/converter/converter/health_version_converters/resources_status/resources_status_converter.py @@ -1,11 +1,13 @@ from typing import Dict, Any from converter.utils import map_to_new_value, switch_field_name -from converter.versions.base_message_converter import BaseMessageConverter -from converter.versions.resources_status.resources_status_constants import ( +from converter.health_version_converters.base_message_converter import ( + BaseMessageConverter, +) +from converter.health_version_converters.resources_status.resources_status_constants import ( ResourcesStatusConstants, ) -from converter.versions.utils import reverse_map_to_new_value +from converter.health_version_converters.utils import reverse_map_to_new_value class ResourcesStatusConverter(BaseMessageConverter): diff --git a/converter/converter/versions/utils.py b/converter/converter/health_version_converters/utils.py similarity index 100% rename from converter/converter/versions/utils.py rename to converter/converter/health_version_converters/utils.py diff --git a/converter/tests/cisu/test_cisu_utils.py b/converter/tests/cisu/test_cisu_utils.py index d147073b13..217d2440fd 100644 --- a/converter/tests/cisu/test_cisu_utils.py +++ b/converter/tests/cisu/test_cisu_utils.py @@ -1,4 +1,4 @@ -from converter.cisu.utils import add_object_to_initial_alert_notes +from converter.cisu_transcoders.utils import add_object_to_initial_alert_notes def test_add_note_to_existing_notes(): diff --git a/converter/tests/cisu/test_create_case_converter.py b/converter/tests/cisu/test_create_case_converter.py index 78358f74e0..3e46c97cee 100644 --- a/converter/tests/cisu/test_create_case_converter.py +++ b/converter/tests/cisu/test_create_case_converter.py @@ -1,6 +1,6 @@ import unittest from unittest.mock import patch -from converter.cisu.create_case.create_case_cisu_converter import ( +from converter.cisu_transcoders.create_case.create_case_cisu_converter import ( CreateCaseCISUConverter, ) from tests.cisu.helpers import get_edxl_message @@ -89,8 +89,8 @@ class TestSnapshotCreateCaseConverter: edxl_envelope_fire_to_health_path = TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH fixtures_folder_path = "tests/fixtures/" - @patch("converter.cisu.create_case.create_case_cisu_converter.datetime") - @patch("converter.cisu.create_case.create_case_cisu_converter.random") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.datetime") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.random") def test_snapshot_RS_EDA_exhaustive_message(self, mock_choices, mock_now, snapshot): mock_now.now.return_value = datetime(2024, 2, 10, 12, 34, 56) mock_now.strftime = datetime.strftime @@ -106,7 +106,7 @@ def test_snapshot_RS_EDA_exhaustive_message(self, mock_choices, mock_now, snapsh output_data = converter.from_rs_to_cisu(message) assert json.dumps(output_data, indent=2) == snapshot - @patch("converter.cisu.create_case.create_case_cisu_converter.random") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.random") def test_snapshot_RC_EDA_exhaustive_message(self, mock_choices, snapshot): mock_choices.choices.side_effect = ["f5de7hj", "a3b2YH8", "c9d8jk9", "he9i0kz"] @@ -119,8 +119,8 @@ def test_snapshot_RC_EDA_exhaustive_message(self, mock_choices, snapshot): output_data = converter.from_cisu_to_rs(message) assert json.dumps(output_data, indent=2) == snapshot - @patch("converter.cisu.create_case.create_case_cisu_converter.datetime") - @patch("converter.cisu.create_case.create_case_cisu_converter.random") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.datetime") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.random") def test_snapshot_RS_EDA_required_field_message( self, mock_choices, mock_now, snapshot ): @@ -138,7 +138,7 @@ def test_snapshot_RS_EDA_required_field_message( output_data = converter.from_rs_to_cisu(message) assert json.dumps(output_data, indent=2) == snapshot - @patch("converter.cisu.create_case.create_case_cisu_converter.random") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.random") def test_snapshot_RC_EDA_required_field_message(self, mock_choices, snapshot): mock_choices.choices.side_effect = ["f5de7hj", "a3b2YH8", "c9d8jk9", "he9i0kz"] @@ -152,8 +152,8 @@ def test_snapshot_RC_EDA_required_field_message(self, mock_choices, snapshot): assert json.dumps(output_data, indent=2) == snapshot - @patch("converter.cisu.create_case.create_case_cisu_converter.datetime") - @patch("converter.cisu.create_case.create_case_cisu_converter.random") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.datetime") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.random") def test_snapshot_RS_EDA_exhaustive_bis_message( self, mock_choices, mock_now, snapshot ): @@ -173,7 +173,7 @@ def test_snapshot_RS_EDA_exhaustive_bis_message( assert json.dumps(output_data, indent=2) == snapshot - @patch("converter.cisu.create_case.create_case_cisu_converter.random") + @patch("converter.cisu_transcoders.create_case.create_case_cisu_converter.random") def test_snapshot_RC_EDA_exhaustive_bis_message(self, mock_choices, snapshot): mock_choices.choices.side_effect = ["f5de7hj", "a3b2YH8", "c9d8jk9", "he9i0kz"] diff --git a/converter/tests/cisu/test_identical_cisu_converter.py b/converter/tests/cisu/test_identical_cisu_converter.py index 98bf09763a..da63096231 100644 --- a/converter/tests/cisu/test_identical_cisu_converter.py +++ b/converter/tests/cisu/test_identical_cisu_converter.py @@ -1,4 +1,4 @@ -from converter.cisu.identical_cisu_converter import IdenticalCISUConverter +from converter.cisu_transcoders.identical_cisu_converter import IdenticalCISUConverter mock_message = {"message": {"content": "This is a mock CISU message.", "status": "200"}} diff --git a/converter/tests/cisu/test_reference_converter.py b/converter/tests/cisu/test_reference_converter.py index 67849d8cbe..656ea415d1 100644 --- a/converter/tests/cisu/test_reference_converter.py +++ b/converter/tests/cisu/test_reference_converter.py @@ -1,5 +1,5 @@ import json -from converter.cisu.reference.reference_converter import ReferenceConverter +from converter.cisu_transcoders.reference.reference_converter import ReferenceConverter from tests.constants import TestConstants from tests.test_helpers import TestHelper diff --git a/converter/tests/cisu/test_resources_info_cisu_helper.py b/converter/tests/cisu/test_resources_info_cisu_helper.py index 03e157aeff..842cdc91bd 100644 --- a/converter/tests/cisu/test_resources_info_cisu_helper.py +++ b/converter/tests/cisu/test_resources_info_cisu_helper.py @@ -1,4 +1,4 @@ -from converter.cisu.resources_info.resources_info_cisu_helper import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_helper import ( enrich_rs_ri_with_rs_srs, log_cisu_to_rs_converted_messages_ids, ) diff --git a/converter/tests/cisu/test_resources_info_converter.py b/converter/tests/cisu/test_resources_info_converter.py index 5098d180c6..d7e81850c9 100644 --- a/converter/tests/cisu/test_resources_info_converter.py +++ b/converter/tests/cisu/test_resources_info_converter.py @@ -4,7 +4,7 @@ import pytest -from converter.cisu.resources_info.resources_info_cisu_converter import ( +from converter.cisu_transcoders.resources_info.resources_info_cisu_converter import ( ConversionError, ResourcesInfoCISUConverter, ) @@ -23,8 +23,8 @@ RS_RI_SCHEMA = TestHelper.load_schema("RS-RI.schema.json") -_PATCH_GET_LAST_RC_RI_BY_CASE_ID = "converter.cisu.resources_info.resources_info_cisu_converter.get_last_rc_ri_by_case_id" -_PATCH_GET_RS_MESSAGES_BY_CASE_ID = "converter.cisu.resources_info.resources_info_cisu_converter.get_rs_messages_by_case_id" +_PATCH_GET_LAST_RC_RI_BY_CASE_ID = "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.get_last_rc_ri_by_case_id" +_PATCH_GET_RS_MESSAGES_BY_CASE_ID = "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.get_rs_messages_by_case_id" # These usecases does not contain the minimal infomations to trigger # the traduction of a valid RC-RI (no state on resource). @@ -145,7 +145,7 @@ def test_cisu_to_rs_breaking_changes(): "tests/fixtures/RC-RI/RC-RI_V3.0_exhaustive_fill.json", ) with patch( - "converter.cisu.resources_info.resources_info_cisu_converter.get_last_rc_ri_by_case_id", + "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.get_last_rc_ri_by_case_id", return_value=None, ): results = ResourcesInfoCISUConverter.from_cisu_to_rs(cisu_raw_message) diff --git a/converter/tests/cisu/test_resources_status_converter.py b/converter/tests/cisu/test_resources_status_converter.py index 28e82d8af8..c4e40a194b 100644 --- a/converter/tests/cisu/test_resources_status_converter.py +++ b/converter/tests/cisu/test_resources_status_converter.py @@ -1,7 +1,7 @@ import pytest from unittest.mock import patch -from converter.cisu.resources_status.resources_status_converter import ( +from converter.cisu_transcoders.resources_status.resources_status_converter import ( ResourcesStatusConverter, ) from tests.cisu.helpers import ( @@ -15,7 +15,7 @@ _RESOURCE_ID_1 = "fr.fire.sis076.cgo-076.resource.VLM1" _RESOURCE_ID_2 = "fr.fire.sis076.cgo-076.resource.VLM2" -_PATCH_GET_RS_MESSAGES = "converter.cisu.resources_status.resources_status_converter.get_rs_messages_by_case_id" +_PATCH_GET_RS_MESSAGES = "converter.cisu_transcoders.resources_status.resources_status_converter.get_rs_messages_by_case_id" def test_from_rs_to_cisu_real_data(): diff --git a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py index a113330cbc..d4c63e5579 100644 --- a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py @@ -1,7 +1,7 @@ import unittest from unittest.mock import patch -from converter.cisu.constants import CISUConstants +from converter.cisu_transcoders.constants import CISUConstants from converter.conversion_strategy.cisu_conversion_strategy import ( cisu_conversion_strategy, compute_message_direction, @@ -48,7 +48,7 @@ def run_rs_to_cisu_conversion_strategy(message_type: str) -> None: cisu_conversion_strategy(edxl_json, source_version, target_version) @patch( - "converter.cisu.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_rs_to_cisu" + "converter.cisu_transcoders.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_rs_to_cisu" ) def test_rs_to_cisu_conversion_strategy_should_convert_create_case_message( self, mock_convert @@ -57,7 +57,7 @@ def test_rs_to_cisu_conversion_strategy_should_convert_create_case_message( mock_convert.assert_called_once() @patch( - "converter.cisu.resources_info.resources_info_cisu_converter.ResourcesInfoCISUConverter.from_rs_to_cisu" + "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.ResourcesInfoCISUConverter.from_rs_to_cisu" ) def test_rs_to_cisu_conversion_strategy_should_convert_resources_info_message( self, mock_convert @@ -66,7 +66,7 @@ def test_rs_to_cisu_conversion_strategy_should_convert_resources_info_message( mock_convert.assert_called_once() @patch( - "converter.cisu.reference.reference_converter.ReferenceConverter.from_rs_to_cisu" + "converter.cisu_transcoders.reference.reference_converter.ReferenceConverter.from_rs_to_cisu" ) def test_rs_to_cisu_conversion_strategy_should_convert_reference_message( self, mock_convert @@ -86,7 +86,7 @@ def run_cisu_to_rs_conversion_strategy(message_type: str) -> None: cisu_conversion_strategy(edxl_json, source_version, target_version) @patch( - "converter.cisu.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_cisu_to_rs" + "converter.cisu_transcoders.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_cisu_to_rs" ) @patch( "converter.conversion_strategy.cisu_conversion_strategy.health_conversion_strategy" @@ -99,7 +99,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_create_case_message( mock_health_convert_strategy.assert_called_once() @patch( - "converter.cisu.resources_info.resources_info_cisu_converter.ResourcesInfoCISUConverter.from_cisu_to_rs" + "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.ResourcesInfoCISUConverter.from_cisu_to_rs" ) @patch( "converter.conversion_strategy.cisu_conversion_strategy.health_conversion_strategy" @@ -112,7 +112,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_resources_info_message( mock_health_convert_strategy.assert_called_once() @patch( - "converter.cisu.reference.reference_converter.ReferenceConverter.from_cisu_to_rs" + "converter.cisu_transcoders.reference.reference_converter.ReferenceConverter.from_cisu_to_rs" ) @patch( "converter.conversion_strategy.cisu_conversion_strategy.health_conversion_strategy" @@ -125,7 +125,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_reference_message( mock_health_convert_strategy.assert_called_once() @patch( - "converter.cisu.resources_info.resources_info_cisu_converter.get_last_rc_ri_by_case_id", + "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.get_last_rc_ri_by_case_id", return_value=None, ) @patch( diff --git a/converter/tests/conversion_strategy/test_health_conversion_strategy.py b/converter/tests/conversion_strategy/test_health_conversion_strategy.py index 49d3dcb8d1..d824374873 100644 --- a/converter/tests/conversion_strategy/test_health_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_health_conversion_strategy.py @@ -47,7 +47,7 @@ def run_health_conversion_strategy(message_type: str) -> Tuple[str, str, Dict]: return source_version, target_version, edxl_json @patch( - "converter.versions.create_case_health.create_case_health_converter.CreateHealthCaseConverter.convert" + "converter.health_version_converters.create_case_health.create_case_health_converter.CreateHealthCaseConverter.convert" ) def test_health_conversion_strategy_should_convert_create_case_health_message( self, mock_convert @@ -56,7 +56,7 @@ def test_health_conversion_strategy_should_convert_create_case_health_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.create_case_health.create_case_health_update_converter.CreateHealthUpdateCaseConverter.convert" + "converter.health_version_converters.create_case_health.create_case_health_update_converter.CreateHealthUpdateCaseConverter.convert" ) def test_health_conversion_strategy_should_convert_create_case_health_update_message( self, mock_convert @@ -65,7 +65,7 @@ def test_health_conversion_strategy_should_convert_create_case_health_update_mes mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.reference.reference_converter.ReferenceConverter.convert" + "converter.health_version_converters.reference.reference_converter.ReferenceConverter.convert" ) def test_health_conversion_strategy_should_convert_reference_message( self, mock_convert @@ -73,7 +73,7 @@ def test_health_conversion_strategy_should_convert_reference_message( args = self.run_health_conversion_strategy(TestConstants.RC_REF_TAG) mock_convert.assert_called_once_with(*args) - @patch("converter.versions.error_converter.ErrorConverter.convert") + @patch("converter.health_version_converters.error_converter.ErrorConverter.convert") def test_health_conversion_strategy_should_convert_error_message( self, mock_convert ): @@ -81,7 +81,7 @@ def test_health_conversion_strategy_should_convert_error_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.resources_status.resources_status_converter.ResourcesStatusConverter.convert" + "converter.health_version_converters.resources_status.resources_status_converter.ResourcesStatusConverter.convert" ) def test_health_conversion_strategy_should_convert_resources_status_message( self, mock_convert @@ -90,7 +90,7 @@ def test_health_conversion_strategy_should_convert_resources_status_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.resources_info.resources_info_converter.ResourcesInfoConverter.convert" + "converter.health_version_converters.resources_info.resources_info_converter.ResourcesInfoConverter.convert" ) def test_health_conversion_strategy_should_convert_resources_info_message( self, mock_convert @@ -99,7 +99,7 @@ def test_health_conversion_strategy_should_convert_resources_info_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.resources_response.resources_response_converter.ResourcesResponseConverter.convert" + "converter.health_version_converters.resources_response.resources_response_converter.ResourcesResponseConverter.convert" ) def test_health_conversion_strategy_should_convert_resources_response_message( self, mock_convert @@ -108,7 +108,7 @@ def test_health_conversion_strategy_should_convert_resources_response_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.resources_request.resources_request_converter.ResourcesRequestConverter.convert" + "converter.health_version_converters.resources_request.resources_request_converter.ResourcesRequestConverter.convert" ) def test_health_conversion_strategy_should_convert_resources_request_message( self, mock_convert @@ -117,7 +117,7 @@ def test_health_conversion_strategy_should_convert_resources_request_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.resources_engagement.resources_engagement_converter.ResourcesEngagementConverter.convert" + "converter.health_version_converters.resources_engagement.resources_engagement_converter.ResourcesEngagementConverter.convert" ) def test_health_conversion_strategy_should_convert_resources_engagement_message( self, mock_convert @@ -126,7 +126,7 @@ def test_health_conversion_strategy_should_convert_resources_engagement_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.geo_positions_update.geo_positions_update_converter.GeoPositionsUpdateConverter.convert" + "converter.health_version_converters.geo_positions_update.geo_positions_update_converter.GeoPositionsUpdateConverter.convert" ) def test_health_conversion_strategy_should_convert_geo_positions_update_message( self, mock_convert @@ -135,7 +135,7 @@ def test_health_conversion_strategy_should_convert_geo_positions_update_message( mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.identical_message_converter.IdenticalMessageConverter.convert" + "converter.health_version_converters.identical_message_converter.IdenticalMessageConverter.convert" ) def test_health_conversion_strategy_should_convert_geo_resources_requests_message( self, mock_convert @@ -144,7 +144,7 @@ def test_health_conversion_strategy_should_convert_geo_resources_requests_messag mock_convert.assert_called_once_with(*args) @patch( - "converter.versions.geo_resources_details.geo_resources_details_converter.GeoResourcesDetailsConverter.convert" + "converter.health_version_converters.geo_resources_details.geo_resources_details_converter.GeoResourcesDetailsConverter.convert" ) def test_health_conversion_strategy_should_convert_geo_resources_details_message( self, mock_convert diff --git a/converter/tests/versions/create_health_case/test_v1_v2_converter.py b/converter/tests/versions/create_health_case/test_v1_v2_converter.py index 68c0e720fb..7b433523f8 100644 --- a/converter/tests/versions/create_health_case/test_v1_v2_converter.py +++ b/converter/tests/versions/create_health_case/test_v1_v2_converter.py @@ -4,7 +4,7 @@ import pytest from converter.utils import get_field_value, extract_message_content -from converter.versions.create_case_health.create_case_health_converter import ( +from converter.health_version_converters.create_case_health.create_case_health_converter import ( CreateHealthCaseConverter, ) from tests.constants import TestConstants @@ -79,7 +79,9 @@ def test_snapshot_V1_to_V2_upgrade(self, mock_choices, snapshot): assert json.dumps(output_data, indent=2) == snapshot - @patch("converter.versions.create_case_health.v1_v2.utils.datetime") + @patch( + "converter.health_version_converters.create_case_health.v1_v2.utils.datetime" + ) @patch("converter.utils.random") def test_snapshot_V2_to_V1_downgrade(self, mock_choices, mock_datetime, snapshot): mock_choices.choices.side_effect = [ diff --git a/converter/tests/versions/create_health_case/test_v1_v2_utils.py b/converter/tests/versions/create_health_case/test_v1_v2_utils.py index a80a74b035..e3ee3ca91e 100644 --- a/converter/tests/versions/create_health_case/test_v1_v2_utils.py +++ b/converter/tests/versions/create_health_case/test_v1_v2_utils.py @@ -1,16 +1,20 @@ import unittest from unittest.mock import patch -from converter.versions.create_case_health.v1_v2.utils import validate_diagnosis_code +from converter.health_version_converters.create_case_health.v1_v2.utils import ( + validate_diagnosis_code, +) -from converter.versions.create_case_health.v1_v2.utils import ( +from converter.health_version_converters.create_case_health.v1_v2.utils import ( update_language, get_field_value, set_value, ) -from converter.versions.create_case_health.constants import Constants +from converter.health_version_converters.create_case_health.constants import Constants -from converter.versions.create_case_health.v1_v2.utils import add_to_initial_alert_notes +from converter.health_version_converters.create_case_health.v1_v2.utils import ( + add_to_initial_alert_notes, +) class TestValidateDiagnosisCode(unittest.TestCase): diff --git a/converter/tests/versions/create_health_case/test_v2_v3_converter.py b/converter/tests/versions/create_health_case/test_v2_v3_converter.py index 1c2d72c1cf..9bf7aaf244 100644 --- a/converter/tests/versions/create_health_case/test_v2_v3_converter.py +++ b/converter/tests/versions/create_health_case/test_v2_v3_converter.py @@ -1,6 +1,6 @@ import json from unittest.mock import patch -from converter.versions.create_case_health.create_case_health_converter import ( +from converter.health_version_converters.create_case_health.create_case_health_converter import ( CreateHealthCaseConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_geo_positions_update_converter.py b/converter/tests/versions/test_geo_positions_update_converter.py index 17ba7238b5..7a9d637846 100644 --- a/converter/tests/versions/test_geo_positions_update_converter.py +++ b/converter/tests/versions/test_geo_positions_update_converter.py @@ -1,4 +1,4 @@ -from converter.versions.geo_positions_update.geo_positions_update_converter import ( +from converter.health_version_converters.geo_positions_update.geo_positions_update_converter import ( GeoPositionsUpdateConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_geo_resources_details_converter.py b/converter/tests/versions/test_geo_resources_details_converter.py index 841db977ea..0bc50ef2db 100644 --- a/converter/tests/versions/test_geo_resources_details_converter.py +++ b/converter/tests/versions/test_geo_resources_details_converter.py @@ -1,4 +1,4 @@ -from converter.versions.geo_resources_details.geo_resources_details_converter import ( +from converter.health_version_converters.geo_resources_details.geo_resources_details_converter import ( GeoResourcesDetailsConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_geo_resources_request_converter.py b/converter/tests/versions/test_geo_resources_request_converter.py index 51051fe716..6fb1665f62 100644 --- a/converter/tests/versions/test_geo_resources_request_converter.py +++ b/converter/tests/versions/test_geo_resources_request_converter.py @@ -1,4 +1,6 @@ -from converter.versions.identical_message_converter import IdenticalMessageConverter +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) from tests.constants import TestConstants from tests.test_helpers import TestHelper, get_file_endpoint diff --git a/converter/tests/versions/test_identical_converter.py b/converter/tests/versions/test_identical_converter.py index 5324237cfa..0a53aab80d 100644 --- a/converter/tests/versions/test_identical_converter.py +++ b/converter/tests/versions/test_identical_converter.py @@ -1,5 +1,7 @@ import pytest -from converter.versions.identical_message_converter import IdenticalMessageConverter +from converter.health_version_converters.identical_message_converter import ( + IdenticalMessageConverter, +) mock_message = {"error": {"code": 500}} test_cases = [ diff --git a/converter/tests/versions/test_reference_converter.py b/converter/tests/versions/test_reference_converter.py index 9ba149855f..66830d9d43 100644 --- a/converter/tests/versions/test_reference_converter.py +++ b/converter/tests/versions/test_reference_converter.py @@ -1,5 +1,7 @@ import json -from converter.versions.reference.reference_converter import ReferenceConverter +from converter.health_version_converters.reference.reference_converter import ( + ReferenceConverter, +) from tests.constants import TestConstants from tests.test_helpers import TestHelper diff --git a/converter/tests/versions/test_resources_engagement_converter.py b/converter/tests/versions/test_resources_engagement_converter.py index b65693308e..eb60c7657e 100644 --- a/converter/tests/versions/test_resources_engagement_converter.py +++ b/converter/tests/versions/test_resources_engagement_converter.py @@ -1,4 +1,4 @@ -from converter.versions.resources_engagement.resources_engagement_converter import ( +from converter.health_version_converters.resources_engagement.resources_engagement_converter import ( ResourcesEngagementConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_resources_info_converter.py b/converter/tests/versions/test_resources_info_converter.py index 3fca9583e3..2122f80091 100644 --- a/converter/tests/versions/test_resources_info_converter.py +++ b/converter/tests/versions/test_resources_info_converter.py @@ -1,5 +1,5 @@ import json -from converter.versions.resources_info.resources_info_converter import ( +from converter.health_version_converters.resources_info.resources_info_converter import ( ResourcesInfoConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_resources_request_converter.py b/converter/tests/versions/test_resources_request_converter.py index 6806e8f22d..4ac5c44a0c 100644 --- a/converter/tests/versions/test_resources_request_converter.py +++ b/converter/tests/versions/test_resources_request_converter.py @@ -1,5 +1,5 @@ import json -from converter.versions.resources_request.resources_request_converter import ( +from converter.health_version_converters.resources_request.resources_request_converter import ( ResourcesRequestConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_resources_response_converter.py b/converter/tests/versions/test_resources_response_converter.py index cad5304ce1..83d590b3b6 100644 --- a/converter/tests/versions/test_resources_response_converter.py +++ b/converter/tests/versions/test_resources_response_converter.py @@ -1,5 +1,5 @@ import json -from converter.versions.resources_response.resources_response_converter import ( +from converter.health_version_converters.resources_response.resources_response_converter import ( ResourcesResponseConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_resources_status_converter.py b/converter/tests/versions/test_resources_status_converter.py index 3c3b9f0ffb..c3706eb5b0 100644 --- a/converter/tests/versions/test_resources_status_converter.py +++ b/converter/tests/versions/test_resources_status_converter.py @@ -1,5 +1,5 @@ import json -from converter.versions.resources_status.resources_status_converter import ( +from converter.health_version_converters.resources_status.resources_status_converter import ( ResourcesStatusConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_rs_eda_maj_converter.py b/converter/tests/versions/test_rs_eda_maj_converter.py index 85fbe6e1ca..3a266e80db 100644 --- a/converter/tests/versions/test_rs_eda_maj_converter.py +++ b/converter/tests/versions/test_rs_eda_maj_converter.py @@ -1,4 +1,4 @@ -from converter.versions.create_case_health.create_case_health_update_converter import ( +from converter.health_version_converters.create_case_health.create_case_health_update_converter import ( CreateHealthUpdateCaseConverter, ) from tests.constants import TestConstants diff --git a/converter/tests/versions/test_utils.py b/converter/tests/versions/test_utils.py index a25643a0f3..1510151ee5 100644 --- a/converter/tests/versions/test_utils.py +++ b/converter/tests/versions/test_utils.py @@ -1,6 +1,6 @@ import unittest -from converter.versions.utils import ( +from converter.health_version_converters.utils import ( reverse_map_to_new_value, ) From 741dbe80d3b90c9e7d1da82d88bf1b9d78cab1a2 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 14:51:07 +0200 Subject: [PATCH 02/27] feat(converter): add ConversionType enum --- converter/converter/constants.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/converter/converter/constants.py b/converter/converter/constants.py index 285158529e..7600537590 100644 --- a/converter/converter/constants.py +++ b/converter/converter/constants.py @@ -1,3 +1,6 @@ +from enum import Enum + + class Constants: FR_HEALTH_PREFIX = "fr.health" @@ -17,3 +20,9 @@ class Constants: } MEDICAL_NOTE_RANDOM_ID_LENGTH = 7 + + +class ConversionType(Enum): + CISUVersionConversion = "CISUVersionConversion" + HealthVersionConversion = "HealthVersionConversion" + CISUTranscoding = "CISUTranscoding" From f39fb5c813b3ec2dd8cbc7f3dbdcc830aebc4823 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 14:59:49 +0200 Subject: [PATCH 03/27] refactor(converter): change cisu_conversion_strategy to cisu_transcoding_strategy --- ...rategy.py => cisu_transcoding_strategy.py} | 2 +- .../conversion_strategy.py | 6 +-- .../test_cisu_conversion_strategy.py | 44 +++++++++---------- .../test_conversion_strategy.py | 8 ++-- 4 files changed, 31 insertions(+), 29 deletions(-) rename converter/converter/conversion_strategy/{cisu_conversion_strategy.py => cisu_transcoding_strategy.py} (98%) diff --git a/converter/converter/conversion_strategy/cisu_conversion_strategy.py b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py similarity index 98% rename from converter/converter/conversion_strategy/cisu_conversion_strategy.py rename to converter/converter/conversion_strategy/cisu_transcoding_strategy.py index da34c0a51d..21c0d07b2c 100644 --- a/converter/converter/conversion_strategy/cisu_conversion_strategy.py +++ b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py @@ -25,7 +25,7 @@ logger = logging.getLogger(__name__) -def cisu_conversion_strategy(edxl_json, source_version, target_version): +def cisu_transcoding_strategy(edxl_json, source_version, target_version): logger.info(f"CISU Conversion initiated from {source_version} to {target_version}") direction = compute_message_direction(edxl_json) diff --git a/converter/converter/conversion_strategy/conversion_strategy.py b/converter/converter/conversion_strategy/conversion_strategy.py index 6842b72647..8a82b1532d 100644 --- a/converter/converter/conversion_strategy/conversion_strategy.py +++ b/converter/converter/conversion_strategy/conversion_strategy.py @@ -1,8 +1,8 @@ from converter.conversion_strategy.health_conversion_strategy import ( health_conversion_strategy, ) -from converter.conversion_strategy.cisu_conversion_strategy import ( - cisu_conversion_strategy, +from converter.conversion_strategy.cisu_transcoding_strategy import ( + cisu_transcoding_strategy, ) @@ -10,7 +10,7 @@ def conversion_strategy( edxl_json, source_version: str, target_version: str, is_cisu_conversion: bool ) -> list: if is_cisu_conversion: - converted_edxl = cisu_conversion_strategy( + converted_edxl = cisu_transcoding_strategy( edxl_json, source_version, target_version ) else: diff --git a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py index d4c63e5579..67d7205aca 100644 --- a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py @@ -2,8 +2,8 @@ from unittest.mock import patch from converter.cisu_transcoders.constants import CISUConstants -from converter.conversion_strategy.cisu_conversion_strategy import ( - cisu_conversion_strategy, +from converter.conversion_strategy.cisu_transcoding_strategy import ( + cisu_transcoding_strategy, compute_message_direction, ) from tests.constants import TestConstants @@ -11,7 +11,7 @@ class TestCisuConversionStrategy(unittest.TestCase): - def test_cisu_conversion_strategy_raise_error_when_converting_unsupported_message_type( + def test_cisu_transcoding_strategy_raise_error_when_converting_unsupported_message_type( self, ): edxl_json = { @@ -34,10 +34,10 @@ def test_cisu_conversion_strategy_raise_error_when_converting_unsupported_messag ValueError, "Perimeter translation for message type 'notSupportedMessageType' is not implemented.", ): - cisu_conversion_strategy(edxl_json, source_version, target_version) + cisu_transcoding_strategy(edxl_json, source_version, target_version) @staticmethod - def run_rs_to_cisu_conversion_strategy(message_type: str) -> None: + def run_rs_to_cisu_transcoding_strategy(message_type: str) -> None: message_json_path = TestHelper.get_json_files(message_type)[0]["path"] edxl_json = TestHelper.create_edxl_json_from_sample( TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH, message_json_path @@ -45,33 +45,33 @@ def run_rs_to_cisu_conversion_strategy(message_type: str) -> None: source_version = "v1" target_version = "v3" - cisu_conversion_strategy(edxl_json, source_version, target_version) + cisu_transcoding_strategy(edxl_json, source_version, target_version) @patch( "converter.cisu_transcoders.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_rs_to_cisu" ) - def test_rs_to_cisu_conversion_strategy_should_convert_create_case_message( + def test_rs_to_cisu_transcoding_strategy_should_convert_create_case_message( self, mock_convert ): - self.run_rs_to_cisu_conversion_strategy(TestConstants.RS_EDA_TAG) + self.run_rs_to_cisu_transcoding_strategy(TestConstants.RS_EDA_TAG) mock_convert.assert_called_once() @patch( "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.ResourcesInfoCISUConverter.from_rs_to_cisu" ) - def test_rs_to_cisu_conversion_strategy_should_convert_resources_info_message( + def test_rs_to_cisu_transcoding_strategy_should_convert_resources_info_message( self, mock_convert ): - self.run_rs_to_cisu_conversion_strategy(TestConstants.RS_RI_TAG) + self.run_rs_to_cisu_transcoding_strategy(TestConstants.RS_RI_TAG) mock_convert.assert_called_once() @patch( "converter.cisu_transcoders.reference.reference_converter.ReferenceConverter.from_rs_to_cisu" ) - def test_rs_to_cisu_conversion_strategy_should_convert_reference_message( + def test_rs_to_cisu_transcoding_strategy_should_convert_reference_message( self, mock_convert ): - self.run_rs_to_cisu_conversion_strategy(TestConstants.RC_REF_TAG) + self.run_rs_to_cisu_transcoding_strategy(TestConstants.RC_REF_TAG) mock_convert.assert_called_once() @staticmethod @@ -83,13 +83,13 @@ def run_cisu_to_rs_conversion_strategy(message_type: str) -> None: source_version = "v3" target_version = "v3" - cisu_conversion_strategy(edxl_json, source_version, target_version) + cisu_transcoding_strategy(edxl_json, source_version, target_version) @patch( "converter.cisu_transcoders.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_cisu_to_rs" ) @patch( - "converter.conversion_strategy.cisu_conversion_strategy.health_conversion_strategy" + "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy" ) def test_cisu_to_rs_conversion_strategy_should_convert_create_case_message( self, mock_health_convert_strategy, mock_convert @@ -102,7 +102,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_create_case_message( "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.ResourcesInfoCISUConverter.from_cisu_to_rs" ) @patch( - "converter.conversion_strategy.cisu_conversion_strategy.health_conversion_strategy" + "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy" ) def test_cisu_to_rs_conversion_strategy_should_convert_resources_info_message( self, mock_health_convert_strategy, mock_convert @@ -115,7 +115,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_resources_info_message( "converter.cisu_transcoders.reference.reference_converter.ReferenceConverter.from_cisu_to_rs" ) @patch( - "converter.conversion_strategy.cisu_conversion_strategy.health_conversion_strategy" + "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy" ) def test_cisu_to_rs_conversion_strategy_should_convert_reference_message( self, mock_health_convert_strategy, mock_convert @@ -129,13 +129,13 @@ def test_cisu_to_rs_conversion_strategy_should_convert_reference_message( return_value=None, ) @patch( - "converter.conversion_strategy.cisu_conversion_strategy.health_conversion_strategy", + "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy", side_effect=lambda msg, *_: msg, ) def test_cisu_to_rs_resources_info_returns_list( self, mock_health_convert_strategy, mock_repo ): - """cisu_conversion_strategy must return a list when from_cisu_to_rs produces multiple messages.""" + """cisu_transcoding_strategy must return a list when from_cisu_to_rs produces multiple messages.""" message_json_path = TestHelper.get_json_files(TestConstants.RC_RI_TAG)[0][ "path" ] @@ -143,7 +143,7 @@ def test_cisu_to_rs_resources_info_returns_list( TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, message_json_path ) - result = cisu_conversion_strategy( + result = cisu_transcoding_strategy( edxl_json, CISUConstants.MAINTAINED_CISU_VERSION, "v3" ) @@ -151,7 +151,7 @@ def test_cisu_to_rs_resources_info_returns_list( # health_conversion_strategy must be called once per produced message assert mock_health_convert_strategy.call_count == len(result) - def test_rs_to_cisu_conversion_strategy_should_raise_error_with_invalid_target_version( + def test_rs_to_cisu_transcoding_strategy_should_raise_error_with_invalid_target_version( self, ): message_json_path = TestHelper.get_json_files(TestConstants.RS_EDA_TAG)[0][ @@ -166,7 +166,7 @@ def test_rs_to_cisu_conversion_strategy_should_raise_error_with_invalid_target_v ValueError, "Unknown target version v1. Must be: v3", ): - cisu_conversion_strategy(edxl_json, "v1", invalid_target_version) + cisu_transcoding_strategy(edxl_json, "v1", invalid_target_version) def test_cisu_to_rs_conversion_strategy_should_raise_error_with_invalid_source_version( self, @@ -183,7 +183,7 @@ def test_cisu_to_rs_conversion_strategy_should_raise_error_with_invalid_source_v ValueError, "Unknown source version v1. Must be: v3", ): - cisu_conversion_strategy(edxl_json, invalid_source_version, "v1") + cisu_transcoding_strategy(edxl_json, invalid_source_version, "v1") class TestComputeMessageDirection(unittest.TestCase): diff --git a/converter/tests/conversion_strategy/test_conversion_strategy.py b/converter/tests/conversion_strategy/test_conversion_strategy.py index 828c889338..b8323ee125 100644 --- a/converter/tests/conversion_strategy/test_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_conversion_strategy.py @@ -4,9 +4,11 @@ class TestConversionStrategy(unittest.TestCase): - @patch("converter.conversion_strategy.conversion_strategy.cisu_conversion_strategy") + @patch( + "converter.conversion_strategy.conversion_strategy.cisu_transcoding_strategy" + ) def test_conversion_strategy_with_cisu_conversion( - self, mock_cisu_conversion_strategy + self, mock_cisu_transcoding_strategy ): edxl_json = {} source_version = "source_version" @@ -17,7 +19,7 @@ def test_conversion_strategy_with_cisu_conversion( edxl_json, source_version, target_version, is_cisu_conversion ) - mock_cisu_conversion_strategy.assert_called_once_with( + mock_cisu_transcoding_strategy.assert_called_once_with( edxl_json, source_version, target_version ) From 08b3065442c25d0e737a6e6eb1d718ee9c994d9d Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 15:03:23 +0200 Subject: [PATCH 04/27] refactor(converter): change health_conversion_strategy to health_version_conversion_strategy --- .../cisu_transcoding_strategy.py | 8 +-- .../conversion_strategy.py | 6 +- ... => health_version_conversion_strategy.py} | 4 +- .../test_cisu_conversion_strategy.py | 10 +-- .../test_conversion_strategy.py | 18 +++--- .../test_health_conversion_strategy.py | 64 ++++++++++--------- 6 files changed, 58 insertions(+), 52 deletions(-) rename converter/converter/conversion_strategy/{health_conversion_strategy.py => health_version_conversion_strategy.py} (97%) diff --git a/converter/converter/conversion_strategy/cisu_transcoding_strategy.py b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py index 21c0d07b2c..9de96ea489 100644 --- a/converter/converter/conversion_strategy/cisu_transcoding_strategy.py +++ b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py @@ -12,8 +12,8 @@ ) from converter.constants import Constants from converter.cisu_transcoders.constants import CISUConstants -from converter.conversion_strategy.health_conversion_strategy import ( - health_conversion_strategy, +from converter.conversion_strategy.health_version_conversion_strategy import ( + health_version_conversion_strategy, ) from converter.utils import ( get_recipient, @@ -41,7 +41,7 @@ def cisu_transcoding_strategy(edxl_json, source_version, target_version): f"Unknown target version {target_version}. Must be: {CISUConstants.MAINTAINED_CISU_VERSION}" ) - rs_json_message = health_conversion_strategy( + rs_json_message = health_version_conversion_strategy( edxl_json, source_version, CISUConstants.MAINTAINED_CISU_VERSION ) @@ -59,7 +59,7 @@ def cisu_transcoding_strategy(edxl_json, source_version, target_version): if not isinstance(rc_json_messages, list): rc_json_messages = [rc_json_messages] return [ - health_conversion_strategy( + health_version_conversion_strategy( msg, CISUConstants.MAINTAINED_CISU_VERSION, target_version ) for msg in rc_json_messages diff --git a/converter/converter/conversion_strategy/conversion_strategy.py b/converter/converter/conversion_strategy/conversion_strategy.py index 8a82b1532d..aef3944a0d 100644 --- a/converter/converter/conversion_strategy/conversion_strategy.py +++ b/converter/converter/conversion_strategy/conversion_strategy.py @@ -1,5 +1,5 @@ -from converter.conversion_strategy.health_conversion_strategy import ( - health_conversion_strategy, +from converter.conversion_strategy.health_version_conversion_strategy import ( + health_version_conversion_strategy, ) from converter.conversion_strategy.cisu_transcoding_strategy import ( cisu_transcoding_strategy, @@ -14,7 +14,7 @@ def conversion_strategy( edxl_json, source_version, target_version ) else: - converted_edxl = health_conversion_strategy( + converted_edxl = health_version_conversion_strategy( edxl_json, source_version, target_version ) return converted_edxl if isinstance(converted_edxl, list) else [converted_edxl] diff --git a/converter/converter/conversion_strategy/health_conversion_strategy.py b/converter/converter/conversion_strategy/health_version_conversion_strategy.py similarity index 97% rename from converter/converter/conversion_strategy/health_conversion_strategy.py rename to converter/converter/conversion_strategy/health_version_conversion_strategy.py index 2de7a8f5c3..7283085c01 100644 --- a/converter/converter/conversion_strategy/health_conversion_strategy.py +++ b/converter/converter/conversion_strategy/health_version_conversion_strategy.py @@ -40,7 +40,9 @@ ) -def health_conversion_strategy(edxl_json, source_version: str, target_version: str): +def health_version_conversion_strategy( + edxl_json, source_version: str, target_version: str +): logging.info( f"Health Conversion initiated from {source_version} to {target_version}" ) diff --git a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py index 67d7205aca..e32f661c0a 100644 --- a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py @@ -89,7 +89,7 @@ def run_cisu_to_rs_conversion_strategy(message_type: str) -> None: "converter.cisu_transcoders.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_cisu_to_rs" ) @patch( - "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy" + "converter.conversion_strategy.cisu_transcoding_strategy.health_version_conversion_strategy" ) def test_cisu_to_rs_conversion_strategy_should_convert_create_case_message( self, mock_health_convert_strategy, mock_convert @@ -102,7 +102,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_create_case_message( "converter.cisu_transcoders.resources_info.resources_info_cisu_converter.ResourcesInfoCISUConverter.from_cisu_to_rs" ) @patch( - "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy" + "converter.conversion_strategy.cisu_transcoding_strategy.health_version_conversion_strategy" ) def test_cisu_to_rs_conversion_strategy_should_convert_resources_info_message( self, mock_health_convert_strategy, mock_convert @@ -115,7 +115,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_resources_info_message( "converter.cisu_transcoders.reference.reference_converter.ReferenceConverter.from_cisu_to_rs" ) @patch( - "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy" + "converter.conversion_strategy.cisu_transcoding_strategy.health_version_conversion_strategy" ) def test_cisu_to_rs_conversion_strategy_should_convert_reference_message( self, mock_health_convert_strategy, mock_convert @@ -129,7 +129,7 @@ def test_cisu_to_rs_conversion_strategy_should_convert_reference_message( return_value=None, ) @patch( - "converter.conversion_strategy.cisu_transcoding_strategy.health_conversion_strategy", + "converter.conversion_strategy.cisu_transcoding_strategy.health_version_conversion_strategy", side_effect=lambda msg, *_: msg, ) def test_cisu_to_rs_resources_info_returns_list( @@ -148,7 +148,7 @@ def test_cisu_to_rs_resources_info_returns_list( ) assert isinstance(result, list) - # health_conversion_strategy must be called once per produced message + # health_version_conversion_strategy must be called once per produced message assert mock_health_convert_strategy.call_count == len(result) def test_rs_to_cisu_transcoding_strategy_should_raise_error_with_invalid_target_version( diff --git a/converter/tests/conversion_strategy/test_conversion_strategy.py b/converter/tests/conversion_strategy/test_conversion_strategy.py index b8323ee125..ecda7b1338 100644 --- a/converter/tests/conversion_strategy/test_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_conversion_strategy.py @@ -24,10 +24,10 @@ def test_conversion_strategy_with_cisu_conversion( ) @patch( - "converter.conversion_strategy.conversion_strategy.health_conversion_strategy" + "converter.conversion_strategy.conversion_strategy.health_version_conversion_strategy" ) def test_conversion_strategy_with_health_conversion( - self, mock_health_conversion_strategy + self, mock_health_version_conversion_strategy ): edxl_json = {} source_version = "source_version" @@ -38,22 +38,22 @@ def test_conversion_strategy_with_health_conversion( edxl_json, source_version, target_version, is_cisu_conversion ) - mock_health_conversion_strategy.assert_called_once_with( + mock_health_version_conversion_strategy.assert_called_once_with( edxl_json, source_version, target_version ) @patch( - "converter.conversion_strategy.conversion_strategy.health_conversion_strategy" + "converter.conversion_strategy.conversion_strategy.health_version_conversion_strategy" ) def test_conversion_strategy_wraps_single_dict_in_list( - self, mock_health_conversion_strategy + self, mock_health_version_conversion_strategy ): edxl_json = {} source_version = "source_version" target_version = "target_version" is_cisu_conversion = False single_message = {"distributionID": "single-message"} - mock_health_conversion_strategy.return_value = single_message + mock_health_version_conversion_strategy.return_value = single_message converted_edxl = conversion_strategy( edxl_json, source_version, target_version, is_cisu_conversion @@ -63,17 +63,17 @@ def test_conversion_strategy_wraps_single_dict_in_list( assert converted_edxl == [single_message] @patch( - "converter.conversion_strategy.conversion_strategy.health_conversion_strategy" + "converter.conversion_strategy.conversion_strategy.health_version_conversion_strategy" ) def test_conversion_strategy_preserves_list_result( - self, mock_health_conversion_strategy + self, mock_health_version_conversion_strategy ): edxl_json = {} source_version = "source_version" target_version = "target_version" is_cisu_conversion = False list_message = [{"distributionID": "msg-1"}, {"distributionID": "msg-2"}] - mock_health_conversion_strategy.return_value = list_message + mock_health_version_conversion_strategy.return_value = list_message converted_edxl = conversion_strategy( edxl_json, source_version, target_version, is_cisu_conversion diff --git a/converter/tests/conversion_strategy/test_health_conversion_strategy.py b/converter/tests/conversion_strategy/test_health_conversion_strategy.py index d824374873..24a2bc2a49 100644 --- a/converter/tests/conversion_strategy/test_health_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_health_conversion_strategy.py @@ -2,15 +2,15 @@ from typing import Tuple, Dict from unittest.mock import patch -from converter.conversion_strategy.health_conversion_strategy import ( - health_conversion_strategy, +from converter.conversion_strategy.health_version_conversion_strategy import ( + health_version_conversion_strategy, ) from tests.constants import TestConstants from tests.test_helpers import TestHelper class TestConversionStrategy(unittest.TestCase): - def test_health_conversion_strategy_raise_error_when_converting_unsupported_message_type( + def test_health_version_conversion_strategy_raise_error_when_converting_unsupported_message_type( self, ): edxl_json = { @@ -31,10 +31,14 @@ def test_health_conversion_strategy_raise_error_when_converting_unsupported_mess ValueError, "Version conversion for message type 'notSupportedMessageType' is currently not implemented.", ): - health_conversion_strategy(edxl_json, source_version, target_version) + health_version_conversion_strategy( + edxl_json, source_version, target_version + ) @staticmethod - def run_health_conversion_strategy(message_type: str) -> Tuple[str, str, Dict]: + def run_health_version_conversion_strategy( + message_type: str, + ) -> Tuple[str, str, Dict]: message_json_path = TestHelper.get_json_files(message_type)[0]["path"] edxl_json = TestHelper.create_edxl_json_from_sample( TestConstants.EDXL_HEALTH_TO_HEALTH_ENVELOPE_PATH, message_json_path @@ -42,112 +46,112 @@ def run_health_conversion_strategy(message_type: str) -> Tuple[str, str, Dict]: source_version = "v1" target_version = "v2" - health_conversion_strategy(edxl_json, source_version, target_version) + health_version_conversion_strategy(edxl_json, source_version, target_version) return source_version, target_version, edxl_json @patch( "converter.health_version_converters.create_case_health.create_case_health_converter.CreateHealthCaseConverter.convert" ) - def test_health_conversion_strategy_should_convert_create_case_health_message( + def test_health_version_conversion_strategy_should_convert_create_case_health_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_EDA_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_EDA_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.create_case_health.create_case_health_update_converter.CreateHealthUpdateCaseConverter.convert" ) - def test_health_conversion_strategy_should_convert_create_case_health_update_message( + def test_health_version_conversion_strategy_should_convert_create_case_health_update_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_EDA_MAJ_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_EDA_MAJ_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.reference.reference_converter.ReferenceConverter.convert" ) - def test_health_conversion_strategy_should_convert_reference_message( + def test_health_version_conversion_strategy_should_convert_reference_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RC_REF_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RC_REF_TAG) mock_convert.assert_called_once_with(*args) @patch("converter.health_version_converters.error_converter.ErrorConverter.convert") - def test_health_conversion_strategy_should_convert_error_message( + def test_health_version_conversion_strategy_should_convert_error_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_ERROR_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_ERROR_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.resources_status.resources_status_converter.ResourcesStatusConverter.convert" ) - def test_health_conversion_strategy_should_convert_resources_status_message( + def test_health_version_conversion_strategy_should_convert_resources_status_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_SR_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_SR_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.resources_info.resources_info_converter.ResourcesInfoConverter.convert" ) - def test_health_conversion_strategy_should_convert_resources_info_message( + def test_health_version_conversion_strategy_should_convert_resources_info_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_RI_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_RI_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.resources_response.resources_response_converter.ResourcesResponseConverter.convert" ) - def test_health_conversion_strategy_should_convert_resources_response_message( + def test_health_version_conversion_strategy_should_convert_resources_response_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_RR_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_RR_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.resources_request.resources_request_converter.ResourcesRequestConverter.convert" ) - def test_health_conversion_strategy_should_convert_resources_request_message( + def test_health_version_conversion_strategy_should_convert_resources_request_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_DR_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_DR_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.resources_engagement.resources_engagement_converter.ResourcesEngagementConverter.convert" ) - def test_health_conversion_strategy_should_convert_resources_engagement_message( + def test_health_version_conversion_strategy_should_convert_resources_engagement_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.RS_ER_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.RS_ER_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.geo_positions_update.geo_positions_update_converter.GeoPositionsUpdateConverter.convert" ) - def test_health_conversion_strategy_should_convert_geo_positions_update_message( + def test_health_version_conversion_strategy_should_convert_geo_positions_update_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.GEO_POS_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.GEO_POS_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.identical_message_converter.IdenticalMessageConverter.convert" ) - def test_health_conversion_strategy_should_convert_geo_resources_requests_message( + def test_health_version_conversion_strategy_should_convert_geo_resources_requests_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.GEO_REQ_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.GEO_REQ_TAG) mock_convert.assert_called_once_with(*args) @patch( "converter.health_version_converters.geo_resources_details.geo_resources_details_converter.GeoResourcesDetailsConverter.convert" ) - def test_health_conversion_strategy_should_convert_geo_resources_details_message( + def test_health_version_conversion_strategy_should_convert_geo_resources_details_message( self, mock_convert ): - args = self.run_health_conversion_strategy(TestConstants.GEO_RES_TAG) + args = self.run_health_version_conversion_strategy(TestConstants.GEO_RES_TAG) mock_convert.assert_called_once_with(*args) From f2adf8ab64730e3e2ca8cf22a0dff2daba48b0c8 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 15:07:21 +0200 Subject: [PATCH 05/27] feat(converter): new cisu_version_conversion_strategy --- .../cisu_version_conversion_strategy.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 converter/converter/conversion_strategy/cisu_version_conversion_strategy.py diff --git a/converter/converter/conversion_strategy/cisu_version_conversion_strategy.py b/converter/converter/conversion_strategy/cisu_version_conversion_strategy.py new file mode 100644 index 0000000000..444f46c75c --- /dev/null +++ b/converter/converter/conversion_strategy/cisu_version_conversion_strategy.py @@ -0,0 +1,11 @@ +import logging + +logger = logging.getLogger(__name__) + + +def cisu_version_conversion_strategy(edxl_json, source_version, target_version): + logger.info(f"CISU Conversion initiated from {source_version} to {target_version}") + + raise NotImplementedError( + "Conversion strategy 'cisu_version_conversion_strategy' not yet implemented." + ) From ae78b9b58fe5b45a0121d133564ee02f015d5488 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 16:32:25 +0200 Subject: [PATCH 06/27] feat(converter): new type param validation --- converter/converter/converter.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/converter/converter/converter.py b/converter/converter/converter.py index 38e9402d2f..5ecd8ddb5c 100644 --- a/converter/converter/converter.py +++ b/converter/converter/converter.py @@ -14,6 +14,7 @@ ) from converter.logging_config import configure_logging, LoggingKeys from converter.database import init_db, get_db +from converter.constants import ConversionType configure_logging() @@ -65,6 +66,14 @@ def convert(): target_version = req_data.get("targetVersion") edxl_json = req_data.get("edxl") is_cisu_conversion = req_data.get("cisuConversion", False) + conversion_type = req_data.get("type") + + valid = [t.value for t in ConversionType] + if conversion_type not in valid: + return raise_error( + f'Conversion type "{conversion_type}" must be one of {valid}' + ) + conversion_type = ConversionType(conversion_type) # Store data in request context to be used in logs try: From be2871194a5a6321c2afd64cdf3897b3e9254cae Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 16:41:41 +0200 Subject: [PATCH 07/27] test(converter): make conversion strategy based on payload type + test not implemented --- .../conversion_strategy.py | 26 +++++++++++-- converter/converter/converter.py | 3 +- .../test_conversion_strategy.py | 38 +++++++++++++------ converter/tests/test_converter.py | 10 ++++- 4 files changed, 58 insertions(+), 19 deletions(-) diff --git a/converter/converter/conversion_strategy/conversion_strategy.py b/converter/converter/conversion_strategy/conversion_strategy.py index aef3944a0d..9e5e298273 100644 --- a/converter/converter/conversion_strategy/conversion_strategy.py +++ b/converter/converter/conversion_strategy/conversion_strategy.py @@ -1,20 +1,38 @@ +from typing import Any, Dict + from converter.conversion_strategy.health_version_conversion_strategy import ( health_version_conversion_strategy, ) from converter.conversion_strategy.cisu_transcoding_strategy import ( cisu_transcoding_strategy, ) +from converter.conversion_strategy.cisu_version_conversion_strategy import ( + cisu_version_conversion_strategy, +) +from converter.constants import ConversionType def conversion_strategy( - edxl_json, source_version: str, target_version: str, is_cisu_conversion: bool + edxl_json, source_version: str, target_version: str, conversion_type: ConversionType ) -> list: - if is_cisu_conversion: - converted_edxl = cisu_transcoding_strategy( + converted_edxl: Dict[str, Any] | list[Dict[str, Any]] | list = [] + + if conversion_type == ConversionType.CISUVersionConversion: + converted_edxl = cisu_version_conversion_strategy( edxl_json, source_version, target_version ) - else: + + elif conversion_type == ConversionType.HealthVersionConversion: converted_edxl = health_version_conversion_strategy( edxl_json, source_version, target_version ) + + elif conversion_type == ConversionType.CISUTranscoding: + converted_edxl = cisu_transcoding_strategy( + edxl_json, source_version, target_version + ) + + else: + raise ValueError(f"Unknown conversion type: {conversion_type}") + return converted_edxl if isinstance(converted_edxl, list) else [converted_edxl] diff --git a/converter/converter/converter.py b/converter/converter/converter.py index 5ecd8ddb5c..bfc9237359 100644 --- a/converter/converter/converter.py +++ b/converter/converter/converter.py @@ -65,7 +65,6 @@ def convert(): source_version = req_data.get("sourceVersion") target_version = req_data.get("targetVersion") edxl_json = req_data.get("edxl") - is_cisu_conversion = req_data.get("cisuConversion", False) conversion_type = req_data.get("type") valid = [t.value for t in ConversionType] @@ -96,7 +95,7 @@ def convert(): try: converted_messages = conversion_strategy( - edxl_json, source_version, target_version, is_cisu_conversion + edxl_json, source_version, target_version, conversion_type ) except ValueError as e: return raise_error(str(e)) diff --git a/converter/tests/conversion_strategy/test_conversion_strategy.py b/converter/tests/conversion_strategy/test_conversion_strategy.py index ecda7b1338..d11bc8cdc8 100644 --- a/converter/tests/conversion_strategy/test_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_conversion_strategy.py @@ -1,6 +1,8 @@ import unittest from unittest.mock import patch +import pytest from converter.conversion_strategy.conversion_strategy import conversion_strategy +from converter.constants import ConversionType class TestConversionStrategy(unittest.TestCase): @@ -13,11 +15,9 @@ def test_conversion_strategy_with_cisu_conversion( edxl_json = {} source_version = "source_version" target_version = "target_version" - is_cisu_conversion = True + conversion_type = ConversionType.CISUTranscoding - conversion_strategy( - edxl_json, source_version, target_version, is_cisu_conversion - ) + conversion_strategy(edxl_json, source_version, target_version, conversion_type) mock_cisu_transcoding_strategy.assert_called_once_with( edxl_json, source_version, target_version @@ -32,16 +32,30 @@ def test_conversion_strategy_with_health_conversion( edxl_json = {} source_version = "source_version" target_version = "target_version" - is_cisu_conversion = False + conversion_type = ConversionType.HealthVersionConversion - conversion_strategy( - edxl_json, source_version, target_version, is_cisu_conversion - ) + conversion_strategy(edxl_json, source_version, target_version, conversion_type) mock_health_version_conversion_strategy.assert_called_once_with( edxl_json, source_version, target_version ) + def test_conversion_strategy_with_cisu_version_conversion_raises_not_implemented( + self, + ): + edxl_json = {} + source_version = "source_version" + target_version = "target_version" + conversion_type = ConversionType.CISUVersionConversion + + with pytest.raises( + NotImplementedError, + match="Conversion strategy 'cisu_version_conversion_strategy' not yet implemented.", + ): + conversion_strategy( + edxl_json, source_version, target_version, conversion_type + ) + @patch( "converter.conversion_strategy.conversion_strategy.health_version_conversion_strategy" ) @@ -51,12 +65,12 @@ def test_conversion_strategy_wraps_single_dict_in_list( edxl_json = {} source_version = "source_version" target_version = "target_version" - is_cisu_conversion = False + conversion_type = ConversionType.HealthVersionConversion single_message = {"distributionID": "single-message"} mock_health_version_conversion_strategy.return_value = single_message converted_edxl = conversion_strategy( - edxl_json, source_version, target_version, is_cisu_conversion + edxl_json, source_version, target_version, conversion_type ) assert isinstance(converted_edxl, list) @@ -71,12 +85,12 @@ def test_conversion_strategy_preserves_list_result( edxl_json = {} source_version = "source_version" target_version = "target_version" - is_cisu_conversion = False + conversion_type = ConversionType.HealthVersionConversion list_message = [{"distributionID": "msg-1"}, {"distributionID": "msg-2"}] mock_health_version_conversion_strategy.return_value = list_message converted_edxl = conversion_strategy( - edxl_json, source_version, target_version, is_cisu_conversion + edxl_json, source_version, target_version, conversion_type ) assert isinstance(converted_edxl, list) diff --git a/converter/tests/test_converter.py b/converter/tests/test_converter.py index 422698f943..10e77ee333 100644 --- a/converter/tests/test_converter.py +++ b/converter/tests/test_converter.py @@ -21,7 +21,7 @@ def test_convert_invalid_content_type(client): def test_convert_missing_required_fields(client): """Test sending request without required fields""" - response = client.post("/convert", json={}) + response = client.post("/convert", json={"type": "HealthVersionConversion"}) assert response.status_code == 400 assert "Missing required fields" in response.json["error"] @@ -43,6 +43,7 @@ def test_convert_cisu_invalid_direction(client): "targetVersion": "v3", "edxl": envelope["edxl"], "cisuConversion": True, + "type": "CISUTranscoding", }, ) assert response.status_code == 400 @@ -60,6 +61,7 @@ def test_convert_version_with_invalid_source_version(client): "targetVersion": "v1", "edxl": edxl_json, "cisuConversion": False, + "type": "HealthVersionConversion", }, ) @@ -78,6 +80,7 @@ def test_convert_version_with_invalid_target_version(client): "targetVersion": "v4", "edxl": edxl_json, "cisuConversion": False, + "type": "HealthVersionConversion", }, ) @@ -107,6 +110,7 @@ def test_convert_edxl_versions(client, source_version, target_version): "targetVersion": target_version, "edxl": edxl_json, "cisuConversion": False, + "type": "HealthVersionConversion", }, ) @@ -134,6 +138,7 @@ def test_convert_from_cisu(client, rs_target_version): "targetVersion": rs_target_version, "edxl": edxl_json, "cisuConversion": True, + "type": "CISUTranscoding", }, ) @@ -169,6 +174,7 @@ def test_convert_to_cisu(client, rs_source_version): "targetVersion": "v3", "edxl": edxl_json, "cisuConversion": True, + "type": "CISUTranscoding", }, ) @@ -196,6 +202,7 @@ def test_convert_to_cisu_with_invalid_cisu_target_version(client): "targetVersion": "v2", "edxl": edxl_json, "cisuConversion": True, + "type": "CISUTranscoding", }, ) @@ -214,6 +221,7 @@ def test_convert_to_cisu_with_invalid_cisu_source_version(client): "targetVersion": "v1", "edxl": edxl_json, "cisuConversion": True, + "type": "CISUTranscoding", }, ) From bdcb943dec043b6b2d35ea4be82873572c962dd6 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 18 May 2026 17:13:14 +0200 Subject: [PATCH 08/27] feat(converter): update MAINTAINED_CISU_VERSION to 'vactive' --- converter/converter/cisu_transcoders/constants.py | 3 ++- .../conversion_strategy/cisu_transcoding_strategy.py | 4 ++-- .../conversion_strategy/test_cisu_conversion_strategy.py | 8 ++++---- converter/tests/test_converter.py | 5 +++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/converter/converter/cisu_transcoders/constants.py b/converter/converter/cisu_transcoders/constants.py index 66b8dc4744..7fa6e38918 100644 --- a/converter/converter/cisu_transcoders/constants.py +++ b/converter/converter/cisu_transcoders/constants.py @@ -1,4 +1,5 @@ class CISUConstants: TO_CISU = "to_CISU" FROM_CISU = "from_CISU" - MAINTAINED_CISU_VERSION = "v3" + MAINTAINED_CISU_VERSION = "vactive" + MAINTAINED_HEALTH_CISU_VERSION = "v3" diff --git a/converter/converter/conversion_strategy/cisu_transcoding_strategy.py b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py index 9de96ea489..59884d0b1d 100644 --- a/converter/converter/conversion_strategy/cisu_transcoding_strategy.py +++ b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py @@ -42,7 +42,7 @@ def cisu_transcoding_strategy(edxl_json, source_version, target_version): ) rs_json_message = health_version_conversion_strategy( - edxl_json, source_version, CISUConstants.MAINTAINED_CISU_VERSION + edxl_json, source_version, CISUConstants.MAINTAINED_HEALTH_CISU_VERSION ) return selected_strategy.from_rs_to_cisu(rs_json_message) @@ -60,7 +60,7 @@ def cisu_transcoding_strategy(edxl_json, source_version, target_version): rc_json_messages = [rc_json_messages] return [ health_version_conversion_strategy( - msg, CISUConstants.MAINTAINED_CISU_VERSION, target_version + msg, CISUConstants.MAINTAINED_HEALTH_CISU_VERSION, target_version ) for msg in rc_json_messages ] diff --git a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py index e32f661c0a..1dc8402af0 100644 --- a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py @@ -43,7 +43,7 @@ def run_rs_to_cisu_transcoding_strategy(message_type: str) -> None: TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH, message_json_path ) source_version = "v1" - target_version = "v3" + target_version = CISUConstants.MAINTAINED_CISU_VERSION cisu_transcoding_strategy(edxl_json, source_version, target_version) @@ -80,7 +80,7 @@ def run_cisu_to_rs_conversion_strategy(message_type: str) -> None: edxl_json = TestHelper.create_edxl_json_from_sample( TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, message_json_path ) - source_version = "v3" + source_version = CISUConstants.MAINTAINED_CISU_VERSION target_version = "v3" cisu_transcoding_strategy(edxl_json, source_version, target_version) @@ -164,7 +164,7 @@ def test_rs_to_cisu_transcoding_strategy_should_raise_error_with_invalid_target_ with self.assertRaisesRegex( ValueError, - "Unknown target version v1. Must be: v3", + f"Unknown target version v1. Must be: {CISUConstants.MAINTAINED_CISU_VERSION}", ): cisu_transcoding_strategy(edxl_json, "v1", invalid_target_version) @@ -181,7 +181,7 @@ def test_cisu_to_rs_conversion_strategy_should_raise_error_with_invalid_source_v with self.assertRaisesRegex( ValueError, - "Unknown source version v1. Must be: v3", + f"Unknown source version v1. Must be: {CISUConstants.MAINTAINED_CISU_VERSION}", ): cisu_transcoding_strategy(edxl_json, invalid_source_version, "v1") diff --git a/converter/tests/test_converter.py b/converter/tests/test_converter.py index 10e77ee333..9299ea208d 100644 --- a/converter/tests/test_converter.py +++ b/converter/tests/test_converter.py @@ -1,4 +1,5 @@ import pytest +from converter.cisu_transcoders.constants import CISUConstants from converter.converter import app from tests.constants import TestConstants from tests.test_helpers import TestHelper @@ -134,7 +135,7 @@ def test_convert_from_cisu(client, rs_target_version): response = client.post( "/convert", json={ - "sourceVersion": "v3", + "sourceVersion": CISUConstants.MAINTAINED_CISU_VERSION, "targetVersion": rs_target_version, "edxl": edxl_json, "cisuConversion": True, @@ -171,7 +172,7 @@ def test_convert_to_cisu(client, rs_source_version): "/convert", json={ "sourceVersion": rs_source_version, - "targetVersion": "v3", + "targetVersion": CISUConstants.MAINTAINED_CISU_VERSION, "edxl": edxl_json, "cisuConversion": True, "type": "CISUTranscoding", From 13cbbc6f0210eb4c31ea584a9657545622b3e5b9 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Tue, 19 May 2026 14:57:07 +0200 Subject: [PATCH 09/27] test(converter): new tests covering MAINTAINED_HEALTH_CISU_VERSION constant --- .../test_cisu_conversion_strategy.py | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py index 1dc8402af0..ea9397c956 100644 --- a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py @@ -185,6 +185,59 @@ def test_cisu_to_rs_conversion_strategy_should_raise_error_with_invalid_source_v ): cisu_transcoding_strategy(edxl_json, invalid_source_version, "v1") + @patch( + "converter.cisu_transcoders.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_rs_to_cisu" + ) + @patch( + "converter.conversion_strategy.cisu_transcoding_strategy.health_version_conversion_strategy", + side_effect=lambda edxl, *_: edxl, + ) + def test_rs_to_cisu_bridge_targets_maintained_health_cisu_version( + self, mock_health_convert_strategy, _mock_convert + ): + """TO_CISU bridge must target MAINTAINED_HEALTH_CISU_VERSION (RS-side), not MAINTAINED_CISU_VERSION (CISU-side).""" + message_json_path = TestHelper.get_json_files(TestConstants.RS_EDA_TAG)[0][ + "path" + ] + edxl_json = TestHelper.create_edxl_json_from_sample( + TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH, message_json_path + ) + + cisu_transcoding_strategy( + edxl_json, "v1", CISUConstants.MAINTAINED_CISU_VERSION + ) + + mock_health_convert_strategy.assert_called_once_with( + edxl_json, "v1", CISUConstants.MAINTAINED_HEALTH_CISU_VERSION + ) + + @patch( + "converter.cisu_transcoders.create_case.create_case_cisu_converter.CreateCaseCISUConverter.from_cisu_to_rs", + side_effect=lambda edxl: edxl, + ) + @patch( + "converter.conversion_strategy.cisu_transcoding_strategy.health_version_conversion_strategy", + side_effect=lambda msg, *_: msg, + ) + def test_cisu_to_rs_bridge_sources_from_maintained_health_cisu_version( + self, mock_health_convert_strategy, _mock_convert + ): + """FROM_CISU bridge must source from MAINTAINED_HEALTH_CISU_VERSION (RS-side), not MAINTAINED_CISU_VERSION (CISU-side).""" + message_json_path = TestHelper.get_json_files(TestConstants.RC_EDA_TAG)[0][ + "path" + ] + edxl_json = TestHelper.create_edxl_json_from_sample( + TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, message_json_path + ) + + cisu_transcoding_strategy( + edxl_json, CISUConstants.MAINTAINED_CISU_VERSION, "v1" + ) + + mock_health_convert_strategy.assert_called_once_with( + edxl_json, CISUConstants.MAINTAINED_HEALTH_CISU_VERSION, "v1" + ) + class TestComputeMessageDirection(unittest.TestCase): def test_compute_message_direction_should_return_to_cisu_when_sender_is_health_and_not_recipient( From 1703da95a09bc83b02f4ee5eb5f8434165324ada Mon Sep 17 00:00:00 2001 From: EliNoden Date: Wed, 20 May 2026 13:52:52 +0200 Subject: [PATCH 10/27] refactor(converter): update constants naming --- .../converter/cisu_transcoders/constants.py | 4 ++-- .../cisu_transcoding_strategy.py | 16 +++++++++----- .../test_cisu_conversion_strategy.py | 22 +++++++++---------- converter/tests/test_converter.py | 4 ++-- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/converter/converter/cisu_transcoders/constants.py b/converter/converter/cisu_transcoders/constants.py index 7fa6e38918..ed7591130f 100644 --- a/converter/converter/cisu_transcoders/constants.py +++ b/converter/converter/cisu_transcoders/constants.py @@ -1,5 +1,5 @@ class CISUConstants: TO_CISU = "to_CISU" FROM_CISU = "from_CISU" - MAINTAINED_CISU_VERSION = "vactive" - MAINTAINED_HEALTH_CISU_VERSION = "v3" + CISU_EXPECTED_MODEL_VERSION = "vactive" + HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION = "v3" diff --git a/converter/converter/conversion_strategy/cisu_transcoding_strategy.py b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py index 59884d0b1d..2f41349235 100644 --- a/converter/converter/conversion_strategy/cisu_transcoding_strategy.py +++ b/converter/converter/conversion_strategy/cisu_transcoding_strategy.py @@ -36,13 +36,15 @@ def cisu_transcoding_strategy(edxl_json, source_version, target_version): logger.info( "Conversion RS -> CISU", ) - if target_version != CISUConstants.MAINTAINED_CISU_VERSION: + if target_version != CISUConstants.CISU_EXPECTED_MODEL_VERSION: raise ValueError( - f"Unknown target version {target_version}. Must be: {CISUConstants.MAINTAINED_CISU_VERSION}" + f"Unknown target version {target_version}. Must be: {CISUConstants.CISU_EXPECTED_MODEL_VERSION}" ) rs_json_message = health_version_conversion_strategy( - edxl_json, source_version, CISUConstants.MAINTAINED_HEALTH_CISU_VERSION + edxl_json, + source_version, + CISUConstants.HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION, ) return selected_strategy.from_rs_to_cisu(rs_json_message) @@ -50,9 +52,9 @@ def cisu_transcoding_strategy(edxl_json, source_version, target_version): logger.info( "Conversion CISU -> RS", ) - if source_version != CISUConstants.MAINTAINED_CISU_VERSION: + if source_version != CISUConstants.CISU_EXPECTED_MODEL_VERSION: raise ValueError( - f"Unknown source version {source_version}. Must be: {CISUConstants.MAINTAINED_CISU_VERSION}" + f"Unknown source version {source_version}. Must be: {CISUConstants.CISU_EXPECTED_MODEL_VERSION}" ) rc_json_messages = selected_strategy.from_cisu_to_rs(edxl_json) @@ -60,7 +62,9 @@ def cisu_transcoding_strategy(edxl_json, source_version, target_version): rc_json_messages = [rc_json_messages] return [ health_version_conversion_strategy( - msg, CISUConstants.MAINTAINED_HEALTH_CISU_VERSION, target_version + msg, + CISUConstants.HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION, + target_version, ) for msg in rc_json_messages ] diff --git a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py index ea9397c956..191c05cf1b 100644 --- a/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_cisu_conversion_strategy.py @@ -43,7 +43,7 @@ def run_rs_to_cisu_transcoding_strategy(message_type: str) -> None: TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH, message_json_path ) source_version = "v1" - target_version = CISUConstants.MAINTAINED_CISU_VERSION + target_version = CISUConstants.CISU_EXPECTED_MODEL_VERSION cisu_transcoding_strategy(edxl_json, source_version, target_version) @@ -80,7 +80,7 @@ def run_cisu_to_rs_conversion_strategy(message_type: str) -> None: edxl_json = TestHelper.create_edxl_json_from_sample( TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, message_json_path ) - source_version = CISUConstants.MAINTAINED_CISU_VERSION + source_version = CISUConstants.CISU_EXPECTED_MODEL_VERSION target_version = "v3" cisu_transcoding_strategy(edxl_json, source_version, target_version) @@ -144,7 +144,7 @@ def test_cisu_to_rs_resources_info_returns_list( ) result = cisu_transcoding_strategy( - edxl_json, CISUConstants.MAINTAINED_CISU_VERSION, "v3" + edxl_json, CISUConstants.CISU_EXPECTED_MODEL_VERSION, "v3" ) assert isinstance(result, list) @@ -164,7 +164,7 @@ def test_rs_to_cisu_transcoding_strategy_should_raise_error_with_invalid_target_ with self.assertRaisesRegex( ValueError, - f"Unknown target version v1. Must be: {CISUConstants.MAINTAINED_CISU_VERSION}", + f"Unknown target version v1. Must be: {CISUConstants.CISU_EXPECTED_MODEL_VERSION}", ): cisu_transcoding_strategy(edxl_json, "v1", invalid_target_version) @@ -181,7 +181,7 @@ def test_cisu_to_rs_conversion_strategy_should_raise_error_with_invalid_source_v with self.assertRaisesRegex( ValueError, - f"Unknown source version v1. Must be: {CISUConstants.MAINTAINED_CISU_VERSION}", + f"Unknown source version v1. Must be: {CISUConstants.CISU_EXPECTED_MODEL_VERSION}", ): cisu_transcoding_strategy(edxl_json, invalid_source_version, "v1") @@ -195,7 +195,7 @@ def test_cisu_to_rs_conversion_strategy_should_raise_error_with_invalid_source_v def test_rs_to_cisu_bridge_targets_maintained_health_cisu_version( self, mock_health_convert_strategy, _mock_convert ): - """TO_CISU bridge must target MAINTAINED_HEALTH_CISU_VERSION (RS-side), not MAINTAINED_CISU_VERSION (CISU-side).""" + """TO_CISU bridge must target HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION (RS-side), not CISU_EXPECTED_MODEL_VERSION (CISU-side).""" message_json_path = TestHelper.get_json_files(TestConstants.RS_EDA_TAG)[0][ "path" ] @@ -204,11 +204,11 @@ def test_rs_to_cisu_bridge_targets_maintained_health_cisu_version( ) cisu_transcoding_strategy( - edxl_json, "v1", CISUConstants.MAINTAINED_CISU_VERSION + edxl_json, "v1", CISUConstants.CISU_EXPECTED_MODEL_VERSION ) mock_health_convert_strategy.assert_called_once_with( - edxl_json, "v1", CISUConstants.MAINTAINED_HEALTH_CISU_VERSION + edxl_json, "v1", CISUConstants.HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION ) @patch( @@ -222,7 +222,7 @@ def test_rs_to_cisu_bridge_targets_maintained_health_cisu_version( def test_cisu_to_rs_bridge_sources_from_maintained_health_cisu_version( self, mock_health_convert_strategy, _mock_convert ): - """FROM_CISU bridge must source from MAINTAINED_HEALTH_CISU_VERSION (RS-side), not MAINTAINED_CISU_VERSION (CISU-side).""" + """FROM_CISU bridge must source from HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION (RS-side), not CISU_EXPECTED_MODEL_VERSION (CISU-side).""" message_json_path = TestHelper.get_json_files(TestConstants.RC_EDA_TAG)[0][ "path" ] @@ -231,11 +231,11 @@ def test_cisu_to_rs_bridge_sources_from_maintained_health_cisu_version( ) cisu_transcoding_strategy( - edxl_json, CISUConstants.MAINTAINED_CISU_VERSION, "v1" + edxl_json, CISUConstants.CISU_EXPECTED_MODEL_VERSION, "v1" ) mock_health_convert_strategy.assert_called_once_with( - edxl_json, CISUConstants.MAINTAINED_HEALTH_CISU_VERSION, "v1" + edxl_json, CISUConstants.HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION, "v1" ) diff --git a/converter/tests/test_converter.py b/converter/tests/test_converter.py index 9299ea208d..f0d9a614f2 100644 --- a/converter/tests/test_converter.py +++ b/converter/tests/test_converter.py @@ -135,7 +135,7 @@ def test_convert_from_cisu(client, rs_target_version): response = client.post( "/convert", json={ - "sourceVersion": CISUConstants.MAINTAINED_CISU_VERSION, + "sourceVersion": CISUConstants.CISU_EXPECTED_MODEL_VERSION, "targetVersion": rs_target_version, "edxl": edxl_json, "cisuConversion": True, @@ -172,7 +172,7 @@ def test_convert_to_cisu(client, rs_source_version): "/convert", json={ "sourceVersion": rs_source_version, - "targetVersion": CISUConstants.MAINTAINED_CISU_VERSION, + "targetVersion": CISUConstants.CISU_EXPECTED_MODEL_VERSION, "edxl": edxl_json, "cisuConversion": True, "type": "CISUTranscoding", From 0323d568a3bb00fe3d358233b96dfac49c9b1ea1 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Wed, 20 May 2026 13:56:03 +0200 Subject: [PATCH 11/27] feat(converter): use proper python enum casting --- converter/converter/converter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/converter/converter/converter.py b/converter/converter/converter.py index bfc9237359..2615f57c02 100644 --- a/converter/converter/converter.py +++ b/converter/converter/converter.py @@ -67,12 +67,12 @@ def convert(): edxl_json = req_data.get("edxl") conversion_type = req_data.get("type") - valid = [t.value for t in ConversionType] - if conversion_type not in valid: + try: + conversion_type = ConversionType(conversion_type) + except ValueError: return raise_error( - f'Conversion type "{conversion_type}" must be one of {valid}' + f'Conversion type "{conversion_type}" must be one of {[t.value for t in ConversionType]}' ) - conversion_type = ConversionType(conversion_type) # Store data in request context to be used in logs try: From 2c0464a75c4b4ea977dfc6f59e57555f6e2d04d0 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Wed, 20 May 2026 16:18:19 +0200 Subject: [PATCH 12/27] refactor(converter): add pydantic payload validation --- converter/converter/converter.py | 51 ++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/converter/converter/converter.py b/converter/converter/converter.py index 2615f57c02..8fb48404b4 100644 --- a/converter/converter/converter.py +++ b/converter/converter/converter.py @@ -4,6 +4,8 @@ from prometheus_flask_exporter.multiprocess import GunicornInternalPrometheusMetrics from prometheus_flask_exporter import PrometheusMetrics from pymongo import timeout +from pydantic import BaseModel, ConfigDict, Field, ValidationError +from typing import Any from converter.conversion_strategy.conversion_strategy import conversion_strategy from converter.utils import ( @@ -31,11 +33,36 @@ logger = logging.getLogger(__name__) +class ConvertRequest(BaseModel): + model_config = ConfigDict(extra="forbid") + source_version: str = Field(alias="sourceVersion") + target_version: str = Field(alias="targetVersion") + edxl: dict[str, Any] + type: ConversionType + + def raise_error(message, code: int = 400): logger.error(message) return jsonify({"error": message}), code +def format_validation_error(e): + errors = e.errors() + missing = [err["loc"][0] for err in errors if err["type"] == "missing"] + if missing: + return f"Missing required fields: {', '.join(str(f) for f in missing)}" + + extra = [err["loc"][0] for err in errors if err["type"] == "extra_forbidden"] + if extra: + return f"Unknown fields: {', '.join(str(f) for f in extra)}" + + for err in errors: + if err["loc"][0] == "type": + return f"Conversion type must be one of {[t.value for t in ConversionType]}" + + return "Invalid request payload" + + def extract_message_type_from_payload(): try: data = request.get_json(silent=True) or {} @@ -59,20 +86,17 @@ def extract_message_type_from_payload(): def convert(): if not request.is_json: return raise_error("Content-Type must be application/json") + try: + req_data = ConvertRequest.model_validate(request.get_json()) + except ValidationError as e: + return raise_error(format_validation_error(e)) - req_data = request.get_json() logger.debug(f"Received conversion request: {req_data}") - source_version = req_data.get("sourceVersion") - target_version = req_data.get("targetVersion") - edxl_json = req_data.get("edxl") - conversion_type = req_data.get("type") - try: - conversion_type = ConversionType(conversion_type) - except ValueError: - return raise_error( - f'Conversion type "{conversion_type}" must be one of {[t.value for t in ConversionType]}' - ) + source_version = req_data.source_version + target_version = req_data.target_version + edxl_json = req_data.edxl + conversion_type = req_data.type # Store data in request context to be used in logs try: @@ -88,11 +112,6 @@ def convert(): except Exception: pass - if not source_version or not target_version or not edxl_json: - return raise_error( - f"Missing required fields: sourceVersion={source_version}, targetVersion={target_version}, edxl present={edxl_json is not None}" - ) - try: converted_messages = conversion_strategy( edxl_json, source_version, target_version, conversion_type From 457484259bd0ffb85d9d3a34bf7fb2e1075f2959 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Wed, 20 May 2026 16:19:57 +0200 Subject: [PATCH 13/27] refactor(converter): remove deprecated cisuConversion param --- converter/tests/test_converter.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/converter/tests/test_converter.py b/converter/tests/test_converter.py index f0d9a614f2..aa3106d722 100644 --- a/converter/tests/test_converter.py +++ b/converter/tests/test_converter.py @@ -43,7 +43,6 @@ def test_convert_cisu_invalid_direction(client): "sourceVersion": "v3", "targetVersion": "v3", "edxl": envelope["edxl"], - "cisuConversion": True, "type": "CISUTranscoding", }, ) @@ -61,7 +60,6 @@ def test_convert_version_with_invalid_source_version(client): "sourceVersion": "v4", "targetVersion": "v1", "edxl": edxl_json, - "cisuConversion": False, "type": "HealthVersionConversion", }, ) @@ -80,7 +78,6 @@ def test_convert_version_with_invalid_target_version(client): "sourceVersion": "v1", "targetVersion": "v4", "edxl": edxl_json, - "cisuConversion": False, "type": "HealthVersionConversion", }, ) @@ -110,7 +107,6 @@ def test_convert_edxl_versions(client, source_version, target_version): "sourceVersion": source_version, "targetVersion": target_version, "edxl": edxl_json, - "cisuConversion": False, "type": "HealthVersionConversion", }, ) @@ -138,7 +134,6 @@ def test_convert_from_cisu(client, rs_target_version): "sourceVersion": CISUConstants.CISU_EXPECTED_MODEL_VERSION, "targetVersion": rs_target_version, "edxl": edxl_json, - "cisuConversion": True, "type": "CISUTranscoding", }, ) @@ -174,7 +169,6 @@ def test_convert_to_cisu(client, rs_source_version): "sourceVersion": rs_source_version, "targetVersion": CISUConstants.CISU_EXPECTED_MODEL_VERSION, "edxl": edxl_json, - "cisuConversion": True, "type": "CISUTranscoding", }, ) @@ -202,7 +196,6 @@ def test_convert_to_cisu_with_invalid_cisu_target_version(client): "sourceVersion": "v1", "targetVersion": "v2", "edxl": edxl_json, - "cisuConversion": True, "type": "CISUTranscoding", }, ) @@ -221,7 +214,6 @@ def test_convert_to_cisu_with_invalid_cisu_source_version(client): "sourceVersion": "v2", "targetVersion": "v1", "edxl": edxl_json, - "cisuConversion": True, "type": "CISUTranscoding", }, ) From 22e42d271c06143c561ff202be2d440deb8b18e4 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Wed, 20 May 2026 16:20:32 +0200 Subject: [PATCH 14/27] tests(converter): add tests cover malformed queries --- converter/tests/test_converter.py | 68 +++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/converter/tests/test_converter.py b/converter/tests/test_converter.py index aa3106d722..ccc09c7266 100644 --- a/converter/tests/test_converter.py +++ b/converter/tests/test_converter.py @@ -27,6 +27,74 @@ def test_convert_missing_required_fields(client): assert "Missing required fields" in response.json["error"] +def test_convert_missing_single_field_names_it(client): + """Test that missing field name is reported in the error message""" + response = client.post( + "/convert", + json={ + "sourceVersion": "v1", + "targetVersion": "v2", + "type": "HealthVersionConversion", + }, + ) + assert response.status_code == 400 + assert "Missing required fields" in response.json["error"] + assert "edxl" in response.json["error"] + + +def test_convert_extra_forbidden_field(client): + """Test sending request with an unknown extra field""" + edxl_json = TestHelper.create_edxl_json_from_schema( + TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, TestConstants.RS_EDA_TAG + ) + response = client.post( + "/convert", + json={ + "sourceVersion": "v1", + "targetVersion": "v2", + "edxl": edxl_json, + "type": "HealthVersionConversion", + "unexpected": "boom", + }, + ) + assert response.status_code == 400 + assert "Unknown fields" in response.json["error"] + assert "unexpected" in response.json["error"] + + +def test_convert_invalid_type_enum(client): + """Test sending request with an invalid conversion type""" + edxl_json = TestHelper.create_edxl_json_from_schema( + TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, TestConstants.RS_EDA_TAG + ) + response = client.post( + "/convert", + json={ + "sourceVersion": "v1", + "targetVersion": "v2", + "edxl": edxl_json, + "type": "NotARealType", + }, + ) + assert response.status_code == 400 + assert "Conversion type must be one of" in response.json["error"] + + +def test_convert_invalid_edxl_shape(client): + """Test sending request with edxl as a non-dict value""" + response = client.post( + "/convert", + json={ + "sourceVersion": "v1", + "targetVersion": "v2", + "edxl": "not a dict", + "type": "HealthVersionConversion", + }, + ) + assert response.status_code == 400 + assert response.json["error"] == "Invalid request payload" + + def test_convert_cisu_invalid_direction(client): """Test sending request with both sender and recipient as health""" # Load base envelope From 3ef6cae10f3298eae649857136b19056470e651a Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 21 May 2026 16:17:15 +0200 Subject: [PATCH 15/27] feat(converter): base_cisu_version_converter --- .../base_cisu_version_converter.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 converter/converter/cisu_version_converters/base_cisu_version_converter.py diff --git a/converter/converter/cisu_version_converters/base_cisu_version_converter.py b/converter/converter/cisu_version_converters/base_cisu_version_converter.py new file mode 100644 index 0000000000..5f6e9cefef --- /dev/null +++ b/converter/converter/cisu_version_converters/base_cisu_version_converter.py @@ -0,0 +1,45 @@ +from typing import Any, Dict + +from converter.conversion_mixin import ConversionMixin +from converter.cisu_transcoders.constants import CISUConstants + + +class BaseCISUVersionConverter(ConversionMixin): + def __init__(self): + raise ValueError( + "BaseCISUVersionConverter is an abstract class and cannot be instantiated directly. Use a subclass instead." + ) + + @classmethod + def convert_v3_to_vactive(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]: + raise NotImplementedError("convert_v3_to_vactive not implemented yet.") + + @classmethod + def convert_vactive_to_v3(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]: + raise NotImplementedError("convert_vactive_to_v3 not implemented yet.") + + @classmethod + def get_message_type(cls) -> str: + raise NotImplementedError( + "Subclasses must implement this method to return the message type in RS specifications." + ) + + @classmethod + def convert( + cls, source_version: str, target_version: str, edxl_json: Dict[str, Any] + ): + if ( + source_version == CISUConstants.CISU_EXPECTED_MODEL_VERSION + and target_version + == CISUConstants.HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION + ): + return cls.convert_vactive_to_v3(edxl_json) + elif ( + source_version == CISUConstants.HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION + and target_version == CISUConstants.CISU_EXPECTED_MODEL_VERSION + ): + return cls.convert_v3_to_vactive(edxl_json) + else: + raise ValueError( + f"CISU version conversion from '{source_version}' to '{target_version}' for message type '{cls.get_message_type()}' is currently not implemented." + ) From 541756f42fa7dbee7d7d956031cbd3cb58cb2998 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 21 May 2026 16:18:05 +0200 Subject: [PATCH 16/27] feat(converter): IdenticalCISUVersionConverter --- .../identical_cisu_version_converter.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 converter/converter/cisu_version_converters/identical_cisu_version_converter.py diff --git a/converter/converter/cisu_version_converters/identical_cisu_version_converter.py b/converter/converter/cisu_version_converters/identical_cisu_version_converter.py new file mode 100644 index 0000000000..db0552d75e --- /dev/null +++ b/converter/converter/cisu_version_converters/identical_cisu_version_converter.py @@ -0,0 +1,15 @@ +from typing import Dict, Any + +from converter.cisu_version_converters.base_cisu_version_converter import ( + BaseCISUVersionConverter, +) + + +class IdenticalCISUVersionConverter(BaseCISUVersionConverter): + @classmethod + def convert_v3_to_vactive(cls, edxl_json) -> Dict[str, Any]: + return edxl_json + + @classmethod + def convert_vactive_to_v3(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]: + return edxl_json From 429b3b839a9aea0be236384e2a5e8f70982032e0 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 21 May 2026 16:18:24 +0200 Subject: [PATCH 17/27] feat(converter): CreateCaseVersionConverter --- .../create_case/rc_eda_version_converter.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 converter/converter/cisu_version_converters/create_case/rc_eda_version_converter.py diff --git a/converter/converter/cisu_version_converters/create_case/rc_eda_version_converter.py b/converter/converter/cisu_version_converters/create_case/rc_eda_version_converter.py new file mode 100644 index 0000000000..59323bd1c9 --- /dev/null +++ b/converter/converter/cisu_version_converters/create_case/rc_eda_version_converter.py @@ -0,0 +1,9 @@ +from converter.cisu_version_converters.identical_cisu_version_converter import ( + IdenticalCISUVersionConverter, +) + + +class CreateCaseVersionConverter(IdenticalCISUVersionConverter): + @classmethod + def get_message_type(cls) -> str: + return "createCase" From 02fda7cc6b26696e0e410cfbabfcfa062269dcb7 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 21 May 2026 16:18:37 +0200 Subject: [PATCH 18/27] feat(converter): ResourcesInfoCISUVersionConverter --- .../resources_info_cisu_version_converter.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 converter/converter/cisu_version_converters/resources_info_cisu/resources_info_cisu_version_converter.py diff --git a/converter/converter/cisu_version_converters/resources_info_cisu/resources_info_cisu_version_converter.py b/converter/converter/cisu_version_converters/resources_info_cisu/resources_info_cisu_version_converter.py new file mode 100644 index 0000000000..8af0e34e42 --- /dev/null +++ b/converter/converter/cisu_version_converters/resources_info_cisu/resources_info_cisu_version_converter.py @@ -0,0 +1,9 @@ +from converter.cisu_version_converters.identical_cisu_version_converter import ( + IdenticalCISUVersionConverter, +) + + +class ResourcesInfoCISUVersionConverter(IdenticalCISUVersionConverter): + @classmethod + def get_message_type(cls) -> str: + return "resourcesInfoCisu" From 9c49dfae11009ae20556f6c25d62449cf9947c70 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 21 May 2026 16:18:55 +0200 Subject: [PATCH 19/27] feat(converter): implement cisu_version_conversion_strategy --- .../cisu_version_conversion_strategy.py | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/converter/converter/conversion_strategy/cisu_version_conversion_strategy.py b/converter/converter/conversion_strategy/cisu_version_conversion_strategy.py index 444f46c75c..c563026cb7 100644 --- a/converter/converter/conversion_strategy/cisu_version_conversion_strategy.py +++ b/converter/converter/conversion_strategy/cisu_version_conversion_strategy.py @@ -1,4 +1,17 @@ import logging +from converter.cisu_version_converters.create_case.rc_eda_version_converter import ( + CreateCaseVersionConverter, +) +from converter.cisu_version_converters.resources_info_cisu.resources_info_cisu_version_converter import ( + ResourcesInfoCISUVersionConverter, +) +from converter.utils import ( + extract_message_type_from_message_content, + extract_message_content, +) +from converter.cisu_version_converters.identical_cisu_version_converter import ( + IdenticalCISUVersionConverter, +) logger = logging.getLogger(__name__) @@ -6,6 +19,25 @@ def cisu_version_conversion_strategy(edxl_json, source_version, target_version): logger.info(f"CISU Conversion initiated from {source_version} to {target_version}") - raise NotImplementedError( - "Conversion strategy 'cisu_version_conversion_strategy' not yet implemented." - ) + message_content = extract_message_content(edxl_json) + selected_strategy = select_conversion_strategy(message_content) + + return selected_strategy.convert(source_version, target_version, edxl_json) + + +def select_conversion_strategy(message_content): + if "createCase" in message_content: + return CreateCaseVersionConverter + elif "resourcesInfoCisu" in message_content: + return ResourcesInfoCISUVersionConverter + elif "reference" in message_content: + return IdenticalCISUVersionConverter + elif "error" in message_content: + return IdenticalCISUVersionConverter + else: + deducted_message_type = extract_message_type_from_message_content( + message_content + ) + raise ValueError( + f"CISU Version conversion for message type '{deducted_message_type}' is not implemented." + ) From 1f142a37e255cd54fc61dabd61aaf7717c04efe8 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 21 May 2026 16:20:08 +0200 Subject: [PATCH 20/27] tests(converter): test conversion v3 <-> vactive --- .../test_cisu_version_conversion_strategy.py | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py diff --git a/converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py new file mode 100644 index 0000000000..4a48e79709 --- /dev/null +++ b/converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py @@ -0,0 +1,87 @@ +import unittest +from unittest.mock import patch, ANY + +from converter.cisu_transcoders.constants import CISUConstants +from converter.conversion_strategy.cisu_version_conversion_strategy import ( + cisu_version_conversion_strategy, +) +from tests.constants import TestConstants +from tests.test_helpers import TestHelper + +V3 = CISUConstants.HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION +VACTIVE = CISUConstants.CISU_EXPECTED_MODEL_VERSION + + +class TestCisuVersionConversionStrategy(unittest.TestCase): + @staticmethod + def run_v3_to_vactive_cisu_version_conversion_strategy(message_type: str) -> None: + message_json_path = TestHelper.get_json_files(message_type)[0]["path"] + edxl_json = TestHelper.create_edxl_json_from_sample( + TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH, message_json_path + ) + cisu_version_conversion_strategy(edxl_json, V3, VACTIVE) + + @staticmethod + def run_vactive_to_v3_cisu_version_conversion_strategy(message_type: str) -> None: + message_json_path = TestHelper.get_json_files(message_type)[0]["path"] + edxl_json = TestHelper.create_edxl_json_from_sample( + TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, message_json_path + ) + cisu_version_conversion_strategy(edxl_json, VACTIVE, V3) + + def test_cisu_version_conversion_strategy_raise_error_when_converting_unsupported_message_type( + self, + ): + edxl_json = { + "content": [ + { + "jsonContent": { + "embeddedJsonContent": { + "message": {"notSupportedMessageType": {}} + } + } + } + ], + "senderID": "senderId", + "descriptor": {"explicitAddress": {"explicitAddressValue": "recipientId"}}, + } + + with self.assertRaisesRegex( + ValueError, + "Perimeter translation for message type 'notSupportedMessageType' is not implemented.", + ): + cisu_version_conversion_strategy(edxl_json, V3, VACTIVE) + + @patch( + "converter.conversion_strategy.cisu_version_conversion_strategy.CreateCaseVersionConverter.convert" + ) + def test_create_case_v3_to_vactive(self, mock_convert): + self.run_v3_to_vactive_cisu_version_conversion_strategy( + TestConstants.RC_EDA_TAG + ) + + mock_convert.assert_called_once_with(V3, VACTIVE, ANY) + + @patch( + "converter.conversion_strategy.cisu_version_conversion_strategy.CreateCaseVersionConverter.convert" + ) + def test_create_case_vactive_to_v3(self, mock_convert): + self.run_vactive_to_v3_cisu_version_conversion_strategy( + TestConstants.RC_EDA_TAG + ) + + mock_convert.assert_called_once_with(VACTIVE, V3, ANY) + + @patch( + "converter.conversion_strategy.cisu_version_conversion_strategy.ResourcesInfoCISUVersionConverter.convert" + ) + def test_resources_info_cisu_v3_to_vactive(self, mock_convert): + self.run_v3_to_vactive_cisu_version_conversion_strategy(TestConstants.RC_RI_TAG) + mock_convert.assert_called_once_with(V3, VACTIVE, ANY) + + @patch( + "converter.conversion_strategy.cisu_version_conversion_strategy.ResourcesInfoCISUVersionConverter.convert" + ) + def test_resources_info_cisu_vactive_to_v3(self, mock_convert): + self.run_vactive_to_v3_cisu_version_conversion_strategy(TestConstants.RC_RI_TAG) + mock_convert.assert_called_once_with(VACTIVE, V3, ANY) From ed1cce294697975e5c8de76454c328ff4ea3ac14 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Fri, 22 May 2026 15:01:23 +0200 Subject: [PATCH 21/27] tests(converter): test_resource_info_cisu_version_converter --- ...st_resource_info_cisu_version_converter.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 converter/tests/cisu_version/test_resource_info_cisu_version_converter.py diff --git a/converter/tests/cisu_version/test_resource_info_cisu_version_converter.py b/converter/tests/cisu_version/test_resource_info_cisu_version_converter.py new file mode 100644 index 0000000000..6bd13d2b4c --- /dev/null +++ b/converter/tests/cisu_version/test_resource_info_cisu_version_converter.py @@ -0,0 +1,35 @@ +import unittest + +from converter.cisu_version_converters.resources_info_cisu.resources_info_cisu_version_converter import ( + ResourcesInfoCISUVersionConverter, +) +from tests.constants import TestConstants +from tests.test_helpers import TestHelper + + +class TestResourceInfoCisuVersionConverter(unittest.TestCase): + def setUp(self): + self.edxl_envelope_health_to_fire_path = ( + TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH + ) + self.edxl_envelope_fire_to_health_path = ( + TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH + ) + self.fixtures_folder_path = "tests/fixtures/" + self.converter = ResourcesInfoCISUVersionConverter + + def test_v3_to_vactive(self): + message = TestHelper.create_edxl_json_from_sample( + self.edxl_envelope_health_to_fire_path, + self.fixtures_folder_path + "RC-RI/RC-RI_V3.0_exhaustive_fill.json", + ) + converted_message = self.converter.convert_v3_to_vactive(message) + assert converted_message == message + + def test_vactive_to_v3(self): + message = TestHelper.create_edxl_json_from_sample( + self.edxl_envelope_fire_to_health_path, + self.fixtures_folder_path + "RC-RI/RC-RI_V3.0_exhaustive_fill.json", + ) + converted_message = self.converter.convert_vactive_to_v3(message) + assert converted_message == message From 6fa34ffd0d4ae041d66b6d9a307ecd073b772e86 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Fri, 22 May 2026 15:01:19 +0200 Subject: [PATCH 22/27] tests(converter): test_create_case_version_converter --- .../test_create_case_version_converter.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 converter/tests/cisu_version/test_create_case_version_converter.py diff --git a/converter/tests/cisu_version/test_create_case_version_converter.py b/converter/tests/cisu_version/test_create_case_version_converter.py new file mode 100644 index 0000000000..ccf1f97055 --- /dev/null +++ b/converter/tests/cisu_version/test_create_case_version_converter.py @@ -0,0 +1,35 @@ +import unittest + +from converter.cisu_version_converters.create_case.rc_eda_version_converter import ( + CreateCaseVersionConverter, +) +from tests.constants import TestConstants +from tests.test_helpers import TestHelper + + +class TestCreateCaseVersionConverter(unittest.TestCase): + def setUp(self): + self.edxl_envelope_health_to_fire_path = ( + TestConstants.EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH + ) + self.edxl_envelope_fire_to_health_path = ( + TestConstants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH + ) + self.fixtures_folder_path = "tests/fixtures/" + self.converter = CreateCaseVersionConverter + + def test_v3_to_vactive(self): + message = TestHelper.create_edxl_json_from_sample( + self.edxl_envelope_health_to_fire_path, + self.fixtures_folder_path + "RC-EDA/RC-EDA_exhaustive_fill.json", + ) + converted_message = self.converter.convert_v3_to_vactive(message) + assert converted_message == message + + def test_vactive_to_v3(self): + message = TestHelper.create_edxl_json_from_sample( + self.edxl_envelope_fire_to_health_path, + self.fixtures_folder_path + "RC-EDA/RC-EDA_exhaustive_fill.json", + ) + converted_message = self.converter.convert_vactive_to_v3(message) + assert converted_message == message From c936d03a59f0be2afd13103c9e5efdb15e866ff1 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 21 May 2026 16:23:44 +0200 Subject: [PATCH 23/27] tests(converter): remove cisu_version_conversion_strategy not yet implemented test --- .../test_conversion_strategy.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/converter/tests/conversion_strategy/test_conversion_strategy.py b/converter/tests/conversion_strategy/test_conversion_strategy.py index d11bc8cdc8..5438131467 100644 --- a/converter/tests/conversion_strategy/test_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_conversion_strategy.py @@ -1,6 +1,5 @@ import unittest from unittest.mock import patch -import pytest from converter.conversion_strategy.conversion_strategy import conversion_strategy from converter.constants import ConversionType @@ -40,22 +39,6 @@ def test_conversion_strategy_with_health_conversion( edxl_json, source_version, target_version ) - def test_conversion_strategy_with_cisu_version_conversion_raises_not_implemented( - self, - ): - edxl_json = {} - source_version = "source_version" - target_version = "target_version" - conversion_type = ConversionType.CISUVersionConversion - - with pytest.raises( - NotImplementedError, - match="Conversion strategy 'cisu_version_conversion_strategy' not yet implemented.", - ): - conversion_strategy( - edxl_json, source_version, target_version, conversion_type - ) - @patch( "converter.conversion_strategy.conversion_strategy.health_version_conversion_strategy" ) From b65189f9a1344fa51fd2de928c31179e83d07e43 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Mon, 25 May 2026 12:08:08 +0200 Subject: [PATCH 24/27] tests(converter): update TestCisuVersionConversionStrategy --- .../test_cisu_version_conversion_strategy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py b/converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py index 4a48e79709..6880ffa86d 100644 --- a/converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py +++ b/converter/tests/conversion_strategy/test_cisu_version_conversion_strategy.py @@ -48,7 +48,7 @@ def test_cisu_version_conversion_strategy_raise_error_when_converting_unsupporte with self.assertRaisesRegex( ValueError, - "Perimeter translation for message type 'notSupportedMessageType' is not implemented.", + "CISU Version conversion for message type 'notSupportedMessageType' is not implemented.", ): cisu_version_conversion_strategy(edxl_json, V3, VACTIVE) From f8172e164eeaf4d38497a8277c602c2e831d6c15 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Fri, 22 May 2026 10:46:46 +0200 Subject: [PATCH 25/27] feat(converter): helper script --- converter/scripts/call_convert.sh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/converter/scripts/call_convert.sh b/converter/scripts/call_convert.sh index bf9b5524fe..ae8333a17e 100755 --- a/converter/scripts/call_convert.sh +++ b/converter/scripts/call_convert.sh @@ -7,18 +7,18 @@ CONVERTER_URL_DEFAULT="http://localhost:8083" usage() { cat >&2 < [options] +Usage: $(basename "$0") [options] Positional arguments: sourceVersion e.g. v1, v2, v3, vactive (passed as-is) targetVersion e.g. v1, v2, v3, vactive (passed as-is) + type HealthVersionConversion | CISUTranscoding | CISUVersionConversion useCase path to a JSON file OR http(s) URL of the message payload Options: --envelope EDXL envelope file or URL (default: tests/fixtures/EDXL/edxl_envelope_health_to_health.json) --converter_url Converter base URL (default: http://localhost:8083) - --no-cisu Disable CISU conversion -h, --help Show this message Example: @@ -28,7 +28,6 @@ EOF ENVELOPE="$ENVELOPE_DEFAULT" CONVERTER_URL="$CONVERTER_URL_DEFAULT" -CISU_CONVERSION=true POSITIONAL=() while [[ $# -gt 0 ]]; do @@ -39,8 +38,6 @@ while [[ $# -gt 0 ]]; do --converter_url) [[ $# -ge 2 ]] || { echo "Error: --converter_url requires a value" >&2; usage; exit 1; } CONVERTER_URL="$2"; shift 2;; - --no-cisu) - CISU_CONVERSION=false; shift;; -h|--help) usage; exit 0;; --*) @@ -50,15 +47,16 @@ while [[ $# -gt 0 ]]; do esac done -if [[ ${#POSITIONAL[@]} -ne 3 ]]; then - echo "Error: expected 3 positional arguments, got ${#POSITIONAL[@]}" >&2 +if [[ ${#POSITIONAL[@]} -ne 4 ]]; then + echo "Error: expected 4 positional arguments, got ${#POSITIONAL[@]}" >&2 usage exit 1 fi SOURCE_VERSION="${POSITIONAL[0]}" TARGET_VERSION="${POSITIONAL[1]}" -USECASE="${POSITIONAL[2]}" +TYPE="${POSITIONAL[2]}" +USECASE="${POSITIONAL[3]}" for dep in jq curl; do if ! command -v "$dep" >/dev/null 2>&1; then @@ -92,11 +90,11 @@ PAYLOAD=$(jq -n \ --argjson usecase "$USECASE_JSON" \ --arg sourceVersion "$SOURCE_VERSION" \ --arg targetVersion "$TARGET_VERSION" \ - --argjson cisuConversion "$CISU_CONVERSION" \ + --arg type "$TYPE" \ '{ sourceVersion: $sourceVersion, targetVersion: $targetVersion, - cisuConversion: $cisuConversion, + type: $type, edxl: ($envelope.edxl | .content[0].jsonContent.embeddedJsonContent.message |= (. + $usecase)) }') @@ -108,4 +106,4 @@ if printf '%s' "$RESPONSE" | jq . >/dev/null 2>&1; then printf '%s' "$RESPONSE" | jq . else printf '%s\n' "$RESPONSE" -fi \ No newline at end of file +fi From f0e0ceade6f071f64a922ac33cc9987118bf35ef Mon Sep 17 00:00:00 2001 From: EliNoden Date: Fri, 22 May 2026 10:47:02 +0200 Subject: [PATCH 26/27] feat(converter): update README.md --- converter/README.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/converter/README.md b/converter/README.md index 464e3ea642..37a54bd25b 100644 --- a/converter/README.md +++ b/converter/README.md @@ -113,3 +113,43 @@ curl -X POST http://localhost:8080/convert \ -H "Content-Type: application/json" \ -d "$(jq --argjson usecase "$(cat ../src/main/resources/sample/examples/RS-EDA/RS-EDA-SMUR_FemmeEnceinte_DelphineVigneau.01.json)" '.sourceVersion = "v3" | .targetVersion = "v3" | .cisuConversion = true | .edxl.content[0].jsonContent.embeddedJsonContent.message |= (. + $usecase)' tests/fixtures/EDXL/edxl_envelope_health_to_fire.json)" ``` + +### Helper script — `scripts/call_convert.sh` + +Executable helper to call `/convert` quickly without building the payload by hand. + +**Prerequisite**: local-dev setup running (see [launch local dev setup](https://github.com/ansforge/SAMU-Hub-Config/blob/main/tools/local-dev/README.md)). + +Usage: + +```bash +scripts/call_convert.sh [options] +``` + +Positional args: +- `sourceVersion`, `targetVersion`: `v1` | `v2` | `v3` | `vactive` +- `type`: `HealthVersionConversion` | `CISUTranscoding` | `CISUVersionConversion` (see `ConversionType` in `converter/constants.py`) +- `useCase`: local path to a JSON file **or** `http(s)://` URL of the message payload + +Options: +- `--envelope `: EDXL envelope file or URL (default: `tests/fixtures/EDXL/edxl_envelope_health_to_health.json`) +- `--converter_url `: converter base URL, `/convert` is appended (default: `http://localhost:8083`) +- `-h`, `--help`: show usage + +Examples: + +```bash +# Local fixture, default envelope (health-to-health) +scripts/call_convert.sh v3 v2 HealthVersionConversion tests/fixtures/RS-RI/RS-RI_V3.0_exhaustive_fill.json + +# CISU transcoding with a custom envelope +scripts/call_convert.sh v3 vactive CISUTranscoding ./tests/fixtures/RC-EDA/RC-EDA_required_fields.json \ + --envelope tests/fixtures/EDXL/edxl_envelope_fire_to_health.json + +# Remote payload via URL +scripts/call_convert.sh v3 vactive CISUTranscoding https://raw.githubusercontent.com/org/repo/main/sample.json + +# Override endpoint (e.g. staging) +scripts/call_convert.sh v3 vactive CISUTranscoding ./sample.json \ + --converter_url https://staging.example.com +``` From 60f036537369f3ffc25cd1e2d64cee8eaf32fb96 Mon Sep 17 00:00:00 2001 From: EliNoden Date: Thu, 2 Jul 2026 10:30:16 +0200 Subject: [PATCH 27/27] feat(converter): set cisu expected model version as v3 --- converter/converter/cisu_transcoders/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/converter/converter/cisu_transcoders/constants.py b/converter/converter/cisu_transcoders/constants.py index ed7591130f..cd4bb72540 100644 --- a/converter/converter/cisu_transcoders/constants.py +++ b/converter/converter/cisu_transcoders/constants.py @@ -1,5 +1,5 @@ class CISUConstants: TO_CISU = "to_CISU" FROM_CISU = "from_CISU" - CISU_EXPECTED_MODEL_VERSION = "vactive" + CISU_EXPECTED_MODEL_VERSION = "v3" HEALTH_EXPECTED_VERSION_FOR_CISU_CONVERSION = "v3"