From bc948258777f57f7c01e909417577337d96fa456 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:24:27 +0000 Subject: [PATCH 1/3] Initial plan From 8060a79b9c5172c40edff87bdcf0e095e177560e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:25:32 +0000 Subject: [PATCH 2/3] style: fix ruff formatting in tests/test_imap_profiles.py Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_imap_profiles.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_imap_profiles.py b/tests/test_imap_profiles.py index bfc2fb2c..1c18459f 100644 --- a/tests/test_imap_profiles.py +++ b/tests/test_imap_profiles.py @@ -1,6 +1,5 @@ """Tests for app/api/imap_profiles.py and app/utils/allowed_types category helpers.""" - import pytest from app.utils.allowed_types import ( From be6b49c8721445dc8ea870afda87f311acb192e3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Mar 2026 10:49:49 +0000 Subject: [PATCH 3/3] fix(tests): fix two failing tests - missing DB table and MagicMock IP address - tests/test_database.py: add user_imap_accounts table to the regression test's initial DB setup (migration 022 creates it before rev 026, so it must exist for migration 032's ALTER TABLE to succeed) - tests/test_local_auth.py: configure mock_request.headers.get to return None and client=None so get_client_ip() returns "unknown" instead of an un-serialisable MagicMock that broke the audit_logs INSERT in test_local_login_success and test_local_login_by_email Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_database.py | 16 ++++++++++++++++ tests/test_local_auth.py | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/tests/test_database.py b/tests/test_database.py index 14e803c0..47a56a40 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -182,6 +182,22 @@ class TestInitDb: "UNIQUE (user_id, name))" ) ) + # user_imap_accounts was created by migration 022 and must exist + # before migration 032 (ALTER TABLE ... ADD COLUMN) can run. + conn.execute( + text( + "CREATE TABLE user_imap_accounts (" + "id INTEGER PRIMARY KEY, owner_id VARCHAR NOT NULL, " + "name VARCHAR(255) NOT NULL, host VARCHAR(255) NOT NULL, " + "port INTEGER NOT NULL DEFAULT 993, username VARCHAR(255) NOT NULL, " + "password VARCHAR(1024) NOT NULL, use_ssl BOOLEAN NOT NULL DEFAULT 1, " + "delete_after_process BOOLEAN NOT NULL DEFAULT 0, " + "is_active BOOLEAN NOT NULL DEFAULT 1, " + "last_checked_at DATETIME, last_error TEXT, " + "created_at DATETIME DEFAULT CURRENT_TIMESTAMP, " + "updated_at DATETIME DEFAULT CURRENT_TIMESTAMP)" + ) + ) conn.execute(text("CREATE TABLE alembic_version (version_num VARCHAR(32) NOT NULL)")) conn.execute(text("INSERT INTO alembic_version VALUES ('026_add_scheduled_jobs')")) diff --git a/tests/test_local_auth.py b/tests/test_local_auth.py index 743a3eaf..8759d88c 100644 --- a/tests/test_local_auth.py +++ b/tests/test_local_auth.py @@ -613,6 +613,8 @@ async def test_local_login_success(la_session, active_user): mock_request = MagicMock(spec=Request) mock_request.form = AsyncMock(return_value={"username": "activeuser", "password": "password123"}) mock_request.session = {} + mock_request.headers.get.return_value = None + mock_request.client = None result = await auth(mock_request, db=la_session) assert result.status_code == 302 @@ -634,6 +636,8 @@ async def test_local_login_by_email(la_session, active_user): mock_request = MagicMock(spec=Request) mock_request.form = AsyncMock(return_value={"username": "active@example.com", "password": "password123"}) mock_request.session = {} + mock_request.headers.get.return_value = None + mock_request.client = None result = await auth(mock_request, db=la_session) assert result.status_code == 302