diff --git a/models/product_model.py b/models/product_model.py index fc251d1595b0d87d6f37af49848d3fec8a32fde1..7966b9e5d8dde596a29f4cd9e448482d0923ee3c 100644 --- a/models/product_model.py +++ b/models/product_model.py @@ -1,4 +1,4 @@ -from sqlalchemy import Column, String, Integer, select +from sqlalchemy import Column, String, Integer, select, Boolean from app import db from models import CommonModel @@ -13,6 +13,7 @@ class TestProduct(CommonModel): desc = Column(String(256), nullable=True, comment='产品描述') test_method = Column(String(256), nullable=True, comment='测试方法') test_requirement = Column(String(256), nullable=True, comment='测试要求') + need_config = Column(Boolean, nullable=False, default=False, comment='是否扩展配置') owner = Column(String(256), nullable=False, comment='测试产品创建人') diff --git a/services/plan_service.py b/services/plan_service.py index a66346242f75dd0aa82945bb899983d6a87c7df1..bab0c89962089d646045091a74e7bdf3302f74bd 100644 --- a/services/plan_service.py +++ b/services/plan_service.py @@ -166,7 +166,7 @@ async def delete(plan_id, user): return 'success', True -async def run_task(plan_id, user): +async def run_task(plan_id, user, config): plan = await Plan.query_obj_one(Plan.id == plan_id) if not plan: return ERROR_NO_REQUIREMENT_PERMISSION, False @@ -176,6 +176,11 @@ async def run_task(plan_id, user): return ERROR_NO_AUTO_TASK, False task_ids = plan.tasks.split(',') auto_task = await Task.query_obj_all(Task.id.in_(task_ids), Task.run_method == Task_Run_Method.AUTO) + if config: + for task in auto_task: + task.config += config + task.gmt_modified = datetime.now() + await task.update() await __start_auto_task(auto_task) await __start_manual_task(task_ids) plan.status = Status_EN.RUNNING diff --git a/services/product_service.py b/services/product_service.py index ee103ce2548651055328482bf332f505e29395e8..7616dc3e31871f6d3170fcf76fdb5257f78c74f0 100644 --- a/services/product_service.py +++ b/services/product_service.py @@ -73,7 +73,9 @@ async def create_product(data, creator): return test_product.to_dict(), True -async def run_check(test_product_id, user_infos): +async def run_check(request, user_infos): + test_product_id = request.get('test_product_id') + config = request.get('config', None) test_product = await TestProduct.query_obj_one(TestProduct.id == test_product_id) if not test_product: return ERROR_UN_EXISTED_PRODUCT, False @@ -88,7 +90,7 @@ async def run_check(test_product_id, user_infos): 'plan_id': result['id'], 'executor': user_infos['user_name'] }) - return await run_task(result['id'], user_infos) + return await run_task(result['id'], user_infos, config) async def modify_product(data, test_product_id, user): @@ -109,6 +111,8 @@ async def modify_product(data, test_product_id, user): test_product.test_method = data['test_method'] if 'test_requirement' in data: test_product.test_requirement = data['test_requirement'] + if 'need_config' in data: + test_product.need_config = data['need_config'] test_product.gmt_modified = datetime.now() await test_product.update() return test_product.to_dict(), True diff --git a/views/product_view.py b/views/product_view.py index 436a7c5e71da8f4fb9f577f4c360b4b8a973c4ac..41da1ca2607914dbde23682f0ccf1e0a2c71cc3c 100644 --- a/views/product_view.py +++ b/views/product_view.py @@ -68,10 +68,10 @@ async def delete(_, test_product_id, user_infos): return rsp(data=result) -@bp.get('/run/') +@bp.post('/run') @login_auth -async def run(_, test_product_id, user_infos): - result, ok = await run_check(test_product_id, user_infos) +async def run(request, user_infos): + result, ok = await run_check(request.json, user_infos) if not ok: return rsp(code=500, msg=result) return rsp(data=result)