Merge pull request #606 from christianlouis/copilot/fix-ruff-not-clearing-main
fix(tests): repair two broken tests — missing DB table and MagicMock ip_address
This commit is contained in:
@@ -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')"))
|
||||
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user