| 130 | |
| 131 | |
| 132 | def run_group_graphql_test(queries_and_expected_outputs, graph, sort_output=False): |
| 133 | tmp_work_dir = tempfile.mkdtemp() |
| 134 | with GraphServer(tmp_work_dir).start() as server: |
| 135 | client = server.get_client() |
| 136 | client.send_graph(path="g", graph=graph) |
| 137 | |
| 138 | for query, expected_output in queries_and_expected_outputs: |
| 139 | response = client.query(query) |
| 140 | response_dict = ( |
| 141 | json.loads(response) if isinstance(response, str) else response |
| 142 | ) |
| 143 | if sort_output: |
| 144 | response_dict = sort_by_gql_name_or_id(response_dict) |
| 145 | expected_output = sort_by_gql_name_or_id(expected_output) |
| 146 | assert ( |
| 147 | response_dict == expected_output |
| 148 | ), f"Expected:\n{sort_dict_recursive(expected_output)}\nGot:\n{sort_dict_recursive(response_dict)}" |
| 149 | |
| 150 | |
| 151 | def run_graphql_error_test(query, expected_error_message, graph): |