Skip to content
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

fix: REST API treat 'false' as False #5573

Merged
merged 7 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aiida/restapi/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ def parse_query_string(self, query_string):
)
# Value types
value_num = ppc.number
value_bool = (Literal('true') | Literal('false')).addParseAction(lambda toks: bool(toks[0]))
value_bool = (Literal('true') | Literal('false')).addParseAction(lambda toks: toks[0] == 'true')
eimrek marked this conversation as resolved.
Show resolved Hide resolved
value_string = QuotedString('"', escQuote='""')
value_orderby = Combine(Optional(Word('+-', exact=1)) + key)

Expand Down
5 changes: 3 additions & 2 deletions tests/restapi/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,15 +1014,16 @@ def test_structure_download(self):
structure_data = load_node(node_uuid)._exportcontent('xsf')[0] # pylint: disable=protected-access
assert rv_obj.data == structure_data

def test_structure_download_false(self):
@pytest.mark.parametrize('download', ['false', 'False'])
def test_structure_download_false(self, download):
"""
Test download=false that displays the content in the browser instead
of downloading the structure file
"""
from aiida.orm import load_node

node_uuid = self.get_dummy_data()['structuredata'][0]['uuid']
url = f'{self.get_url_prefix()}/nodes/{node_uuid}/download?download_format=xsf&download=False'
url = f'{self.get_url_prefix()}/nodes/{node_uuid}/download?download_format=xsf&download={download}'
with self.app.test_client() as client:
rv_obj = client.get(url)
response = json.loads(rv_obj.data)
Expand Down