Skip to content

Commit 5ea4276

Browse files
authored
Merge pull request #399 from ansforge/rc-ri-use-original-distribution-id
Converter : transmission du distributionID original pour la conversion RC-RI dans le sens 18-15
2 parents b851b51 + 8e67200 commit 5ea4276

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

.github/workflows/converter-tests.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,9 @@ jobs:
6363
path: tools/converter/htmlcov
6464
retention-days: 7
6565

66-
- name: Run ReportGenerator for test coverage
67-
uses: danielpalme/ReportGenerator-GitHub-Action@5.1.23
68-
with:
69-
reports: ./converter/coverage.xml
70-
targetdir: coveragereport
7166

7267
- name: Pytest coverage comment
73-
uses: MishaKav/pytest-coverage-comment@v1.1.53
68+
uses: MishaKav/pytest-coverage-comment@v1.7.1
7469
with:
7570
pytest-xml-coverage-path: ./converter/coverage.xml
7671
title: "Converter - python code coverage"

converter/converter/cisu/resources_info/resources_info_cisu_converter.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ def _build_rs_ri_from_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]:
7373

7474
@classmethod
7575
def _build_rs_sr_from_resource(
76-
cls, edxl_json: Dict[str, Any], resource: Dict[str, Any], case_id: str
76+
cls,
77+
edxl_json: Dict[str, Any],
78+
resource: Dict[str, Any],
79+
case_id: str,
80+
use_original_distribution_id: bool = False,
7781
) -> Dict[str, Any]:
7882
"""Build an RS-SR from a single RC-RI resource, reusing the EDXL envelope."""
7983
logger.info(
@@ -83,8 +87,10 @@ def _build_rs_sr_from_resource(
8387
)
8488
output_json = cls.copy_cisu_input_content(edxl_json)
8589

86-
# Set a new distributionID for the RS-SR message
87-
cls.set_distribution_id(output_json, f"{edxl_json['senderID']}_{uuid.uuid4()}")
90+
if not use_original_distribution_id:
91+
cls.set_distribution_id(
92+
output_json, f"{edxl_json['senderID']}_{uuid.uuid4()}"
93+
)
8894

8995
output_use_case_json = {
9096
"caseId": case_id,
@@ -200,12 +206,17 @@ def from_cisu_to_rs(cls, edxl_json: Dict[str, Any]) -> List[Dict[str, Any]]:
200206
rs_ri = cls._build_rs_ri_from_cisu(edxl_json)
201207
messages.append(rs_ri)
202208

203-
for resource in modified_status_resources:
209+
for idx, resource in enumerate(modified_status_resources):
204210
logger.info(
205211
"Resource %s has a modified status — adding RS-SR to output.",
206212
resource.get("resourceId"),
207213
)
208-
rs_sr = cls._build_rs_sr_from_resource(edxl_json, resource, case_id)
214+
should_use_original_distribution_id = (
215+
not engaged_resources_updated and idx == 0
216+
)
217+
rs_sr = cls._build_rs_sr_from_resource(
218+
edxl_json, resource, case_id, should_use_original_distribution_id
219+
)
209220
messages.append(rs_sr)
210221

211222
if not messages:

converter/tests/cisu/test_resources_info_converter.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ def test_from_cisu_to_rs_new_case_id():
237237
assert "resourcesInfo" in first_message, (
238238
"first message must be a RS-RI (resourcesInfo key expected)"
239239
)
240+
assert results[0]["distributionID"] == RC_RI_WITH_POSITION_EDXL["distributionID"], (
241+
"Converted RS-RI doesn't have the same distributionID as original RC-RI"
242+
)
240243

241244
for i, rs_sr in enumerate(results[1:], start=1):
242245
message = get_edxl_message(rs_sr)
@@ -393,6 +396,10 @@ def test_from_cisu_to_rs_known_case_id_status_changed_only():
393396

394397
assert isinstance(results, list), "from_cisu_to_rs must return a list"
395398
assert len(results) == 1, f"expected 1 RS-SR, got {len(results)}"
399+
assert results[0]["distributionID"] == RC_RI_WITH_POSITION_EDXL["distributionID"], (
400+
"Converted RS-SR doesn't have the same distributionID as original RC-RI"
401+
)
402+
396403
message = get_edxl_message(results[0])
397404
assert "resourcesStatus" in message, "expected RS-SR (resourcesStatus key)"
398405
assert "resourcesInfo" not in message, (
@@ -421,6 +428,9 @@ def test_from_cisu_to_rs_known_case_id_resource_added():
421428

422429
assert isinstance(results, list), "from_cisu_to_rs must return a list"
423430
assert len(results) == 2, f"expected RS-RI + RS-SR, got {len(results)}"
431+
assert results[0]["distributionID"] == RC_RI_WITH_POSITION_EDXL["distributionID"], (
432+
"Converted RS-RI doesn't have the same distributionID as original RC-RI"
433+
)
424434

425435
first_message = get_edxl_message(results[0])
426436
assert "resourcesInfo" in first_message, (

0 commit comments

Comments
 (0)