Skip to content

Commit

Permalink
test: unit test from_icat Instrument entity creation #265
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Jan 17, 2022
1 parent 0554bea commit 0d0a1e4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/search_api/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,23 @@ def test_from_icat_file_entity_with_data_for_all_related_entities(self):
file_entity = models.File.from_icat(icat_data, [])

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

def test_from_icat_instrument_entity_without_data_for_related_entities(self):
icat_data = INSTRUMENT_ICAT_DATA.copy()
icat_data["facility"] = FACILITY_ICAT_DATA

instrument_entity = models.Instrument.from_icat(icat_data, [])

assert instrument_entity.dict(by_alias=True) == INSTRUMENT_PANOSC_DATA

def test_from_icat_instrument_entity_with_data_for_all_related_entities(self):
expected_entity_data = INSTRUMENT_PANOSC_DATA.copy()
expected_entity_data["datasets"] = [DATASET_PANOSC_DATA]

icat_data = INSTRUMENT_ICAT_DATA.copy()
icat_data["facility"] = FACILITY_ICAT_DATA
icat_data["datasetInstruments"] = [{"dataset": DATASET_ICAT_DATA.copy()}]

instrument_entity = models.Instrument.from_icat(icat_data, ["datasets"])

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

0 comments on commit 0d0a1e4

Please sign in to comment.