Skip to content

Commit

Permalink
test: fix tests following updates to PaNOSC Parameter mappings #265
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Jan 28, 2022
1 parent 1e8badb commit d595ceb
Showing 1 changed file with 4 additions and 31 deletions.
35 changes: 4 additions & 31 deletions test/search_api/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,26 +498,15 @@ def test_from_icat_parameter_entity_without_data_for_related_entities(self):

def test_from_icat_parameter_entity_with_investigation_parameter_data(self):
expected_entity_data = PARAMETER_PANOSC_DATA.copy()
expected_entity_data["dataset"] = DATASET_PANOSC_DATA
expected_entity_data["document"] = DOCUMENT_PANOSC_DATA

icat_data = INVESTIGATION_PARAMETER_ICAT_DATA.copy()
icat_data["type"] = PARAMETER_TYPE_ICAT_DATA
icat_data["investigation"] = INVESTIGATION_ICAT_DATA.copy()
icat_data["investigation"]["type"] = INVESTIGATION_TYPE_ICAT_DATA
icat_data["investigation"]["keywords"] = [KEYWORD_ICAT_DATA]
icat_data["investigation"]["investigationInstruments"] = [
{"instrument": INSTRUMENT_ICAT_DATA.copy()},
{"instrument": INSTRUMENT_ICAT_DATA.copy()},
]
icat_data["investigation"]["investigationInstruments"][0]["instrument"][
"datasetInstruments"
] = [{"dataset": DATASET_ICAT_DATA}, {"dataset": DATASET_ICAT_DATA}]
icat_data["investigation"]["investigationInstruments"][1]["instrument"][
"datasetInstruments"
] = []

parameter_entity = models.Parameter.from_icat(icat_data, ["dataset"])
parameter_entity = models.Parameter.from_icat(icat_data, ["document"])

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

Expand Down Expand Up @@ -613,13 +602,7 @@ def test_from_icat_multiple_and_nested_relations(self):
expected_entity_data["members"][0]["affiliation"] = AFFILIATION_PANOSC_DATA
expected_entity_data["members"][0]["person"] = PERSON_PANOSC_DATA
expected_entity_data["parameters"] = [PARAMETER_PANOSC_DATA.copy()]
expected_entity_data["parameters"][0]["value"]
expected_entity_data["parameters"][0]["dataset"] = DATASET_PANOSC_DATA.copy()
expected_entity_data["parameters"][0]["document"] = DOCUMENT_PANOSC_DATA.copy()
expected_entity_data["parameters"][0]["document"]["keywords"] = []
expected_entity_data["parameters"][0]["dataset"]["techniques"] = [
TECHNIQUE_PANOSC_DATA,
]
expected_entity_data["parameters"][0]["document"] = DOCUMENT_PANOSC_DATA

icat_data = INVESTIGATION_ICAT_DATA.copy()
icat_data["type"] = INVESTIGATION_TYPE_ICAT_DATA
Expand All @@ -645,17 +628,7 @@ def test_from_icat_multiple_and_nested_relations(self):
icat_data["parameters"][0]["investigation"][
"type"
] = INVESTIGATION_TYPE_ICAT_DATA
dataset_with_techniques_icat = DATASET_ICAT_DATA.copy()
dataset_with_techniques_icat.update(
{"datasetTechniques": [{"technique": TECHNIQUE_ICAT_DATA}]},
)
icat_data["parameters"][0]["investigation"]["investigationInstruments"] = [
{
"instrument": {
"datasetInstruments": [{"dataset": dataset_with_techniques_icat}],
},
},
]
icat_data["parameters"][0]["investigation"]["keywords"] = [KEYWORD_ICAT_DATA]

relations = [
"datasets.instrument",
Expand All @@ -664,7 +637,7 @@ def test_from_icat_multiple_and_nested_relations(self):
"datasets.samples",
"members.affiliation",
"members.person",
"parameters.dataset.techniques",
"parameters.document",
]

document_entity = models.Document.from_icat(icat_data, relations)
Expand Down

0 comments on commit d595ceb

Please sign in to comment.