Skip to content

Commit

Permalink
test: unit test from_icat Person entity creation #265
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Jan 17, 2022
1 parent faed594 commit c05a70d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/search_api/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,22 @@ def test_from_icat_parameter_entity_with_dataset_parameter_data(self):
parameter_entity = models.Parameter.from_icat(icat_data, ["dataset"])

assert parameter_entity.dict(by_alias=True) == expected_entity_data

def test_from_icat_person_entity_without_data_for_related_entities(self):
person_entity = models.Person.from_icat(USER_ICAT_DATA, [])

assert person_entity.dict(by_alias=True) == PERSON_PANOSC_DATA

def test_from_icat_person_entity_with_data_for_all_related_entities(self):
expected_entity_data = PERSON_PANOSC_DATA.copy()
expected_entity_data["members"] = [MEMBER_PANOSC_DATA, MEMBER_PANOSC_DATA]

icat_data = USER_ICAT_DATA.copy()
icat_data["investigationUsers"] = [
INVESTIGATION_USER_ICAT_DATA,
INVESTIGATION_USER_ICAT_DATA,
]

person_entity = models.Person.from_icat(icat_data, ["members"])

assert person_entity.dict(by_alias=True) == expected_entity_data

0 comments on commit c05a70d

Please sign in to comment.