feat: debug_single_testcase

This commit is contained in:
debugtalk
2020-02-29 23:28:11 +08:00
parent 14cb49c771
commit c419322006

View File

@@ -0,0 +1,50 @@
from fastapi import APIRouter
from httprunner.api import HttpRunner
from httprunner.schema import ProjectMeta, TestCase
router = APIRouter()
runner = HttpRunner()
@router.post("/hrun/debug/testcase", tags=["debug"])
async def debug_single_testcase(project_meta: ProjectMeta, testcase: TestCase):
resp = {
"code": 0,
"message": "success",
"result": {}
}
tests_mapping = {
"project_mapping": project_meta,
"testcases": [testcase]
}
summary = runner.run_tests(tests_mapping)
if not summary["success"]:
resp["code"] = 1
resp["message"] = "fail"
resp["result"] = summary
return resp
# @router.post("/hrun/debug/api", tags=["debug"])
# async def debug_single_api():
# resp = {
# "code": 0,
# "message": "success",
# "result": {}
# }
#
# # tests_mapping
#
# # summary = runner.run_tests(tests_mapping)
#
# return resp
#
#
# @router.post("/hrun/debug/testcases", tags=["debug"])
# async def debug_multiple_testcases(project_meta: ProjectMeta, testcases: TestCases):
# tests_mapping = {
# "project_mapping": project_meta,
# "testcases": testcases
# }