feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口

完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
hugo committed 2026-08-11 14:04:39 +08:00
1 parent 8e0bbf7a81
commit c94d173f92
181 files changed
+12947 -1724

No files matched your search

+12 -13
View File
@@ -4,9 +4,9 @@ from app.models import User, Agent, Department, PermissionRequest
@pytest.fixture
def client():
app = create_app()
app.config['TESTING'] = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
# 必须在扩展初始化前选择 testing 配置;create_app() 默认会绑定开发 PostgreSQL,
# 之后再覆盖 URI 不会迁移已绑定的 engine,容易把夹具写入共享库并污染全量测试。
app = create_app('testing')
with app.test_client() as client:
with app.app_context():
@@ -24,9 +24,8 @@ def get_headers(client, username='admin', password='admin'):
res = client.post('/api/user/login', json={'username': username, 'password': password})
data = res.get_json()
return {
'X-User-Id': str(data['id']),
'X-Username': data['username'],
'X-Role': data['role']
'Authorization': f"Bearer {data['access_token']}",
'Content-Type': 'application/json',
}
def test_department_crud(client):
@@ -114,6 +113,7 @@ def test_permission_flow(client):
client.post('/api/admin/agents', json={
'name': 'Test Agent',
'dify_app_id': 'app-123'
, 'dify_api_key': 'test-key'
}, headers=admin_headers)
agent_id = 1
@@ -129,13 +129,12 @@ def test_permission_flow(client):
# User Login
user_headers = get_headers(client, 'user1', 'password')
# Request Permission
res = client.post('/api/user/permission-requests', json={
'agent_id': agent_id,
'reason': 'I need it'
}, headers=user_headers)
assert res.status_code == 201
req_id = res.get_json()['id']
# 当前后端只保留管理员审批 API;测试直接创建待审事实,避免依赖已移除的用户申请路由。
with client.application.app_context():
request_row = PermissionRequest(user_id=2, agent_id=agent_id, reason='I need it', status='pending')
db.session.add(request_row)
db.session.commit()
req_id = request_row.id
# Admin List Requests
res = client.get('/api/admin/permission-requests', headers=admin_headers)