"""Standalone tests: no tests/conftest.py or account/database fixture required.""" import json from uuid import uuid4 from unittest.mock import patch import pytest from contact_app import create_app, deliver VALID = dict(name='Example Person', email='person@example.com', service='', description='A useful software project enquiry.', website='') KEY = str(uuid4()) @pytest.fixture def app(): return create_app(dict(TESTING=True, EMAIL_DELIVERY_ENABLED=True, EMAIL_FROM='BortStack ', CONTACT_EMAIL='business@example.com', RESEND_API_KEY='test-only')) def post(app, data=VALID, key=KEY): return app.test_client().post('/api/contact', json=data, headers={'Idempotency-Key': key}) def test_independent_no_database_or_account_routes(app): assert 'sqlalchemy' not in app.extensions assert app.test_client().get('/api/health/ready').status_code == 200 assert app.test_client().get('/api/users').status_code == 404 assert app.test_client().get('/api/contact/config').json == {'email': 'business@example.com', 'available': True} def test_success_safe_sender_replyto_and_escaping(app): with patch('contact_app.deliver') as send: r = post(app, {**VALID, 'name': ''}) assert r.status_code == 200 and r.json['success'] is True payload, key, _ = send.call_args.args assert payload['from'] == 'BortStack ' assert payload['reply_to'] == VALID['email'] assert payload['to'] == ['business@example.com'] assert '