mirror of
https://github.com/mruwnik/memory.git
synced 2025-06-28 15:14:45 +02:00
fix tests
This commit is contained in:
parent
80020e2a61
commit
a3daea883b
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
|
||||
Books
|
||||
CLAUDE.md
|
||||
memory_files
|
||||
venv
|
||||
.env
|
||||
|
@ -370,7 +370,7 @@ class SourceItem(Base):
|
||||
@property
|
||||
def display_contents(self) -> str | dict | None:
|
||||
payload = self.as_payload()
|
||||
payload.pop("id", None) # type: ignore
|
||||
payload.pop("source_id", None) # type: ignore
|
||||
return {
|
||||
**payload,
|
||||
"tags": self.tags,
|
||||
|
@ -91,9 +91,9 @@ class MailMessage(SourceItem):
|
||||
|
||||
def as_payload(self) -> MailMessagePayload:
|
||||
base_payload = super().as_payload() | {
|
||||
"tags": cast(list[str], self.tags)
|
||||
"tags": (cast(list[str], self.tags) or [])
|
||||
+ [cast(str, self.sender)]
|
||||
+ cast(list[str], self.recipients)
|
||||
+ (cast(list[str], self.recipients) or [])
|
||||
}
|
||||
return MailMessagePayload(
|
||||
**cast(dict, base_payload),
|
||||
|
@ -4,8 +4,10 @@ from typing import cast
|
||||
import pytest
|
||||
from PIL import Image
|
||||
from memory.common import settings, chunker, extract
|
||||
from memory.common.db.models.source_items import (
|
||||
from memory.common.db.models.source_item import (
|
||||
Chunk,
|
||||
)
|
||||
from memory.common.db.models.source_items import (
|
||||
MailMessage,
|
||||
)
|
||||
from memory.common.db.models.source_item import (
|
||||
|
@ -203,6 +203,8 @@ Test Body Content"""
|
||||
"sender": "sender@example.com",
|
||||
"recipients": ["recipient@example.com"],
|
||||
"tags": None,
|
||||
"folder": None,
|
||||
"message_id": "<test@example.com>",
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ from pathlib import Path
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
from memory.common.db.models import Book, BookSection
|
||||
from memory.common import settings
|
||||
from memory.parsers.ebook import Ebook, Section
|
||||
from memory.workers.tasks import ebook
|
||||
|
||||
@ -46,7 +47,7 @@ def mock_ebook():
|
||||
end_page=20,
|
||||
),
|
||||
],
|
||||
file_path=Path("/test/book.epub"),
|
||||
file_path=settings.FILE_STORAGE_DIR / "test/book.epub",
|
||||
n_pages=20,
|
||||
)
|
||||
|
||||
@ -70,7 +71,7 @@ def test_create_book_from_ebook(mock_ebook):
|
||||
assert book.author == "Test Author" # type: ignore
|
||||
assert book.publisher == "Test Publisher" # type: ignore
|
||||
assert book.language == "en" # type: ignore
|
||||
assert book.file_path == "/test/book.epub" # type: ignore
|
||||
assert book.file_path == "test/book.epub" # type: ignore
|
||||
assert book.total_pages == 20 # type: ignore
|
||||
assert book.book_metadata == { # type: ignore
|
||||
"language": "en",
|
||||
|
@ -257,6 +257,8 @@ def test_create_mail_message(db_session):
|
||||
"recipients": ["recipient@example.com"],
|
||||
"date": "2023-01-01T12:00:00+00:00",
|
||||
"mime_type": "message/rfc822",
|
||||
"folder": "INBOX",
|
||||
"message_id": "321",
|
||||
"size": 412,
|
||||
"tags": ["test"],
|
||||
"filename": None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user