69 lines
No EOL
1.9 KiB
Python
69 lines
No EOL
1.9 KiB
Python
"""
|
|
Tests for Café Bach Email Generator - App Routes
|
|
"""
|
|
|
|
import pytest
|
|
from app import create_app
|
|
from app.config import TestingConfig
|
|
|
|
|
|
@pytest.fixture
|
|
def client():
|
|
"""Create a test client."""
|
|
app = create_app('testing')
|
|
app.config.from_object(TestingConfig)
|
|
|
|
with app.test_client() as client:
|
|
yield client
|
|
|
|
|
|
def test_index_page(client):
|
|
"""Test that the index page loads successfully."""
|
|
response = client.get('/')
|
|
assert response.status_code == 200
|
|
assert b'Café Bach Email Generator' in response.data
|
|
|
|
|
|
def test_generate_page(client):
|
|
"""Test that the generate page loads successfully."""
|
|
response = client.get('/generate')
|
|
assert response.status_code == 200
|
|
assert b'Create Email Invitation' in response.data
|
|
|
|
|
|
def test_generate_post(client):
|
|
"""Test the generate POST endpoint."""
|
|
data = {
|
|
'title': 'Test Event',
|
|
'date_time': '2024-12-25T18:00',
|
|
'location': 'Test Location',
|
|
'description': 'This is a test event.',
|
|
'button_text': 'RSVP Now',
|
|
'button_url': 'https://example.com/rsvp',
|
|
}
|
|
response = client.post('/generate', json=data)
|
|
assert response.status_code == 200
|
|
json_data = response.get_json()
|
|
assert json_data['status'] == 'success'
|
|
|
|
|
|
def test_preview_page(client):
|
|
"""Test that the preview page loads successfully."""
|
|
response = client.get('/preview')
|
|
assert response.status_code == 200
|
|
assert b'Email Preview' in response.data
|
|
|
|
|
|
def test_preview_post(client):
|
|
"""Test the preview POST endpoint."""
|
|
data = {
|
|
'title': 'Test Event',
|
|
'date_time': '2024-12-25T18:00',
|
|
'location': 'Test Location',
|
|
'description': 'This is a test event.',
|
|
'button_text': 'RSVP Now',
|
|
'button_url': 'https://example.com/rsvp',
|
|
}
|
|
response = client.post('/preview', json=data)
|
|
assert response.status_code == 200
|
|
assert b'Test Event' in response.data |