use multiple apis
This commit is contained in:
@@ -15,11 +15,12 @@ _TYPE_EMOJI = {
|
||||
|
||||
|
||||
def _post(data: dict):
|
||||
requests.post(
|
||||
webhook_url,
|
||||
headers={"Content-Type": "application/json"},
|
||||
data=json.dumps(data, ensure_ascii=False)
|
||||
)
|
||||
return
|
||||
# requests.post(
|
||||
# webhook_url,
|
||||
# headers={"Content-Type": "application/json"},
|
||||
# data=json.dumps(data, ensure_ascii=False)
|
||||
# )
|
||||
|
||||
|
||||
def _make_card(title: str, color: str, elements: list) -> dict:
|
||||
@@ -136,32 +137,6 @@ def send_generate_code(code_result: CodeGenerationResult):
|
||||
[{"tag": "markdown", "content": f"```java\n{code_result['unit_tests']}\n```"}]
|
||||
))
|
||||
|
||||
# 单元测试执行结果
|
||||
try:
|
||||
total = int(code_result["unit_tests_count"])
|
||||
passed = int(code_result["passed_tests_count"])
|
||||
failed = total - passed
|
||||
rate = f"{passed / total * 100:.0f}%" if total > 0 else "—"
|
||||
status = "✅ 全部通过" if failed == 0 else f"⚠️ {failed} 个未通过"
|
||||
failed_display = f"{failed} ❌" if failed > 0 else "0"
|
||||
except (ValueError, TypeError):
|
||||
total = code_result["unit_tests_count"]
|
||||
passed = code_result["passed_tests_count"]
|
||||
failed_display, rate, status = "—", "—", "—"
|
||||
|
||||
result_md = (
|
||||
f"**总用例数:** {total}\n\n"
|
||||
f"**通过:** {passed} ✅\n\n"
|
||||
f"**未通过:** {failed_display}\n\n"
|
||||
f"**通过率:** {rate}\n\n"
|
||||
f"---\n\n"
|
||||
f"**整体状态:** {status}"
|
||||
)
|
||||
_post(_make_card(
|
||||
"📊 代码生成结果 — 单元测试执行结果", "green",
|
||||
[{"tag": "markdown", "content": result_md}]
|
||||
))
|
||||
|
||||
|
||||
def send_test_cases(test_case: TestCaseResult):
|
||||
_post(build_full_feishu_card(test_case))
|
||||
|
||||
Reference in New Issue
Block a user