Skip to content

Commit

Permalink
Bugfix/correct the validation method on the concept object (#138)
Browse files Browse the repository at this point in the history
* Fixing the validation method on the Concept object.

* Bumping the version.

* Updating test data to contain the correct concept ids.

* Further version bump.

---------

Co-authored-by: Mark <[email protected]>
  • Loading branch information
THOR300 and Mark authored Oct 30, 2024
1 parent e698a36 commit 2ccde26
Show file tree
Hide file tree
Showing 4 changed files with 15,768 additions and 15,731 deletions.
19 changes: 10 additions & 9 deletions src/cpr_sdk/models/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,21 +95,22 @@ def validate_parent_concept_ids_flat(self) -> "Concept":
"""
Validate parent_concept_ids_flat field.
This field should hold the same concepts as the parent_concepts field.
This field should hold the same ids as concepts in the parent_concepts field.
"""
parent_concept_ids_flattened = ",".join(
[parent_concept["name"] for parent_concept in self.parent_concepts]
[parent_concept["id"] for parent_concept in self.parent_concepts]
)

if parent_concept_ids_flattened[-1] != ",":
parent_concept_ids_flattened += ","

if not self.parent_concept_ids_flat == parent_concept_ids_flattened:
if not (
self.parent_concept_ids_flat == parent_concept_ids_flattened
or self.parent_concept_ids_flat == parent_concept_ids_flattened + ","
):
raise ValueError(
"parent_concept_ids_flat must be a comma separated list of parent "
"concept names. "
f"Received parent_concept_ids_flat data: {self.parent_concept_ids_flat},"
f"received parent_concept names: {parent_concept_ids_flattened}"
"concept ids held in the parent concepts field. "
f"Received parent_concept_ids_flat: {self.parent_concept_ids_flat}\n"
"Received ids in the parent_concept objects: "
f"{parent_concept_ids_flattened}"
)
return self

Expand Down
2 changes: 1 addition & 1 deletion src/cpr_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_MAJOR = "1"
_MINOR = "9"
_PATCH = "2"
_PATCH = "3"
_SUFFIX = ""

VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
Expand Down
Loading

0 comments on commit 2ccde26

Please sign in to comment.