-
Notifications
You must be signed in to change notification settings - Fork 226
REST API: POST endpoint for QueryBuilder queryhelp JSON payloads #4337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -563,10 +563,10 @@ def get_formatted_result(self, label): | |
|
||
for node_entry in results[result_name]: | ||
# construct full_type and add it to every node | ||
try: | ||
node_entry['full_type'] = construct_full_type(node_entry['node_type'], node_entry['process_type']) | ||
except KeyError: | ||
node_entry['full_type'] = None | ||
node_entry['full_type'] = ( | ||
construct_full_type(node_entry.get('node_type'), node_entry.get('process_type')) | ||
if node_entry.get('node_type') or node_entry.get('process_type') else None | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, so here is where the And, finally, I guess you tried before instead of setting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, so this is what I tried to explain in previous comment answers. It's worth noting that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It was more of a conscious choice to make the response as AiiDA REST API-like as possible. Including all the extra properties expected from any other AiiDA REST API response for the various entities. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main issue here relates to the fact that the REST API was not built to return multiple types of entities (this has been mentioned in issue #4676 as well). So I need a "catch-em-all"/"works-for-all"-translator :) |
||
|
||
return results | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
########################################################################### | ||
# Copyright (c), The AiiDA team. All rights reserved. # | ||
# This file is part of the AiiDA code. # | ||
# # | ||
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # | ||
# For further information on the license, see the LICENSE.txt file # | ||
# For further information please visit http://www.aiida.net # | ||
########################################################################### | ||
"""Tests for the configuration options from `aiida.restapi.common.config` when running the REST API.""" | ||
# pylint: disable=redefined-outer-name | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def create_app(): | ||
"""Set up Flask App""" | ||
from aiida.restapi.run_api import configure_api | ||
|
||
def _create_app(**kwargs): | ||
catch_internal_server = kwargs.pop('catch_internal_server', True) | ||
api = configure_api(catch_internal_server=catch_internal_server, **kwargs) | ||
api.app.config['TESTING'] = True | ||
return api.app | ||
|
||
return _create_app | ||
|
||
|
||
def test_posting(create_app): | ||
"""Test CLI_DEFAULTS['POSTING'] configuration""" | ||
from aiida.restapi.common.config import API_CONFIG | ||
|
||
app = create_app(posting=False) | ||
|
||
url = f'{API_CONFIG["PREFIX"]}/querybuilder' | ||
for method in ('get', 'post'): | ||
with app.test_client() as client: | ||
response = getattr(client, method)(url) | ||
|
||
assert response.status_code == 404 | ||
assert response.status == '404 NOT FOUND' | ||
|
||
del app | ||
app = create_app(posting=True) | ||
|
||
url = f'{API_CONFIG["PREFIX"]}/querybuilder' | ||
for method in ('get', 'post'): | ||
with app.test_client() as client: | ||
response = getattr(client, method)(url) | ||
|
||
assert response.status_code != 404 | ||
assert response.status != '404 NOT FOUND' |
Uh oh!
There was an error while loading. Please reload this page.