Skip to content

Commit 3c5fd80

Browse files
Defined new test case in test_parsers.py
Defined `test_delete_query` method in `TestFileQueryParser` class for testing file query parser with delete queries. Also defined attributes comprising parameters and results for the same.
1 parent d97024b commit 3c5fd80

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/test_query/test_handlers/test_parsers.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,15 @@ class TestFileQueryParser:
8080
"filename, type, mtime FROM RELATIVE . WHERE type = '.png'",
8181
]
8282

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+
8389
# The following are test results for the search query tests comprising sub-lists, each with
8490
# 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
8692
# names of the search fields. All the remaining objects within the list are test specific
8793
# and may differ in different tests.
8894

@@ -107,6 +113,12 @@ class TestFileQueryParser:
107113
[False, ["name", "filetype", "modify_time"], ["filename", "type", "mtime"]],
108114
]
109115

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+
110122
@pytest.mark.parametrize(
111123
("subquery", "results"),
112124
zip(search_query_test_params, search_query_test_results),
@@ -162,6 +174,18 @@ def test_search_query_with_field_aliases(self, subquery, results) -> None:
162174

163175
assert [field.field for field in search_query.fields] == fields
164176

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+
165189

166190
class TestDirectoryQueryParser:
167191
"""Tests the DirectoryQueryParser class"""

0 commit comments

Comments
 (0)