feat: 退网评估后端:单个或清单提交,按逻辑站点并行评估并写入固定模板
每个逻辑站点一个排队任务,与采集共用并行数量;工参按拆除前后规则取本系统快照,指标暂用模拟数据;全部站点结束后写频段清退、低效拆除两份结果表。去掉原来的通用导出任务。
This commit is contained in:
@@ -277,35 +277,39 @@ def test_switch_to_local_needs_no_local_admin_when_hosted(hosted: TestClient):
|
||||
assert back.json()["loginMode"] == "local"
|
||||
|
||||
|
||||
def test_local_user_runs_export(hosted: TestClient):
|
||||
from app.models import ExportTask, User
|
||||
def test_local_user_runs_evaluation(hosted: TestClient, monkeypatch):
|
||||
from app.models import EvalJob, User
|
||||
from app.security import hash_password
|
||||
|
||||
monkeypatch.setenv("DECOM_EVAL_SOURCE", "mock")
|
||||
with session_scope() as session:
|
||||
session.add(User(username="worker", password_hash=hash_password("worker-pass"), role="user"))
|
||||
session.add(User(username="other", password_hash=hash_password("other-pass"), role="user"))
|
||||
login = hosted.post("/api/auth/login", json={"username": "worker", "password": "worker-pass"})
|
||||
headers = bearer(login.json()["token"])
|
||||
created = hosted.post("/api/tasks", json={"format": "csv", "cellKey": ""}, headers=headers)
|
||||
body = {"orderType": "频段清退", "removalDate": "2026-10-01", "city": "江门", "cells": [{"cgi": "460-00-8001-1", "cellName": "某站F-ZLH-1"}]}
|
||||
created = hosted.post("/api/eval/jobs/single", json=body, headers=headers)
|
||||
assert created.status_code == 200
|
||||
task_id = created.json()["task"]["id"]
|
||||
listing = []
|
||||
for _ in range(30):
|
||||
listing = hosted.get("/api/tasks", headers=headers).json()["tasks"]
|
||||
if listing[0]["status"] == "done":
|
||||
job_id = created.json()["job"]["id"]
|
||||
detail = {}
|
||||
for _ in range(50):
|
||||
detail = hosted.get(f"/api/eval/jobs/{job_id}", headers=headers).json()
|
||||
if detail["job"]["status"] in ("done", "partial", "failed"):
|
||||
break
|
||||
time.sleep(0.1)
|
||||
assert listing[0]["status"] == "done"
|
||||
assert detail["job"]["status"] == "done"
|
||||
with session_scope() as session:
|
||||
task = session.get(ExportTask, task_id)
|
||||
job = session.get(EvalJob, job_id)
|
||||
owner = session.scalar(select(User).where(User.username == "worker"))
|
||||
assert (task.owner_kind, task.owner_id) == ("local", str(owner.id))
|
||||
downloaded = hosted.get(f"/api/tasks/{task_id}/file", headers=headers)
|
||||
assert (job.owner_kind, job.owner_id) == ("local", str(owner.id))
|
||||
downloaded = hosted.get(f"/api/eval/jobs/{job_id}/files/pinduan", headers=headers)
|
||||
assert downloaded.status_code == 200
|
||||
other_login = hosted.post("/api/auth/login", json={"username": "other", "password": "other-pass"})
|
||||
assert hosted.get(f"/api/tasks/{task_id}/file", headers=bearer(other_login.json()["token"])).status_code == 404
|
||||
other = bearer(other_login.json()["token"])
|
||||
assert hosted.get(f"/api/eval/jobs/{job_id}/files/pinduan", headers=other).status_code == 404
|
||||
assert hosted.get(f"/api/eval/jobs/{job_id}", headers=other).status_code == 404
|
||||
admin_headers = identity("admin", user_id="a-1")
|
||||
assert hosted.get("/api/tasks", headers=bearer(admin_token(hosted), admin_headers)).status_code == 403
|
||||
assert hosted.get("/api/eval/jobs", headers=bearer(admin_token(hosted), admin_headers)).status_code == 403
|
||||
|
||||
|
||||
def test_index_gets_base_for_prefix(hosted: TestClient):
|
||||
|
||||
Reference in New Issue
Block a user