Skip to content

Commit

Permalink
Add query-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliottKasoar committed Mar 12, 2024
1 parent 5c4b57e commit 5e7beaf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,21 @@ def test_summary(self):
"abcd summary", shell=True, check=True, capture_output=True, text=True
)
assert "Total number of configurations: 1" in summary.stdout

def test_query(self):
"""
Test lucene-style query.
"""
class_path = os.path.normpath(os.path.abspath(__file__))
data_file_1 = os.path.dirname(class_path) + "/data/example.xyz"
data_file_2 = os.path.dirname(class_path) + "/data/example_2.xyz"
subprocess.run(f"abcd upload {data_file_1}", shell=True, check=True)
subprocess.run(f"abcd upload {data_file_2}", shell=True, check=True)
summary = subprocess.run(
"abcd show -p n_atoms -q 'n_atoms : 2", shell=True, check=True, capture_output=True, text=True
)
assert "2" in summary.stdout and "3" not in summary.stdout
summary = subprocess.run(
"abcd show -p n_atoms -q 'n_atoms : 3", shell=True, check=True, capture_output=True, text=True
)
assert "3" in summary.stdout and "2" not in summary.stdout
5 changes: 5 additions & 0 deletions tests/data/example_2.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
3
Properties=species:S:1:pos:R:3 s="sadf" _vtk_test="t _ e s t" pbc="F F F"
Si 0.00000000 1.00000000 2.00000000
Si 3.00000000 4.00000000 5.00000000
Si 6.00000000 7.00000000 7.00000000

0 comments on commit 5e7beaf

Please sign in to comment.