diff --git a/ocdskit/oc4ids_transforms.py b/ocdskit/oc4ids_transforms.py index 9f7a4675..0e89f847 100644 --- a/ocdskit/oc4ids_transforms.py +++ b/ocdskit/oc4ids_transforms.py @@ -649,18 +649,22 @@ def description(state): """ CoST IDS element: Project description """ - if len(state.compiled_releases) == 1: - description = resolve_pointer(state.compiled_releases[0], "/planning/project/description", None) + output_description = None + + for compiled_release in state.compiled_releases: + description = resolve_pointer(compiled_release, "/planning/project/description", None) if description: - state.output["description"] = description - return True + if output_description and output_description != description: + logger.warn( + "Multiple differing planning/project/descriptions found eg. {}, {}, skipping conversion".format( + description, output_description + ) + ) + return + output_description = description - else: - descriptions = concat_ocid_and_string(state, "/planning/project/description") - if descriptions != "": - state.output["description"] = descriptions - return True - return False + if output_description: + state.output["description"] = output_description def description_tender(state): diff --git a/tests/test_oc4ids_transforms.py b/tests/test_oc4ids_transforms.py index fe641793..84ac5261 100644 --- a/tests/test_oc4ids_transforms.py +++ b/tests/test_oc4ids_transforms.py @@ -1158,14 +1158,19 @@ def test_description_multiple(): "id": "2", "tag": "planning", "date": "2001-02-03T04:05:06Z", - "planning": {"project": {"description": "Another project description"}}, + "planning": {"project": {"description": "A project description"}}, }, ] - rationales = " A project description\n Another project description\n" + output = transforms._run_transforms(copy.deepcopy(releases), "1", transforms=[transforms.description],) + assert output["description"] == releases[0]["planning"]["project"]["description"] + + # contraditing descriptions + releases[0]["planning"]["project"]["description"] = "another description" output = transforms._run_transforms(copy.deepcopy(releases), "1", transforms=[transforms.description],) - assert output["description"] == rationales + + assert "description" not in output def test_description_tender():