add ruff. fix all linting

This commit is contained in:
Matteo Rosati
2026-04-22 17:03:01 +02:00
parent bd5f649663
commit 33b46c2c21
14 changed files with 294 additions and 63 deletions
+7 -14
View File
@@ -20,22 +20,19 @@ from chromy.command_inputs import (
class BuildCommandInputTests(unittest.TestCase):
def test_parser_converts_list_collections_and_alias(self) -> None:
self.assertEqual(_parse_input(
["list-collections"]), ListCollectionsInput())
self.assertEqual(_parse_input(["list-collections"]), ListCollectionsInput())
self.assertEqual(_parse_input(["lc"]), ListCollectionsInput())
def test_parser_converts_create_collection_and_alias(self) -> None:
expected = CreateCollectionInput(collection="notes")
self.assertEqual(_parse_input(
["create-collection", "notes"]), expected)
self.assertEqual(_parse_input(["create-collection", "notes"]), expected)
self.assertEqual(_parse_input(["cc", "notes"]), expected)
def test_parser_converts_delete_collection_and_alias(self) -> None:
expected = DeleteCollectionInput(collection="notes")
self.assertEqual(_parse_input(
["delete-collection", "notes"]), expected)
self.assertEqual(_parse_input(["delete-collection", "notes"]), expected)
self.assertEqual(_parse_input(["dc", "notes"]), expected)
def test_parser_converts_count_and_alias(self) -> None:
@@ -45,8 +42,7 @@ class BuildCommandInputTests(unittest.TestCase):
self.assertEqual(_parse_input(["co", "notes"]), expected)
def test_parser_converts_add_data_and_alias(self) -> None:
expected = AddDataInput(
collection="notes", file="romeo_and_juliet.txt")
expected = AddDataInput(collection="notes", file="romeo_and_juliet.txt")
self.assertEqual(
_parse_input(["add-data", "notes", "romeo_and_juliet.txt"]),
@@ -64,12 +60,10 @@ class BuildCommandInputTests(unittest.TestCase):
_parse_input(["query", "notes", "Where is Romeo?"]),
expected,
)
self.assertEqual(_parse_input(
["q", "notes", "Where is Romeo?"]), expected)
self.assertEqual(_parse_input(["q", "notes", "Where is Romeo?"]), expected)
def test_parser_converts_delete_records_and_alias(self) -> None:
expected = DeleteRecordsInput(
collection="notes", where="file_name=play.txt")
expected = DeleteRecordsInput(collection="notes", where="file_name=play.txt")
self.assertEqual(
_parse_input(["delete", "notes", "--where", "file_name=play.txt"]),
@@ -81,8 +75,7 @@ class BuildCommandInputTests(unittest.TestCase):
)
def test_invalid_delete_filter_keeps_user_facing_error(self) -> None:
args = Namespace(command="delete", collection="notes",
where="file_name")
args = Namespace(command="delete", collection="notes", where="file_name")
output = io.StringIO()
with redirect_stdout(output):
+4 -4
View File
@@ -26,13 +26,14 @@ from chromy.handlers.delete_collection import (
from chromy.handlers.list_collections import handle_list_collections
from chromy.handlers.query import handle_query
CommandT = TypeVar("CommandT")
class HandlerTests(unittest.TestCase):
def test_list_collections_prints_empty_message(self) -> None:
with patch("chromy.handlers.list_collections.list_collections", return_value=[]):
with patch(
"chromy.handlers.list_collections.list_collections", return_value=[]
):
exit_code, output = _capture_output(
handle_list_collections,
ListCollectionsInput(),
@@ -133,8 +134,7 @@ class HandlerTests(unittest.TestCase):
) as delete_data:
exit_code, output = _capture_output(
handle_delete_records,
DeleteRecordsInput(collection="notes",
where=" file_name = play.txt "),
DeleteRecordsInput(collection="notes", where=" file_name = play.txt "),
)
delete_data.assert_called_once_with("notes", {"file_name": "play.txt"})