feat: add PageIndex SDK with local/cloud dual-mode support (#207)

This commit is contained in:
Kylin 2026-04-06 22:51:04 +08:00 committed by GitHub
parent 8f1ed7783b
commit b63fd9779a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 4225 additions and 274 deletions

27
tests/test_errors.py Normal file
View file

@ -0,0 +1,27 @@
from pageindex.errors import (
PageIndexError,
CollectionNotFoundError,
DocumentNotFoundError,
IndexingError,
CloudAPIError,
FileTypeError,
)
def test_all_errors_inherit_from_base():
for cls in [CollectionNotFoundError, DocumentNotFoundError, IndexingError, CloudAPIError, FileTypeError]:
assert issubclass(cls, PageIndexError)
assert issubclass(cls, Exception)
def test_error_message():
err = FileTypeError("Unsupported: .docx")
assert str(err) == "Unsupported: .docx"
def test_catch_base_catches_all():
for cls in [CollectionNotFoundError, DocumentNotFoundError, IndexingError, CloudAPIError, FileTypeError]:
try:
raise cls("test")
except PageIndexError:
pass # expected