diff --git a/tests/cli.py b/tests/cli.py index b534f782..36415458 100644 --- a/tests/cli.py +++ b/tests/cli.py @@ -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 diff --git a/tests/data/example_2.xyz b/tests/data/example_2.xyz new file mode 100644 index 00000000..9582ab40 --- /dev/null +++ b/tests/data/example_2.xyz @@ -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