diff --git a/test/search_api/endpoints/test_get_entity_by_pid.py b/test/search_api/endpoints/test_get_entity_by_pid.py index cb656bf5..485a593c 100644 --- a/test/search_api/endpoints/test_get_entity_by_pid.py +++ b/test/search_api/endpoints/test_get_entity_by_pid.py @@ -410,10 +410,514 @@ class TestSearchAPIGetByPIDEndpoint: '{"include": [{"relation": "documents"},' ' {"relation": "files"}, {"relation": "parameters"},' ' {"relation": "samples"}]}', - {}, + { + "pid": "0-8401-1070-7", + "title": "DATASET 2", + "isPublic": True, + "creationDate": "2013-04-01T10:56:52+00:00", + "size": None, + "documents": [ + { + "pid": "0-9729806-3-6", + "isPublic": True, + "type": "INVESTIGATIONTYPE 1", + "title": "INVESTIGATION 2", + "summary": "Day purpose item create. Visit hope mean admit." + " The tonight adult cut foreign would situation fund." + "\nPurpose study usually gas think. Machine world doctor " + "rise be college treat.", + "doi": "0-9729806-3-6", + "startDate": "2000-06-04T00:00:00+00:00", + "endDate": "2000-09-14T00:00:00+00:00", + "releaseDate": "2000-02-10T00:00:00+00:00", + "license": None, + "keywords": [ + "later868", + "black887", + "yard993", + "as1034", + "sister1072", + "knowledge1239", + "heart1286", + "soon1911", + "television2011", + "turn2206", + "PM2477", + "purpose2641", + "box3225", + "fall3339", + "minute3394", + "family3729", + "industry3903", + "throw4294", + "here4636", + "firm4658", + "same4777", + "travel5029", + "like5061", + "but5204", + "pass5300", + "industry5482", + "they6191", + "company6197", + "bed6368", + "shake6405", + "voice6555", + "above6582", + "former6596", + "body6759", + "price6828", + "star6879", + "clearly7066", + "wall7234", + "ground7790", + "maybe8191", + "population8212", + "indeed8287", + "decide8366", + "agree9237", + "color9257", + "once9593", + "two9737", + "they10312", + "heavy10342", + "decide10450", + "main10579", + "particular10646", + "number11411", + "investment11462", + "interesting11775", + "simple12151", + "stand12178", + "morning12276", + "fish12494", + "story12572", + "art13071", + "once13596", + "music13672", + "film13812", + "level14266", + "claim14304", + "nearly14473", + "eight14566", + "president14766", + "near14993", + ], + "datasets": [], + "members": [], + "parameters": [], + }, + ], + "techniques": [], + "instrument": None, + "files": [ + { + "id": "1", + "name": "Datafile 1", + "path": "/hit/consumer/red.jpg", + "size": 199643799, + "dataset": None, + }, + { + "id": "10060", + "name": "Datafile 10060", + "path": "/the/current/next.jpg", + "size": 124327237, + "dataset": None, + }, + { + "id": "10539", + "name": "Datafile 10539", + "path": "/end/its/thought.png", + "size": 189420967, + "dataset": None, + }, + { + "id": "11018", + "name": "Datafile 11018", + "path": "/break/foot/color.jpg", + "size": 35048325, + "dataset": None, + }, + { + "id": "11497", + "name": "Datafile 11497", + "path": "/item/decision/well.png", + "size": 118626932, + "dataset": None, + }, + { + "id": "11976", + "name": "Datafile 11976", + "path": "/ahead/article/oil.jpg", + "size": 34418452, + "dataset": None, + }, + { + "id": "12455", + "name": "Datafile 12455", + "path": "/movement/job/whom.bmp", + "size": 139175969, + "dataset": None, + }, + { + "id": "12934", + "name": "Datafile 12934", + "path": "/office/mean/house.bmp", + "size": 92937891, + "dataset": None, + }, + { + "id": "13413", + "name": "Datafile 13413", + "path": "/democratic/catch/large.png", + "size": 179126789, + "dataset": None, + }, + { + "id": "13892", + "name": "Datafile 13892", + "path": "/become/answer/time.jpg", + "size": 6129000, + "dataset": None, + }, + { + "id": "14371", + "name": "Datafile 14371", + "path": "/on/training/upon.tiff", + "size": 112573570, + "dataset": None, + }, + { + "id": "1438", + "name": "Datafile 1438", + "path": "/nor/create/throw.tiff", + "size": 118142897, + "dataset": None, + }, + { + "id": "14850", + "name": "Datafile 14850", + "path": "/sell/involve/course.jpg", + "size": 210091940, + "dataset": None, + }, + { + "id": "15329", + "name": "Datafile 15329", + "path": "/less/fact/personal.bmp", + "size": 206394669, + "dataset": None, + }, + { + "id": "15808", + "name": "Datafile 15808", + "path": "/of/major/send.png", + "size": 12454385, + "dataset": None, + }, + { + "id": "16287", + "name": "Datafile 16287", + "path": "/threat/paper/reason.tiff", + "size": 72156314, + "dataset": None, + }, + { + "id": "16766", + "name": "Datafile 16766", + "path": "/order/moment/ahead.jpg", + "size": 209206676, + "dataset": None, + }, + { + "id": "17245", + "name": "Datafile 17245", + "path": "/apply/once/heart.tiff", + "size": 119539108, + "dataset": None, + }, + { + "id": "17724", + "name": "Datafile 17724", + "path": "/once/pull/home.bmp", + "size": 143503794, + "dataset": None, + }, + { + "id": "18203", + "name": "Datafile 18203", + "path": "/trip/that/help.png", + "size": 137082678, + "dataset": None, + }, + { + "id": "18682", + "name": "Datafile 18682", + "path": "/camera/until/person.jpeg", + "size": 9734061, + "dataset": None, + }, + { + "id": "19161", + "name": "Datafile 19161", + "path": "/director/reach/do.tiff", + "size": 81993307, + "dataset": None, + }, + { + "id": "1917", + "name": "Datafile 1917", + "path": "/her/camera/reason.jpg", + "size": 120538934, + "dataset": None, + }, + { + "id": "19640", + "name": "Datafile 19640", + "path": "/condition/woman/local.jpeg", + "size": 29793902, + "dataset": None, + }, + { + "id": "20119", + "name": "Datafile 20119", + "path": "/again/like/quite.jpg", + "size": 13941528, + "dataset": None, + }, + { + "id": "20598", + "name": "Datafile 20598", + "path": "/building/show/across.bmp", + "size": 106767153, + "dataset": None, + }, + { + "id": "21077", + "name": "Datafile 21077", + "path": "/nature/around/eye.png", + "size": 95175331, + "dataset": None, + }, + { + "id": "21556", + "name": "Datafile 21556", + "path": "/enter/finally/explain.tiff", + "size": 45086331, + "dataset": None, + }, + { + "id": "22035", + "name": "Datafile 22035", + "path": "/when/education/fund.gif", + "size": 150922750, + "dataset": None, + }, + { + "id": "22514", + "name": "Datafile 22514", + "path": "/rich/store/kitchen.bmp", + "size": 146576559, + "dataset": None, + }, + { + "id": "22993", + "name": "Datafile 22993", + "path": "/best/friend/car.bmp", + "size": 111680161, + "dataset": None, + }, + { + "id": "23472", + "name": "Datafile 23472", + "path": "/even/reach/artist.gif", + "size": 20868104, + "dataset": None, + }, + { + "id": "23951", + "name": "Datafile 23951", + "path": "/now/late/tonight.bmp", + "size": 51780738, + "dataset": None, + }, + { + "id": "2396", + "name": "Datafile 2396", + "path": "/model/quality/consumer.jpeg", + "size": 93486253, + "dataset": None, + }, + { + "id": "24430", + "name": "Datafile 24430", + "path": "/better/reduce/before.gif", + "size": 23636657, + "dataset": None, + }, + { + "id": "24909", + "name": "Datafile 24909", + "path": "/environment/foreign/often.gif", + "size": 209677116, + "dataset": None, + }, + { + "id": "25388", + "name": "Datafile 25388", + "path": "/near/specific/force.gif", + "size": 209279946, + "dataset": None, + }, + { + "id": "25867", + "name": "Datafile 25867", + "path": "/agent/story/single.gif", + "size": 113540888, + "dataset": None, + }, + { + "id": "26346", + "name": "Datafile 26346", + "path": "/theory/early/article.jpg", + "size": 204064131, + "dataset": None, + }, + { + "id": "2875", + "name": "Datafile 2875", + "path": "/election/people/may.tiff", + "size": 107424152, + "dataset": None, + }, + { + "id": "3354", + "name": "Datafile 3354", + "path": "/economy/manager/move.jpeg", + "size": 49217940, + "dataset": None, + }, + { + "id": "3833", + "name": "Datafile 3833", + "path": "/building/land/get.png", + "size": 95005906, + "dataset": None, + }, + { + "id": "4312", + "name": "Datafile 4312", + "path": "/religious/goal/customer.jpg", + "size": 175793879, + "dataset": None, + }, + { + "id": "4791", + "name": "Datafile 4791", + "path": "/now/pass/beautiful.png", + "size": 143040415, + "dataset": None, + }, + { + "id": "480", + "name": "Datafile 480", + "path": "/wall/doctor/either.jpeg", + "size": 176615561, + "dataset": None, + }, + { + "id": "5270", + "name": "Datafile 5270", + "path": "/sign/experience/two.png", + "size": 35763660, + "dataset": None, + }, + { + "id": "5749", + "name": "Datafile 5749", + "path": "/career/various/whether.png", + "size": 39359243, + "dataset": None, + }, + { + "id": "6228", + "name": "Datafile 6228", + "path": "/meet/modern/oil.png", + "size": 98442971, + "dataset": None, + }, + { + "id": "6707", + "name": "Datafile 6707", + "path": "/share/service/minute.jpg", + "size": 34981717, + "dataset": None, + }, + { + "id": "7186", + "name": "Datafile 7186", + "path": "/several/most/thought.gif", + "size": 107926403, + "dataset": None, + }, + { + "id": "7665", + "name": "Datafile 7665", + "path": "/maintain/me/although.jpeg", + "size": 94129376, + "dataset": None, + }, + { + "id": "8144", + "name": "Datafile 8144", + "path": "/huge/eat/section.jpg", + "size": 26196594, + "dataset": None, + }, + { + "id": "8623", + "name": "Datafile 8623", + "path": "/deep/weight/cell.gif", + "size": 63597912, + "dataset": None, + }, + { + "id": "9102", + "name": "Datafile 9102", + "path": "/wrong/increase/interest.jpg", + "size": 68604116, + "dataset": None, + }, + { + "id": "9581", + "name": "Datafile 9581", + "path": "/view/management/lawyer.gif", + "size": 183136479, + "dataset": None, + }, + { + "id": "959", + "name": "Datafile 959", + "path": "/nearly/school/lawyer.gif", + "size": 36259296, + "dataset": None, + }, + ], + "parameters": [], + "samples": [ + { + "name": "SAMPLE 2", + "pid": "pid:2", + "description": "Fill film Mr per sure task commercial " + "physical.\nForce discussion eat sign design. Story " + "follow few above loss. Challenge drop claim employee " + "dark.", + "datasets": [], + }, + ], + }, id="Get dataset by pid including all ICAT 4 related entities", - # Skipped due to #314 (Sample.pid) - marks=pytest.mark.skip, ), pytest.param( "datasets", diff --git a/test/search_api/filters/test_search_api_where_filter.py b/test/search_api/filters/test_search_api_where_filter.py index 7284a6cc..782a36f3 100644 --- a/test/search_api/filters/test_search_api_where_filter.py +++ b/test/search_api/filters/test_search_api_where_filter.py @@ -67,6 +67,18 @@ class TestSearchAPIWhereFilter: " s1 JOIN s1.investigation AS s2 WHERE s2.doi = 'Test DOI'", id="WHERE filter on ICAT related entity with three PaNOSC hops", ), + pytest.param( + SearchAPIWhereFilter("samples.pid", "1", "eq"), + "Dataset", + "SELECT o FROM Dataset o JOIN o.sample AS s1 WHERE s1.pid = '1'", + id="Id sample value (mapping that maps to multiple ICAT fields)", + ), + pytest.param( + SearchAPIWhereFilter("samples.pid", "pid:1", "eq"), + "Dataset", + "SELECT o FROM Dataset o JOIN o.sample AS s1 WHERE s1.id = '1'", + id="Pid sample value (mapping that maps to multiple ICAT fields)", + ), pytest.param( SearchAPIWhereFilter("parameters.value", "My Parameter", "eq"), "Document", diff --git a/test/search_api/test_models.py b/test/search_api/test_models.py index df6aa84b..baf34e1a 100644 --- a/test/search_api/test_models.py +++ b/test/search_api/test_models.py @@ -157,7 +157,7 @@ } SAMPLE_ICAT_DATA = { - "pid": "None", + "pid": "Test pid", "modId": "Test modId", "createId": "Test createId", "name": "Test name", @@ -347,7 +347,8 @@ def test_from_icat_dataset_entity_with_data_for_all_related_entities(self): expected_entity_data["parameters"][0]["value"] = DATASET_PARAMETER_ICAT_DATA[ "stringValue" ] - expected_entity_data["samples"] = [SAMPLE_PANOSC_DATA] + expected_entity_data["samples"] = [SAMPLE_PANOSC_DATA.copy()] + expected_entity_data["samples"][0]["pid"] = f"pid:{SAMPLE_ICAT_DATA['id']}" icat_data = DATASET_ICAT_DATA.copy() icat_data["investigation"] = INVESTIGATION_ICAT_DATA.copy() @@ -368,6 +369,7 @@ def test_from_icat_dataset_entity_with_data_for_all_related_entities(self): icat_data["parameters"] = [DATASET_PARAMETER_ICAT_DATA.copy()] icat_data["parameters"][0]["type"] = PARAMETER_TYPE_ICAT_DATA icat_data["sample"] = SAMPLE_ICAT_DATA.copy() + icat_data["sample"]["pid"] = None icat_data["sample"]["parameters"] = [ {"type": PARAMETER_TYPE_ICAT_DATA}, {"type": PARAMETER_TYPE_ICAT_DATA},