From 35f59c0ec949750b2ed0c3553c50f694992b0b4b Mon Sep 17 00:00:00 2001 From: Toby Qin Date: Wed, 25 Oct 2017 15:24:40 +0800 Subject: [PATCH] able to use reset object in reset command. --- docs/testcube_design.xmind | Bin 795240 -> 810893 bytes testcube/core/forms.py | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/docs/testcube_design.xmind b/docs/testcube_design.xmind index fbfe50733f766e0a2bd6552dd5a6f1e9eab82ba5..0b9da5742253811e6d11d2ba6d8bfd3dbe9eeb19 100644 GIT binary patch delta 11300 zcmeHNd6*Q{wXf=)>6z*7VSpZBdKRW<1X+feslB^k7*JLngi+BbZuC-Jz3S^}GE2S?Z1_>DvB2eMLP{U0qF3OD^4B`y#1_?}1mzD@db5q&b0eFd{uL zUH@;_Rg4^WXfHZzn_-ZS#Ak zw%enQIL`}|FOhJk6o;I4L{rIx%cY>*&ye-#=$Yi4GjJ#`3ZjFb*cpN+}zB zDxs8Zb|{)@TP2`16Lb|LL_cFs&>@e`GaZB?UWsCKu{t~Dn>`q`DYu) zPr&VC1&U{xJZ^s?>QUS&Tc>S7L|PbykJ)}HgxbuymWB|`Ien3&YT)6S)n zc9##P#IS$r)rRz{7~n?Jc?_r99Zh)r5!sfC;=zQ8(UpSv=XNHgE*Mrk9QYfC7ae?( z6dUYrF3s?M#lwXuMua4(sdbmP^M(16Z>idE_)tP<%~^V}L2xF5 zP8Y}c!cm^3d7cZ#>>M3+A@U}zcr6%>XYE`O+CpbCXq)SdcwlC1(A%v77Z*}~9(utm ze8?MBL?$ZIZeIdz)f>lmsR#^5v4!%h!N(_W3d2PslFhXgzR=bloxLH-hoWwOK!`={ zUYU&q?J~>LqAP~B9x#q?)7r#11TkMn>1xTXz)(O5;SNJbdn!0|bga(QASqJV6^O+uULe4~JDcliKT1qUn@wTuZ9sH@@ zVdZ?B-RBAUqA-F!$?f$sac^7-$zG_PHWKPolm6!+5Q|N;` zBsn8CC1!I$mDG$jr#A)J8Jows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ducQ9f1EH;8^2hUKgc9#5 zfzMKBF&`;j`|huS&WU6ScPm!v@vPTqj#|RCPNZCVB2@M~aAJbnB4c-A?o`V@D=xScogJpx=G=hB*+<7LVHWy%)oJ>NeBgl z$#td}aZ?Fguy0kr@!2-t9zDNbGD0z6^02E85+>cEt`fK^3zkSa^#dSp#b{cGH%0^X z);@_k*sk)ws8?547hHoJ5rk8@)zhZGx8SMAeKzJdxl+rvq2z4x7 zq7q>Y^!q@RtQe=)jzmZWCeMT4C1KK07MFpJ?zE&s#!38r8BK8mDDIO;HM!arOvXyT zm;2~kRbERWLI=R)Iewf;t~{U|8DH^Nz=;=iYUHM~N@%wT zO#U+1ay8N$4r8s9BeN28>L*edCR^#B&RqolbPt8eaEsMrseE1G*Eugt2t5Il%iGmj zQJxIFe&3I!V?nZ^kK}=GXKJAnfuz)l2)8tgaxe?~7w*}l#U;2mLhHfgSyxV_aWF4S zhia(;xer#*&A_ybjpJyh=i~TrMZ|6`!cIHi%kS}c&&i=sLC=rnvKCJq&qsDEM#ZQh L8lhbb%wFjKwSIoz diff --git a/testcube/core/forms.py b/testcube/core/forms.py index 7ebcbe4..38fe01c 100644 --- a/testcube/core/forms.py +++ b/testcube/core/forms.py @@ -102,24 +102,26 @@ def save(self, result_id, username): self.add_error('reason', 'Please configure reset profile at first.') return - cmd, error = _parse_command(profile.command, result) + # add reset result object + reset = ResetResult(reset_by=username, + reset_reason=reason, + reset_status=1, # in progress + origin_result=result) # if reset with error, abort tasks + cmd, error = _parse_command(profile.command, result, reset) if error: self.add_error('reason', 'Failed to reset result {}'.format(error)) return - # add reset result object - reset_result = ResetResult(reset_by=username, - reset_reason=reason, - reset_status=1, # in progress - origin_result=result) + reset.save() - reset_result.save() + # now generate cmd with real reset id + cmd = _parse_command(profile.command, result, reset)[0] # add reset task object data = {'result_id': result_id, - 'reset_id': reset_result.id, + 'reset_id': reset.id, 'reason': reason, 'by': username} @@ -132,14 +134,14 @@ def save(self, result_id, username): task.save() -def _parse_command(command, result): +def _parse_command(command, result, reset): """ method to parse reset command. for example: http://server/reset_job?testcase={result.testcase.name}&result_id={result.id} will be parsed according under current result context. """ try: - cmd = command.format(result=result) + cmd = command.format(result=result, reset=reset) return cmd, None except Exception as e: logger.exception('Failed to parse command: {}'.format(command))