add test test_delete_non_existent_collection
build / build (push) Successful in 10s
pytest / pytest (push) Successful in 24s

This commit is contained in:
Matteo Rosati
2026-04-23 21:13:35 +02:00
parent 7ee58939a6
commit 6861636794
+12 -1
View File
@@ -5,7 +5,7 @@ from collections.abc import Sequence
from pathlib import Path from pathlib import Path
from unittest.mock import patch from unittest.mock import patch
from chromadb.errors import InternalError from chromadb.errors import InternalError, NotFoundError
from click.testing import Result from click.testing import Result
from typer.testing import CliRunner from typer.testing import CliRunner
@@ -70,6 +70,17 @@ class CliTests(unittest.TestCase):
self.assertEqual(result.exit_code, 0) self.assertEqual(result.exit_code, 0)
self.assertEqual(result.stdout, "Deleted collection 'notes'.\n") self.assertEqual(result.stdout, "Deleted collection 'notes'.\n")
def test_delete_non_existent_collection(self) -> None:
with patch(
"chromy.handlers.delete_collection.delete_collection",
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, "Collection 'notes' does not exist.\n")
def test_count(self) -> None: def test_count(self) -> None:
with patch( with patch(
"chromy.handlers.count_collection.count_collection", "chromy.handlers.count_collection.count_collection",