fix(接口测试): 修复python3脚本模版
--bug=1037195 --user=王孝刚 【接口测试】前置脚本插入多条公共脚本注释不正确 https://www.tapd.cn/55049933/s/1476296 --bug=1037199 --user=王孝刚 【接口测试】接口调试执行python终止测试提示异常 https://www.tapd.cn/55049933/s/1476304
This commit is contained in:
parent
41690bb922
commit
60df9b676a
|
@ -108,6 +108,16 @@
|
|||
headers.set('Content-type', 'application/json');
|
||||
return getCodeTemplate(innerLanguageType.value, { requestHeaders: headers });
|
||||
}
|
||||
case 'api_stop': {
|
||||
if (innerLanguageType.value === LanguageEnum.PYTHON) {
|
||||
return `
|
||||
import java
|
||||
StandardJMeterEngine = java.type('org.apache.jmeter.engine.StandardJMeterEngine')
|
||||
StandardJMeterEngine.stopThreadNow(ctx.getThread().getThreadName())
|
||||
`;
|
||||
}
|
||||
return 'ctx.getEngine().stopThreadNow(ctx.getThread().getThreadName());';
|
||||
}
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
import { useVModel } from '@vueuse/core';
|
||||
|
||||
import MsCodeEditor from '@/components/pure/ms-code-editor/index.vue';
|
||||
import { Language } from '@/components/pure/ms-code-editor/types';
|
||||
import { Language, LanguageEnum } from '@/components/pure/ms-code-editor/types';
|
||||
import MsTag from '@/components/pure/ms-tag/ms-tag.vue';
|
||||
import FormApiImportDrawer from './formApiImportDrawer.vue';
|
||||
import InsertCommonScript from './insertCommonScript.vue';
|
||||
|
@ -161,10 +161,17 @@
|
|||
} else {
|
||||
let scriptStr = '';
|
||||
data.forEach((item) => {
|
||||
if (item.type === LanguageEnum.PYTHON) {
|
||||
scriptStr += `
|
||||
# ${item.name}
|
||||
${item.script}
|
||||
`;
|
||||
} else {
|
||||
scriptStr += `
|
||||
// ${item.name}
|
||||
${item.script}
|
||||
`;
|
||||
}
|
||||
});
|
||||
codeEditorRef.value?.insertContent(scriptStr);
|
||||
showInsertDrawer.value = false;
|
||||
|
|
|
@ -49,7 +49,8 @@ export const SCRIPT_MENU: CommonScriptMenu[] = [
|
|||
},
|
||||
{
|
||||
title: t('project.processor.terminationTest'),
|
||||
value: 'ctx.getEngine().stopThreadNow(ctx.getThread().getThreadName());',
|
||||
value: 'api_stop',
|
||||
command: 'api_stop',
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -235,17 +236,20 @@ function _pythonCodeTemplate(obj) {
|
|||
|
||||
const host = domain + (port ? `:${port}` : '');
|
||||
|
||||
return `import httplib,urllib
|
||||
return `import http.client
|
||||
import urllib.parse
|
||||
params = ${reqBody} #例 {'username':'test'}
|
||||
headers = ${headers} #例 {'Content-Type':'application/json'} 或 {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}
|
||||
# Specify the host and the HTTP endpoint you want to hit
|
||||
host = '${host}'
|
||||
path = '${requestPath}'
|
||||
method = '${requestMethod}' # POST/GET
|
||||
|
||||
conn = httplib.${connType}(host)
|
||||
conn.request(method, path, params, headers)
|
||||
conn = http.client.${connType}(host)
|
||||
conn.request(method, path, urllib.parse.urlencode(params), headers)
|
||||
res = conn.getresponse()
|
||||
data = unicode(res.read(), 'utf-8')
|
||||
data = res.read().decode('utf-8')
|
||||
conn.close()
|
||||
log.info(data)
|
||||
`;
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ export default {
|
|||
' menu.bugManagement.bugRecycle': 'Recycle',
|
||||
'menu.caseManagement': 'Case Management',
|
||||
'menu.apiTest': 'API Test',
|
||||
'menu.apiTest.debug': 'API debug',
|
||||
'menu.apiTest.debug': 'Debug',
|
||||
'menu.apiTest.debug.debug': 'Debug',
|
||||
'menu.apiTest.management': 'API Management',
|
||||
'menu.apiTest.management.definition': 'API Definition',
|
||||
'menu.apiTest.management': 'Definition',
|
||||
'menu.apiTest.management.definition': 'Definition',
|
||||
'menu.apiTest.scenario': 'Scenario',
|
||||
'menu.apiTest.report': 'API Report',
|
||||
'menu.apiTest.report': 'Report',
|
||||
'menu.uiTest': 'UI Test',
|
||||
'menu.performanceTest': 'Performance Test',
|
||||
'menu.projectManagement': 'Project',
|
||||
|
|
|
@ -25,13 +25,13 @@ export default {
|
|||
'menu.bugManagement.bugRecycle': '回收站',
|
||||
'menu.caseManagement': '用例管理',
|
||||
'menu.apiTest': '接口测试',
|
||||
'menu.apiTest.debug': '接口调试',
|
||||
'menu.apiTest.debug': '调试',
|
||||
'menu.apiTest.debug.debug': '调试',
|
||||
'menu.apiTest.management': '接口管理',
|
||||
'menu.apiTest.management.definition': '接口定义',
|
||||
'menu.apiTest.management': '定义',
|
||||
'menu.apiTest.management.definition': '定义',
|
||||
'menu.apiTest.api': 'API列表',
|
||||
'menu.apiTest.scenario': '场景',
|
||||
'menu.apiTest.report': '接口报告',
|
||||
'menu.apiTest.report': '报告',
|
||||
'menu.uiTest': 'UI测试',
|
||||
'menu.workstation': '工作台',
|
||||
'menu.loadTest': '性能测试',
|
||||
|
|
|
@ -48,7 +48,8 @@ export const SCRIPT_MENU: CommonScriptMenu[] = [
|
|||
},
|
||||
{
|
||||
title: t('project.processor.terminationTest'),
|
||||
value: 'ctx.getEngine().stopThreadNow(ctx.getThread().getThreadName());',
|
||||
value: 'api_stop',
|
||||
command: 'api_stop',
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ export default {
|
|||
'project.fileManagement.caseFileVersion': 'Associated file version',
|
||||
'project.fileManagement.caseTypeBug': 'Bug',
|
||||
'project.fileManagement.caseTypeFeature': 'Feature',
|
||||
'project.fileManagement.caseTypeApiDebug': 'Api debug',
|
||||
'project.fileManagement.caseTypeApiDebug': 'Debug',
|
||||
'project.fileManagement.caseTypeApiScene': 'Api scene',
|
||||
'project.fileManagement.caseTypeApiCase': 'Api case',
|
||||
'project.fileManagement.caseTypeApiDefine': 'Api definition',
|
||||
|
|
|
@ -130,7 +130,7 @@ export default {
|
|||
'project.fileManagement.caseFileVersion': '关联的文件版本',
|
||||
'project.fileManagement.caseTypeBug': '缺陷',
|
||||
'project.fileManagement.caseTypeFeature': '功能用例',
|
||||
'project.fileManagement.caseTypeApiDebug': '接口调试',
|
||||
'project.fileManagement.caseTypeApiDebug': '调试',
|
||||
'project.fileManagement.caseTypeApiScene': '接口场景',
|
||||
'project.fileManagement.caseTypeApiCase': '接口用例',
|
||||
'project.fileManagement.caseTypeApiDefine': '接口定义',
|
||||
|
|
Loading…
Reference in New Issue