diff --git a/das-query-engine/tests/integration/handle/test_query_action.py b/das-query-engine/tests/integration/handle/test_query_action.py index 528ab3d..0a09afe 100644 --- a/das-query-engine/tests/integration/handle/test_query_action.py +++ b/das-query-engine/tests/integration/handle/test_query_action.py @@ -5,6 +5,8 @@ BaseTestHandlerAction, expression, inheritance, + similarity, + human, mammal, symbol, ) @@ -33,12 +35,45 @@ def valid_event(self, action_type): }, } } + + @pytest.fixture + def query_list(self, action_type): + return { + "body": { + "action": action_type, + "input": { + "query": [ + { + "atom_type": "link", + "type": expression, + "targets": [ + {"atom_type": "node", "type": symbol, "name": inheritance}, + {"atom_type": "variable", "name": "$v1"}, + {"atom_type": "node", "type": symbol, "name": mammal}, + ], + }, + { + "atom_type": "link", + "type": expression, + "targets": [ + {"atom_type": "node", "type": symbol, "name": similarity}, + {"atom_type": "variable", "name": "$v1"}, + {"atom_type": "node", "type": symbol, "name": human}, + ], + } + ] + }, + } + } + @pytest.mark.parametrize("query_input", ["valid_event", "query_list"]) def test_query_action( self, - valid_event, + request, + query_input, ): - body, status_code = self.make_request(valid_event) + query_data = request.getfixturevalue(query_input) + body, status_code = self.make_request(query_data) expected_status_code = 200 assert ( diff --git a/das-query-engine/validators/actions.py b/das-query-engine/validators/actions.py index 78839d5..12ad6c8 100644 --- a/das-query-engine/validators/actions.py +++ b/das-query-engine/validators/actions.py @@ -54,6 +54,9 @@ class QueryValidator(PayloadValidator): @staticmethod def validate_query(query, *args, **kwargs) -> bool: + if isinstance(query, list): + return all([QueryValidator.validate_query(q) for q in query]) + if not isinstance(query, dict): return False