This commit is contained in:
Daniel O'Connell 2025-05-20 22:02:31 +02:00
parent 8cfaeaea72
commit 29a2a7ba3a
8 changed files with 37 additions and 21 deletions

26
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
jobs:
lint-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[all]
pip install ruff==0.11.10 pylint
- name: Run linters
run: |
ruff check .
pylint $(git ls-files '*.py')
- name: Run tests
run: pytest -vv

View File

@ -10,7 +10,6 @@ from typing import Sequence, Union
from alembic import op from alembic import op
import sqlalchemy as sa import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic. # revision identifiers, used by Alembic.
revision: str = "d292d48ec74e" revision: str = "d292d48ec74e"

View File

@ -93,7 +93,7 @@ def initialize_collections(
if collections is None: if collections is None:
collections = ALL_COLLECTIONS collections = ALL_COLLECTIONS
logger.info(f"Initializing collections:") logger.info("Initializing collections:")
for name, params in collections.items(): for name, params in collections.items():
logger.info(f" - {name}") logger.info(f" - {name}")
ensure_collection_exists( ensure_collection_exists(

View File

@ -1,9 +1,8 @@
import textwrap from unittest.mock import patch
from memory.common.parsers.comics import extract_smbc, extract_xkcd
import pytest
from unittest.mock import patch, Mock
import requests
import pytest
from memory.common.parsers.comics import extract_smbc, extract_xkcd
MOCK_SMBC_HTML = """ MOCK_SMBC_HTML = """
<!DOCTYPE html> <!DOCTYPE html>

View File

@ -5,7 +5,7 @@ import email.mime.base
from datetime import datetime from datetime import datetime
from email.utils import formatdate from email.utils import formatdate
from unittest.mock import ANY, patch from unittest.mock import ANY
import pytest import pytest
from memory.common.parsers.email import ( from memory.common.parsers.email import (
compute_message_hash, compute_message_hash,
@ -17,9 +17,10 @@ from memory.common.parsers.email import (
) )
# Use a simple counter to generate unique message IDs without calling make_msgid # Use a simple counter to generate unique message IDs without calling make_msgid
_msg_id_counter = 0 _msg_id_counter = 0
def _generate_test_message_id(): def _generate_test_message_id():
"""Generate a simple message ID for testing without expensive calls""" """Generate a simple message ID for testing without expensive calls"""
global _msg_id_counter global _msg_id_counter
@ -248,8 +249,8 @@ def test_parse_simple_email():
"body": "Test body content\n", "body": "Test body content\n",
"attachments": [], "attachments": [],
"sent_at": ANY, "sent_at": ANY,
"hash": b'\xed\xa0\x9b\xd4\t4\x06\xb9l\xa4\xb3*\xe4NpZ\x19\xc2\x9b\x87' "hash": b"\xed\xa0\x9b\xd4\t4\x06\xb9l\xa4\xb3*\xe4NpZ\x19\xc2\x9b\x87"
+ b'\xa6\x12\r\x7fS\xb6\xf1\xbe\x95\x9c\x99\xf1', + b"\xa6\x12\r\x7fS\xb6\xf1\xbe\x95\x9c\x99\xf1",
} }
assert abs(result["sent_at"].timestamp() - test_date.timestamp()) < 86400 assert abs(result["sent_at"].timestamp() - test_date.timestamp()) < 86400

View File

@ -8,7 +8,6 @@ from memory.common.extract import (
as_file, as_file,
extract_text, extract_text,
extract_content, extract_content,
Page,
doc_to_images, doc_to_images,
extract_image, extract_image,
docx_to_pdf, docx_to_pdf,

View File

@ -1,6 +1,4 @@
from unittest import mock
import pytest import pytest
from datetime import datetime, timedelta
from unittest.mock import patch from unittest.mock import patch
from memory.common.db.models import ( from memory.common.db.models import (
EmailAccount, EmailAccount,

View File

@ -1,16 +1,10 @@
import email
import email.mime.multipart
import email.mime.text
import email.mime.base
import base64 import base64
import pathlib import pathlib
from datetime import datetime from datetime import datetime
from email.utils import formatdate from unittest.mock import MagicMock, patch
from unittest.mock import ANY, MagicMock, patch
import pytest import pytest
from memory.common.db.models import ( from memory.common.db.models import (
SourceItem,
MailMessage, MailMessage,
EmailAttachment, EmailAttachment,
EmailAccount, EmailAccount,