Skip to content

Commit

Permalink
make project/description consistant
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Feb 11, 2020
1 parent 2955c5d commit 33363e8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
24 changes: 14 additions & 10 deletions ocdskit/oc4ids_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 8 additions & 3 deletions tests/test_oc4ids_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<ocds-213czf-1> A project description\n<ocds-213czf-2> 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():
Expand Down

0 comments on commit 33363e8

Please sign in to comment.