style: apply black formatting to test_mail_processor_imap.py
Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/2f63c66a-f2dd-41f4-aba4-b89b66f9e11b Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Fix timezone display in Mailbox Activity / Admin Logs pages: timestamps from the server were parsed as local time when no timezone indicator was present, causing relative times ("1h ago") and absolute dates to be shifted by the client's UTC offset.
|
- Fix timezone display in Mailbox Activity / Admin Logs pages: timestamps from the server were parsed as local time when no timezone indicator was present, causing relative times ("1h ago") and absolute dates to be shifted by the client's UTC offset.
|
||||||
- Worker tasks: use a fresh DB session for `send_user_notification` calls and move notifications after `db.commit()` to prevent the post-rollback `greenlet_spawn` SQLAlchemy error.
|
- Worker tasks: use a fresh DB session for `send_user_notification` calls and move notifications after `db.commit()` to prevent the post-rollback `greenlet_spawn` SQLAlchemy error.
|
||||||
- Worker tasks: ensure `last_check_at` and error status are always committed before notifications, fixing accounts being endlessly re-queued after IMAP auth failures.
|
- Worker tasks: ensure `last_check_at` and error status are always committed before notifications, fixing accounts being endlessly re-queued after IMAP auth failures.
|
||||||
|
- Style: apply black formatting to `backend/tests/unit/test_mail_processor_imap.py` to fix CI black check failure.
|
||||||
## v0.4.0 (2026-03-28)
|
## v0.4.0 (2026-03-28)
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ These tests verify that _fetch_imap_emails:
|
|||||||
import pytest
|
import pytest
|
||||||
from unittest.mock import AsyncMock, MagicMock, call, patch
|
from unittest.mock import AsyncMock, MagicMock, call, patch
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Helpers to build lightweight fakes
|
# Helpers to build lightweight fakes
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -139,9 +138,7 @@ class TestFetchImapEmailsUidCommands:
|
|||||||
assert new_uids == ["42"]
|
assert new_uids == ["42"]
|
||||||
|
|
||||||
# The fetch call should use UID FETCH
|
# The fetch call should use UID FETCH
|
||||||
fetch_call = [
|
fetch_call = [c for c in mock_imap.uid.call_args_list if c.args[0] == "fetch"]
|
||||||
c for c in mock_imap.uid.call_args_list if c.args[0] == "fetch"
|
|
||||||
]
|
|
||||||
assert len(fetch_call) == 1
|
assert len(fetch_call) == 1
|
||||||
assert fetch_call[0] == call("fetch", "42", "(RFC822)")
|
assert fetch_call[0] == call("fetch", "42", "(RFC822)")
|
||||||
|
|
||||||
@@ -167,9 +164,7 @@ class TestFetchImapEmailsUidCommands:
|
|||||||
emails, new_uids = await processor._fetch_imap_emails(10, set())
|
emails, new_uids = await processor._fetch_imap_emails(10, set())
|
||||||
|
|
||||||
# No STORE command should have been called (delete_after_forward=False)
|
# No STORE command should have been called (delete_after_forward=False)
|
||||||
store_calls = [
|
store_calls = [c for c in mock_imap.uid.call_args_list if c.args[0] == "store"]
|
||||||
c for c in mock_imap.uid.call_args_list if c.args[0] == "store"
|
|
||||||
]
|
|
||||||
assert store_calls == [], "Expected no STORE commands for \\Seen"
|
assert store_calls == [], "Expected no STORE commands for \\Seen"
|
||||||
|
|
||||||
assert len(emails) == 3
|
assert len(emails) == 3
|
||||||
@@ -201,9 +196,7 @@ class TestFetchImapEmailsUidCommands:
|
|||||||
assert new_uids == ["6"]
|
assert new_uids == ["6"]
|
||||||
assert len(emails) == 1
|
assert len(emails) == 1
|
||||||
|
|
||||||
store_calls = [
|
store_calls = [c for c in mock_imap.uid.call_args_list if c.args[0] == "store"]
|
||||||
c for c in mock_imap.uid.call_args_list if c.args[0] == "store"
|
|
||||||
]
|
|
||||||
# Exactly one STORE for the stale UID
|
# Exactly one STORE for the stale UID
|
||||||
assert len(store_calls) == 1
|
assert len(store_calls) == 1
|
||||||
assert store_calls[0] == call("store", "5", "+FLAGS", "\\Seen")
|
assert store_calls[0] == call("store", "5", "+FLAGS", "\\Seen")
|
||||||
@@ -226,9 +219,7 @@ class TestFetchImapEmailsUidCommands:
|
|||||||
):
|
):
|
||||||
await processor._fetch_imap_emails(10, already_seen_uids={"1", "2"})
|
await processor._fetch_imap_emails(10, already_seen_uids={"1", "2"})
|
||||||
|
|
||||||
store_calls = [
|
store_calls = [c for c in mock_imap.uid.call_args_list if c.args[0] == "store"]
|
||||||
c for c in mock_imap.uid.call_args_list if c.args[0] == "store"
|
|
||||||
]
|
|
||||||
assert len(store_calls) == 1
|
assert len(store_calls) == 1
|
||||||
# The UID set string should contain both stale UIDs (order may vary)
|
# The UID set string should contain both stale UIDs (order may vary)
|
||||||
uid_set_arg = store_calls[0].args[1]
|
uid_set_arg = store_calls[0].args[1]
|
||||||
@@ -266,9 +257,7 @@ class TestFetchImapEmailsUidCommands:
|
|||||||
|
|
||||||
assert new_uids == ["7", "8"]
|
assert new_uids == ["7", "8"]
|
||||||
|
|
||||||
store_calls = [
|
store_calls = [c for c in mock_imap.uid.call_args_list if c.args[0] == "store"]
|
||||||
c for c in mock_imap.uid.call_args_list if c.args[0] == "store"
|
|
||||||
]
|
|
||||||
# Exactly one STORE for deletion covering both UIDs
|
# Exactly one STORE for deletion covering both UIDs
|
||||||
assert len(store_calls) == 1
|
assert len(store_calls) == 1
|
||||||
uid_set_arg = store_calls[0].args[1]
|
uid_set_arg = store_calls[0].args[1]
|
||||||
|
|||||||
Reference in New Issue
Block a user