Files
email-organizer/tests/test_routes.py
2025-08-03 21:35:22 -07:00

28 lines
1.0 KiB
Python

import pytest
from app.models import User, Folder
import uuid
def test_index_route(client, app, mock_user):
response = client.get('/')
assert response.status_code == 200
# Check if the page contains expected elements
assert b'Email Organizer' in response.data
assert b'Folders' in response.data
def test_add_folder_route(client, mock_user):
"""Test the add folder API endpoint."""
# Get initial count of folders for the user
initial_folder_count = Folder.query.count()
# Send form data (URL encoded) instead of JSON
response = client.post('/api/folders',
data={'name': 'Test Folder', 'rule_text': 'Test rule something ok yes'},
content_type='application/x-www-form-urlencoded')
print(response.__dict__)
# Verify the response status is 201 Created
assert response.status_code == 201
# Verify that the number of folders has increased
final_folder_count = Folder.query.count()
assert final_folder_count > initial_folder_count