diff --git a/.github/workflows/converter-tests.yml b/.github/workflows/converter-tests.yml index d01b76af1..99ecc9bb2 100644 --- a/.github/workflows/converter-tests.yml +++ b/.github/workflows/converter-tests.yml @@ -63,14 +63,9 @@ jobs: path: tools/converter/htmlcov retention-days: 7 - - name: Run ReportGenerator for test coverage - uses: danielpalme/ReportGenerator-GitHub-Action@5.1.23 - with: - reports: ./converter/coverage.xml - targetdir: coveragereport - name: Pytest coverage comment - uses: MishaKav/pytest-coverage-comment@v1.1.53 + uses: MishaKav/pytest-coverage-comment@v1.7.1 with: pytest-xml-coverage-path: ./converter/coverage.xml title: "Converter - python code coverage" diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py index fee9ff58f..cadd63599 100644 --- a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py +++ b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py @@ -73,7 +73,11 @@ def _build_rs_ri_from_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]: @classmethod def _build_rs_sr_from_resource( - cls, edxl_json: Dict[str, Any], resource: Dict[str, Any], case_id: str + cls, + edxl_json: Dict[str, Any], + resource: Dict[str, Any], + case_id: str, + use_original_distribution_id: bool = False, ) -> Dict[str, Any]: """Build an RS-SR from a single RC-RI resource, reusing the EDXL envelope.""" logger.info( @@ -83,8 +87,10 @@ def _build_rs_sr_from_resource( ) output_json = cls.copy_cisu_input_content(edxl_json) - # Set a new distributionID for the RS-SR message - cls.set_distribution_id(output_json, f"{edxl_json['senderID']}_{uuid.uuid4()}") + if not use_original_distribution_id: + cls.set_distribution_id( + output_json, f"{edxl_json['senderID']}_{uuid.uuid4()}" + ) output_use_case_json = { "caseId": case_id, @@ -200,12 +206,17 @@ def from_cisu_to_rs(cls, edxl_json: Dict[str, Any]) -> List[Dict[str, Any]]: rs_ri = cls._build_rs_ri_from_cisu(edxl_json) messages.append(rs_ri) - for resource in modified_status_resources: + for idx, resource in enumerate(modified_status_resources): logger.info( "Resource %s has a modified status — adding RS-SR to output.", resource.get("resourceId"), ) - rs_sr = cls._build_rs_sr_from_resource(edxl_json, resource, case_id) + should_use_original_distribution_id = ( + not engaged_resources_updated and idx == 0 + ) + rs_sr = cls._build_rs_sr_from_resource( + edxl_json, resource, case_id, should_use_original_distribution_id + ) messages.append(rs_sr) if not messages: diff --git a/converter/tests/cisu/test_resources_info_converter.py b/converter/tests/cisu/test_resources_info_converter.py index 6162d8669..a51aed653 100644 --- a/converter/tests/cisu/test_resources_info_converter.py +++ b/converter/tests/cisu/test_resources_info_converter.py @@ -237,6 +237,9 @@ def test_from_cisu_to_rs_new_case_id(): assert "resourcesInfo" in first_message, ( "first message must be a RS-RI (resourcesInfo key expected)" ) + assert results[0]["distributionID"] == RC_RI_WITH_POSITION_EDXL["distributionID"], ( + "Converted RS-RI doesn't have the same distributionID as original RC-RI" + ) for i, rs_sr in enumerate(results[1:], start=1): message = get_edxl_message(rs_sr) @@ -393,6 +396,10 @@ def test_from_cisu_to_rs_known_case_id_status_changed_only(): assert isinstance(results, list), "from_cisu_to_rs must return a list" assert len(results) == 1, f"expected 1 RS-SR, got {len(results)}" + assert results[0]["distributionID"] == RC_RI_WITH_POSITION_EDXL["distributionID"], ( + "Converted RS-SR doesn't have the same distributionID as original RC-RI" + ) + message = get_edxl_message(results[0]) assert "resourcesStatus" in message, "expected RS-SR (resourcesStatus key)" assert "resourcesInfo" not in message, ( @@ -421,6 +428,9 @@ def test_from_cisu_to_rs_known_case_id_resource_added(): assert isinstance(results, list), "from_cisu_to_rs must return a list" assert len(results) == 2, f"expected RS-RI + RS-SR, got {len(results)}" + assert results[0]["distributionID"] == RC_RI_WITH_POSITION_EDXL["distributionID"], ( + "Converted RS-RI doesn't have the same distributionID as original RC-RI" + ) first_message = get_edxl_message(results[0]) assert "resourcesInfo" in first_message, (