imap progress

This commit is contained in:
Bryce
2025-08-04 07:34:34 -07:00
parent 34d2913165
commit 31088cf112
11 changed files with 1405 additions and 5 deletions

63
tests/test_imap_routes.py Normal file
View File

@@ -0,0 +1,63 @@
import pytest
from app import create_app
from app.models import User, db, Folder
class TestIMAPRoutes:
def test_imap_config_modal(self, client):
# Create a test user and log in
user = User(email='test@example.com', first_name='Test', last_name='User')
user.set_password('password')
db.session.add(user)
db.session.commit()
client.post('/auth/login', data={
'email': 'test@example.com',
'password': 'password'
})
response = client.get('/api/imap/config')
assert response.status_code == 200
assert b'Configure IMAP Connection' in response.data
def test_imap_connection_test_success(self, client, app):
with app.app_context():
# Create a test user and log in
user = User(email='test2@example.com', first_name='Test', last_name='User')
user.set_password('password')
db.session.add(user)
db.session.commit()
client.post('/auth/login', data={
'email': 'test2@example.com',
'password': 'password'
})
response = client.post('/api/imap/test', data={
'server': 'test.com',
'port': '993',
'username': 'test@test.com',
'password': 'testpass',
'use_ssl': 'on'
})
assert response.status_code == 200
# Should show either success or error message
assert b'Test Connection' in response.data
def test_imap_sync_folders(self, client, app):
with app.app_context():
# Create a test user and log in
user = User(email='test3@example.com', first_name='Test', last_name='User')
user.set_password('password')
user.imap_config = {'server': 'test.com', 'port': 993, 'username': 'test', 'password': 'pass'}
db.session.add(user)
db.session.commit()
client.post('/auth/login', data={
'email': 'test3@example.com',
'password': 'password'
})
response = client.post('/api/imap/sync')
# Should fail without real IMAP server but return proper response
assert response.status_code in [200, 400]