@@ -80,9 +80,15 @@ class TestFileQueryParser:
80
80
"filename, type, mtime FROM RELATIVE . WHERE type = '.png'" ,
81
81
]
82
82
83
+ delete_query_test_params = [
84
+ "FROM ABSOLUTE ." ,
85
+ "FROM . WHERE type = '.py' and 'fise' in parent" ,
86
+ "FROM RELATIVE . WHERE atime <= '2012-02-17' OR ctime <= '2015-03-23'" ,
87
+ ]
88
+
83
89
# The following are test results for the search query tests comprising sub-lists, each with
84
90
# a variable length where the first element of each of them signifies whether the path is
85
- # absolute (True) or relative (Fasle ) whereas the last element in it is a list comprising
91
+ # absolute (True) or relative (False ) whereas the last element in it is a list comprising
86
92
# names of the search fields. All the remaining objects within the list are test specific
87
93
# and may differ in different tests.
88
94
@@ -107,6 +113,12 @@ class TestFileQueryParser:
107
113
[False , ["name" , "filetype" , "modify_time" ], ["filename" , "type" , "mtime" ]],
108
114
]
109
115
116
+ # The following are test results for the delete query tests and comprise boolean objects
117
+ # associated with the corresponding delete queries. These boolean objects signify whether
118
+ # the path type in the query is absolute (True) or relative (False).
119
+
120
+ delete_query_test_results = [True , False , False ]
121
+
110
122
@pytest .mark .parametrize (
111
123
("subquery" , "results" ),
112
124
zip (search_query_test_params , search_query_test_results ),
@@ -162,6 +174,18 @@ def test_search_query_with_field_aliases(self, subquery, results) -> None:
162
174
163
175
assert [field .field for field in search_query .fields ] == fields
164
176
177
+ @pytest .mark .parametrize (
178
+ ("subquery" , "is_absolute" ),
179
+ zip (delete_query_test_params , delete_query_test_results ),
180
+ )
181
+ def test_delete_query (self , subquery : str , is_absolute : bool ) -> None :
182
+ """Tests the file query parser with delete queries."""
183
+
184
+ query : list [str ] = tools .parse_query (subquery )
185
+ parser = FileQueryParser (query , "delete" )
186
+
187
+ examine_delete_query (parser , is_absolute )
188
+
165
189
166
190
class TestDirectoryQueryParser :
167
191
"""Tests the DirectoryQueryParser class"""
0 commit comments