Skip to content

Commit

Permalink
Add null fields to test data
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed May 11, 2021
1 parent 8f7e50d commit e55b6ba
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
17 changes: 17 additions & 0 deletions optimade/server/data/test_structures.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"_id": {
"$oid": "5cfb441f053b174410700d02"
},
"assemblies": null,
"chemsys": "Ac",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -78,6 +79,7 @@
"_id": {
"$oid": "5cfb441f053b174410700d03"
},
"assemblies": null,
"chemsys": "Ac-Ag-Ir",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -193,6 +195,7 @@
"_id": {
"$oid": "5cfb441f053b174410700d04"
},
"assemblies": null,
"chemsys": "Ac-Ag-Pb",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -308,6 +311,7 @@
"_id": {
"$oid": "5cfb441f053b174410700d18"
},
"assemblies": null,
"chemsys": "Ac-Mg",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -396,6 +400,7 @@
"_id": {
"$oid": "5cfb441f053b174410700d1f"
},
"assemblies": null,
"chemsys": "Ac-O",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -496,6 +501,7 @@
"_id": {
"$oid": "5cfb441f053b174410700d6f"
},
"assemblies": null,
"chemsys": "Ac-Cu-F-O",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -618,6 +624,7 @@
"_id": {
"$oid": "5cfb441f053b174410700dc9"
},
"assemblies": null,
"chemsys": "Ag",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -683,6 +690,7 @@
"_id": {
"$oid": "5cfb441f053b174410700ddd"
},
"assemblies": null,
"chemsys": "Ag-Br-Cl-Te",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -871,6 +879,7 @@
"_id": {
"$oid": "5cfb441f053b174410700e04"
},
"assemblies": null,
"chemsys": "Ag-C-Cl-N-O-S",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -1045,6 +1054,7 @@
"_id": {
"$oid": "5cfb441f053b174410700e11"
},
"assemblies": null,
"chemsys": "Ag-C-Cl-H-N",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -1292,6 +1302,7 @@
"_id": {
"$oid": "5cfb441f053b174410700e15"
},
"assemblies": null,
"chemsys": "Ag-C-H-N-O",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -1545,6 +1556,7 @@
"_id": {
"$oid": "5cfb441f053b174410700e1a"
},
"assemblies": null,
"chemsys": "Ag-C-Cl-H-N-O-S",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -1808,6 +1820,7 @@
"_id": {
"$oid": "5cfb441f053b174410700ebf"
},
"assemblies": null,
"chemsys": "Ag-Br-Cl-Hg-I-S",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -2030,6 +2043,7 @@
"_id": {
"$oid": "5cfb441f053b174410700f28"
},
"assemblies": null,
"chemsys": "Ag-B-C-Cl-H-N-O-P",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -2610,6 +2624,7 @@
"_id": {
"$oid": "5cfb441f053b174410700f79"
},
"assemblies": null,
"chemsys": "Ag-C-Cl-H-N-O-S",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -2909,6 +2924,7 @@
"_id": {
"$oid": "5cfb441f053b174410701bdc"
},
"assemblies": null,
"chemsys": "Ba-Ce-Fe-H-Na-O-Si-Ti",
"cartesian_site_positions": [
[
Expand Down Expand Up @@ -3309,6 +3325,7 @@
"_id": {
"$oid": "5cfb441f053b174410701bec"
},
"assemblies": null,
"chemsys": "Ba-F-H-Mn-Na-O-Re-Si-Ti",
"cartesian_site_positions": [
[
Expand Down
25 changes: 21 additions & 4 deletions tests/filtertransformers/test_mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ def test_simple_comparisons(self):
assert self.transform("a>3") == {"a": {"$gt": 3}}
assert self.transform("a>=3") == {"a": {"$gte": 3}}
assert self.transform("a=3") == {"a": {"$eq": 3}}
assert self.transform("a!=3") == {"a": {"$ne": 3}}
assert self.transform("a!=3") == {
"$and": [{"a": {"$ne": 3}}, {"a": {"$ne": None}}]
}

def test_id(self):
assert self.transform('id="example/1"') == {"id": {"$eq": "example/1"}}
Expand Down Expand Up @@ -135,7 +137,12 @@ def test_operators(self):
) == {
"$and": [
{"chemical_formula_hill": {"$eq": "H2O"}},
{"chemical_formula_anonymous": {"$ne": "AB"}},
{
"$and": [
{"chemical_formula_anonymous": {"$ne": "AB"}},
{"chemical_formula_anonymous": {"$ne": None}},
]
},
]
}
assert self.transform(
Expand All @@ -149,7 +156,12 @@ def test_operators(self):
{"nelements": {"$gte": 10}},
{
"$nor": [
{"_exmpl_x": {"$ne": "Some string"}},
{
"$and": [
{"_exmpl_x": {"$ne": "Some string"}},
{"_exmpl_x": {"$ne": None}},
]
},
{"_exmpl_a": {"$not": {"$eq": 7}}},
]
},
Expand Down Expand Up @@ -443,7 +455,12 @@ class MyMapper(mapper("StructureMapper")):

assert transformer.transform(
parser.parse('immutable_id != "5cfb441f053b174410700d02"')
) == {"_id": {"$ne": ObjectId("5cfb441f053b174410700d02")}}
) == {
"$and": [
{"_id": {"$ne": ObjectId("5cfb441f053b174410700d02")}},
{"_id": {"$ne": None}},
]
}

for op in ("CONTAINS", "STARTS WITH", "ENDS WITH", "HAS"):
with pytest.raises(
Expand Down

0 comments on commit e55b6ba

Please sign in to comment.