Skip to content

Commit

Permalink
Refactor test_parsers.py
Browse files Browse the repository at this point in the history
Shortened identifier names in `TestFileQueryParser` class.
  • Loading branch information
rahul4732saini committed Jul 14, 2024
1 parent fed8354 commit f1c70e3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tests/test_query/test_handlers/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class TestFileQueryParser:
"""Tests the FileQueryParser class"""

file_search_query_test_params = [
search_query_test_params = [
"* FROM .",
"name, path, parent FROM ABSOLUTE '.'",
"access_time,modify_time from RELATIVE .",
Expand All @@ -24,7 +24,7 @@ class TestFileQueryParser:
"* FROM '.' WHERE atime >= '2024-02-20'",
]

file_search_query_with_size_fields_test_params = [
search_query_with_size_fields_test_params = [
"size, size[B] FROM . WHERE type = '.py' AND size[KiB] > 512",
"size[b],size,size[TiB] FROM ABSOLUTE .",
"size[MB], size[GB], size[B] FROM . WHERE size[MiB] > 10",
Expand All @@ -34,7 +34,7 @@ class TestFileQueryParser:
# each with a length of 2. The first element of each sub-list signifies whether the path is
# absolute (True) or relative (False) whereas the second element is a list comprising names
# of the search fields.
file_search_query_test_results = [
search_query_test_results = [
[False, list(constants.FILE_FIELDS)],
[True, ["name", "path", "parent"]],
[False, ["access_time", "modify_time"]],
Expand All @@ -43,17 +43,17 @@ class TestFileQueryParser:
[False, list(constants.FILE_FIELDS)],
]

file_search_query_with_size_fields_test_results = [
search_query_with_size_fields_test_results = [
[False, ["B", "B"], ["size", "size[B]"]],
[True, ["b", "B", "TiB"], ["size[b]", "size", "size[TiB]"]],
[False, ["MB", "GB", "B"], ["size[MB]", "size[GB]", "size[B]"]],
]

@pytest.mark.parametrize(
("subquery", "results"),
zip(file_search_query_test_params, file_search_query_test_results),
zip(search_query_test_params, search_query_test_results),
)
def test_file_search_query_parser(self, subquery, results) -> None:
def test_search_query(self, subquery, results) -> None:
"""Tests the file query parser with search queries."""

query: list[str] = tools.parse_query(subquery)
Expand All @@ -74,11 +74,11 @@ def test_file_search_query_parser(self, subquery, results) -> None:
@pytest.mark.parametrize(
("subquery", "results"),
zip(
file_search_query_with_size_fields_test_params,
file_search_query_with_size_fields_test_results,
search_query_with_size_fields_test_params,
search_query_with_size_fields_test_results,
),
)
def test_file_search_query_parser_with_size_fields(self, subquery, results) -> None:
def test_search_query_with_size_fields(self, subquery, results) -> None:
"""
Tests the file query parser with search queries comprising size fields.
"""
Expand Down

0 comments on commit f1c70e3

Please sign in to comment.