Skip to content

Commit

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

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

def test_from_icat_sample_entity_without_data_for_related_entities(self):
icat_data = SAMPLE_ICAT_DATA.copy()
icat_data["parameters"] = [
{"type": PARAMETER_TYPE_ICAT_DATA},
]
sample_entity = models.Sample.from_icat(icat_data, [])

assert sample_entity.dict(by_alias=True) == SAMPLE_PANOSC_DATA

def test_from_icat_sample_entity_with_data_for_all_related_entities(self):
expected_entity_data = SAMPLE_PANOSC_DATA.copy()
expected_entity_data["datasets"] = [DATASET_PANOSC_DATA, DATASET_PANOSC_DATA]

icat_data = SAMPLE_ICAT_DATA.copy()
icat_data["parameters"] = [
{"type": PARAMETER_TYPE_ICAT_DATA},
]
icat_data["datasets"] = [DATASET_ICAT_DATA, DATASET_ICAT_DATA]

sample_entity = models.Sample.from_icat(icat_data, ["datasets"])

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

0 comments on commit 077c279

Please sign in to comment.