""" 示例测试文件 展示如何编写测试 """ import pytest from src.your_app import db from src.your_app.models.example import Example def test_index(client): """ 测试首页路由 """ response = client.get('/') assert response.status_code == 200 data = response.get_json() assert data['status'] == 'ok' def test_health(client): """ 测试健康检查路由 """ response = client.get('/health') assert response.status_code == 200 data = response.get_json() assert data['status'] == 'healthy' def test_example_model(app): """ 测试示例模型 """ with app.app_context(): example = Example(name='Test', description='Test description') db.session.add(example) db.session.commit() assert example.id is not None assert example.name == 'Test' assert example.description == 'Test description'