fix syntax and types

This commit is contained in:
2026-04-24 18:23:02 +02:00
parent 948f8500be
commit c5b6b196b5
8 changed files with 21 additions and 25 deletions
+6 -11
View File
@@ -51,15 +51,13 @@ class CliTests(unittest.TestCase):
def test_create_collection_with_same_name(self) -> None:
with patch(
"chromy.handlers.create_collection.create_collection",
side_effect=InternalError()
side_effect=InternalError(),
) as create_collection:
result = _invoke(["create-collection", "notes"])
create_collection.assert_called_once_with("notes")
self.assertEqual(result.exit_code, 1)
self.assertEqual(
result.stdout, "Error: Collection 'notes' already exists.\n")
self.assertEqual(result.stdout, "Error: Collection 'notes' already exists.\n")
def test_delete_collection(self) -> None:
with patch(
@@ -74,14 +72,13 @@ class CliTests(unittest.TestCase):
def test_delete_non_existent_collection(self) -> None:
with patch(
"chromy.handlers.delete_collection.delete_collection",
side_effect=NotFoundError()
side_effect=NotFoundError(),
) as delete_collection:
result = _invoke(["delete-collection", "notes"])
delete_collection.assert_called_once_with("notes")
self.assertEqual(result.exit_code, 1)
self.assertEqual(
result.stdout, "Error: Collection 'notes' does not exist.\n")
self.assertEqual(result.stdout, "Error: Collection 'notes' does not exist.\n")
def test_count(self) -> None:
with patch(
@@ -106,8 +103,7 @@ class CliTests(unittest.TestCase):
self._fixture_path("romeo_and_juliet.txt"),
)
self.assertEqual(result.exit_code, 0)
self.assertEqual(
result.stdout, "Added 3 records to collection 'notes'.\n")
self.assertEqual(result.stdout, "Added 3 records to collection 'notes'.\n")
def test_query(self) -> None:
query_result = {"ids": [["1"]], "documents": [["hello"]]}
@@ -139,8 +135,7 @@ class CliTests(unittest.TestCase):
self.assertEqual(result.exit_code, 0)
self.assertEqual(
result.stdout,
"Deleted 2 record(s) from collection 'notes' "
"where file_name=play.txt.\n",
"Deleted 2 record(s) from collection 'notes' where file_name=play.txt.\n",
)
def test_invalid_delete_filter_keeps_user_facing_error(self) -> None:
+2 -2
View File
@@ -8,13 +8,13 @@ from pathlib import Path
from typing import TypeVar
from unittest.mock import patch
from chromy.handlers.import_data import handle_import
from chromy.handlers.count_collection import handle_count_collection
from chromy.handlers.create_collection import handle_create_collection
from chromy.handlers.delete_collection import (
handle_delete_collection,
handle_delete_records,
)
from chromy.handlers.import_data import handle_import
from chromy.handlers.list_collections import handle_list_collections
from chromy.handlers.query import handle_query
@@ -154,7 +154,7 @@ class HandlerTests(unittest.TestCase):
def _capture_output(
handler: Callable[..., int],
*arguments: CommandT,
*arguments: object,
) -> tuple[int, str]:
output = io.StringIO()