|
21 | 21 | # Choose which server to test |
22 | 22 | # cr.server = 'https://dev.cohd.io/api' |
23 | 23 | cr.server = 'https://cohd-api.ci.transltr.io/api' |
24 | | -# cr.server = 'https://cohd-api.test.transltr.io/api' |
| 24 | +# cr.server = 'https://cohd-api.test.transltr.io/api' |
25 | 25 | # cr.server = 'https://cohd-api.transltr.io/api' |
26 | 26 |
|
27 | 27 | # Specify what Biolink and TRAPI versions are expected by the server |
@@ -927,6 +927,242 @@ def test_translator_query_qnode_empty_constraint(): |
927 | 927 | assert len(json['message']['results']) >= 1, _print_trapi_log(json) |
928 | 928 |
|
929 | 929 |
|
| 930 | +def test_translator_set_input_query(): |
| 931 | + """ Check the TRAPI endpoint to make sure it returns properly formatted TRAPI for set-input query. """ |
| 932 | + print(f'\ntest_cohd_trapi::test_translator_set_input_query: testing TRAPI set-input query on {cr.server}..... ') |
| 933 | + |
| 934 | + url = f'{cr.server}/query' |
| 935 | + |
| 936 | + # Query with empty constraints |
| 937 | + query = ''' |
| 938 | + { |
| 939 | + "message": { |
| 940 | + "query_graph": { |
| 941 | + "nodes": { |
| 942 | + "input": { |
| 943 | + "categories": [ |
| 944 | + "biolink:PhenotypicFeature" |
| 945 | + ], |
| 946 | + "ids": [ |
| 947 | + "uuid:1" |
| 948 | + ], |
| 949 | + "member_ids": [ |
| 950 | + "HP:0000739", |
| 951 | + "HP:0001288", |
| 952 | + "HP:0001252", |
| 953 | + "HP:0001250", |
| 954 | + "HP:0000750", |
| 955 | + "HP:0002378", |
| 956 | + "HP:0002019", |
| 957 | + "HP:0007146" |
| 958 | + ], |
| 959 | + "set_interpretation": "MANY" |
| 960 | + }, |
| 961 | + "output": { |
| 962 | + "categories": [ |
| 963 | + "biolink:Disease" |
| 964 | + ] |
| 965 | + } |
| 966 | + }, |
| 967 | + "edges": { |
| 968 | + "edge_0": { |
| 969 | + "subject": "input", |
| 970 | + "object": "output", |
| 971 | + "predicates": [ |
| 972 | + "biolink:correlated_with" |
| 973 | + ] |
| 974 | + } |
| 975 | + } |
| 976 | + }, |
| 977 | + "knowledge_graph": { |
| 978 | + "nodes": { |
| 979 | + "uuid:1": { |
| 980 | + "categories": [ |
| 981 | + "biolink:PhenotypicFeature" |
| 982 | + ], |
| 983 | + "is_set": true, |
| 984 | + "name": "set1", |
| 985 | + "attributes": [] |
| 986 | + }, |
| 987 | + "HP:0000739": { |
| 988 | + "categories": [ |
| 989 | + "biolink:PhenotypicFeature" |
| 990 | + ], |
| 991 | + "is_set": false, |
| 992 | + "attributes": [] |
| 993 | + }, |
| 994 | + "HP:0001288": { |
| 995 | + "categories": [ |
| 996 | + "biolink:PhenotypicFeature" |
| 997 | + ], |
| 998 | + "is_set": false, |
| 999 | + "attributes": [] |
| 1000 | + }, |
| 1001 | + "HP:0001252": { |
| 1002 | + "categories": [ |
| 1003 | + "biolink:PhenotypicFeature" |
| 1004 | + ], |
| 1005 | + "is_set": false, |
| 1006 | + "attributes": [] |
| 1007 | + }, |
| 1008 | + "HP:0001250": { |
| 1009 | + "categories": [ |
| 1010 | + "biolink:PhenotypicFeature" |
| 1011 | + ], |
| 1012 | + "is_set": false, |
| 1013 | + "attributes": [] |
| 1014 | + }, |
| 1015 | + "HP:0000750": { |
| 1016 | + "categories": [ |
| 1017 | + "biolink:PhenotypicFeature" |
| 1018 | + ], |
| 1019 | + "is_set": false, |
| 1020 | + "attributes": [] |
| 1021 | + }, |
| 1022 | + "HP:0002378": { |
| 1023 | + "categories": [ |
| 1024 | + "biolink:PhenotypicFeature" |
| 1025 | + ], |
| 1026 | + "is_set": false, |
| 1027 | + "attributes": [] |
| 1028 | + }, |
| 1029 | + "HP:0002019": { |
| 1030 | + "categories": [ |
| 1031 | + "biolink:PhenotypicFeature" |
| 1032 | + ], |
| 1033 | + "is_set": false, |
| 1034 | + "attributes": [] |
| 1035 | + }, |
| 1036 | + "HP:0007146": { |
| 1037 | + "categories": [ |
| 1038 | + "biolink:PhenotypicFeature" |
| 1039 | + ], |
| 1040 | + "is_set": false, |
| 1041 | + "attributes": [] |
| 1042 | + } |
| 1043 | + }, |
| 1044 | + "edges": { |
| 1045 | + "kgedge_member_of_0001": { |
| 1046 | + "attributes": [], |
| 1047 | + "object": "uuid:1", |
| 1048 | + "predicate": "biolink:member_of", |
| 1049 | + "sources": [ |
| 1050 | + { |
| 1051 | + "resource_id": "infores:user-interface", |
| 1052 | + "resource_role": "primary_knowledge_source" |
| 1053 | + } |
| 1054 | + ], |
| 1055 | + "subject": "HP:0000739" |
| 1056 | + }, |
| 1057 | + "kgedge_member_of_0002": { |
| 1058 | + "attributes": [], |
| 1059 | + "object": "uuid:1", |
| 1060 | + "predicate": "biolink:member_of", |
| 1061 | + "sources": [ |
| 1062 | + { |
| 1063 | + "resource_id": "infores:user-interface", |
| 1064 | + "resource_role": "primary_knowledge_source" |
| 1065 | + } |
| 1066 | + ], |
| 1067 | + "subject": "HP:0001288" |
| 1068 | + }, |
| 1069 | + "kgedge_member_of_0003": { |
| 1070 | + "attributes": [], |
| 1071 | + "object": "uuid:1", |
| 1072 | + "predicate": "biolink:member_of", |
| 1073 | + "sources": [ |
| 1074 | + { |
| 1075 | + "resource_id": "infores:user-interface", |
| 1076 | + "resource_role": "primary_knowledge_source" |
| 1077 | + } |
| 1078 | + ], |
| 1079 | + "subject": "HP:0001252" |
| 1080 | + }, |
| 1081 | + "kgedge_member_of_0004": { |
| 1082 | + "attributes": [], |
| 1083 | + "object": "uuid:1", |
| 1084 | + "predicate": "biolink:member_of", |
| 1085 | + "sources": [ |
| 1086 | + { |
| 1087 | + "resource_id": "infores:user-interface", |
| 1088 | + "resource_role": "primary_knowledge_source" |
| 1089 | + } |
| 1090 | + ], |
| 1091 | + "subject": "HP:0001250" |
| 1092 | + }, |
| 1093 | + "kgedge_member_of_0005": { |
| 1094 | + "attributes": [], |
| 1095 | + "object": "uuid:1", |
| 1096 | + "predicate": "biolink:member_of", |
| 1097 | + "sources": [ |
| 1098 | + { |
| 1099 | + "resource_id": "infores:user-interface", |
| 1100 | + "resource_role": "primary_knowledge_source" |
| 1101 | + } |
| 1102 | + ], |
| 1103 | + "subject": "HP:0000750" |
| 1104 | + }, |
| 1105 | + "kgedge_member_of_0006": { |
| 1106 | + "attributes": [], |
| 1107 | + "object": "uuid:1", |
| 1108 | + "predicate": "biolink:member_of", |
| 1109 | + "sources": [ |
| 1110 | + { |
| 1111 | + "resource_id": "infores:user-interface", |
| 1112 | + "resource_role": "primary_knowledge_source" |
| 1113 | + } |
| 1114 | + ], |
| 1115 | + "subject": "HP:0002378" |
| 1116 | + }, |
| 1117 | + "kgedge_member_of_0007": { |
| 1118 | + "attributes": [], |
| 1119 | + "object": "uuid:1", |
| 1120 | + "predicate": "biolink:member_of", |
| 1121 | + "sources": [ |
| 1122 | + { |
| 1123 | + "resource_id": "infores:user-interface", |
| 1124 | + "resource_role": "primary_knowledge_source" |
| 1125 | + } |
| 1126 | + ], |
| 1127 | + "subject": "HP:0002019" |
| 1128 | + }, |
| 1129 | + "kgedge_member_of_0008": { |
| 1130 | + "attributes": [], |
| 1131 | + "object": "uuid:1", |
| 1132 | + "predicate": "biolink:member_of", |
| 1133 | + "sources": [ |
| 1134 | + { |
| 1135 | + "resource_id": "infores:user-interface", |
| 1136 | + "resource_role": "primary_knowledge_source" |
| 1137 | + } |
| 1138 | + ], |
| 1139 | + "subject": "HP:0007146" |
| 1140 | + } |
| 1141 | + } |
| 1142 | + } |
| 1143 | + }, |
| 1144 | + "query_options": { |
| 1145 | + "max_results": 10 |
| 1146 | + } |
| 1147 | + } |
| 1148 | + ''' |
| 1149 | + query = j.loads(query) |
| 1150 | + query['query_options']['query_id'] = str(uuid.uuid4()) |
| 1151 | + print(j.dumps(query)) |
| 1152 | + resp = requests.post(url, json=query, timeout=300) |
| 1153 | + |
| 1154 | + # Expect HTTP 200 status response |
| 1155 | + assert resp.status_code == 200, 'Expected an HTTP 200 status response code' \ |
| 1156 | + f'Received {resp.status_code}: {resp.text}' |
| 1157 | + |
| 1158 | + # Use the Reasoner Validator Python package to validate against Reasoner Standard API |
| 1159 | + json = resp.json() |
| 1160 | + _validate_trapi_response(json) |
| 1161 | + |
| 1162 | + # There should be at least 1 result |
| 1163 | + assert len(json['message']['results']) >= 1, _print_trapi_log(json) |
| 1164 | + |
| 1165 | + |
930 | 1166 | def test_translator_workflows(): |
931 | 1167 | """ Check the TRAPI endpoint to make sure COHD only responds when workflow is a single lookup operation. """ |
932 | 1168 | print(f'\ntest_cohd_trapi::test_translator_workflows: testing TRAPI query with workflows on {cr.server}..... ') |
|
0 commit comments