Skip to content

Commit

Permalink
Added test that returns invalid mongo query
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Mar 6, 2020
1 parent a050705 commit 70e9e44
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/server/test_query_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,29 @@ def test_list_has_and(self):
expected_ids = ["mpf_1"]
self._check_response(request, expected_ids, len(expected_ids))

def test_awkward_not_queries(self):
""" Test an awkward query from the spec examples. It should return all but 2 structures
in the test data.
"""
request = "/structures"
unexpected_ids = ["mpf_3819", "mpf_3"]
expected_ids = [
struct["id"]
for struct in self.client.get(request).json()["data"]
if struct["id"] not in unexpected_ids
]
request = (
"/structures?filter="
"NOT ("
'chemical_formula_hill = "Ba2NaTi2MnRe2Si8HO26F" AND '
'chemical_formula_anonymous = "A26B8C2D2E2FGHI" OR '
'chemical_formula_anonymous = "A2BC" AND '
'NOT chemical_formula_hill = "Ac2AgPb" '
")"
)
self._check_response(request, expected_ids, len(expected_ids))

def test_not_or_and_precedence(self):
request = '/structures?filter=NOT elements HAS "Ac" AND nelements=1'
expected_ids = ["mpf_200"]
Expand Down

0 comments on commit 70e9e44

Please sign in to comment.