设为首页 加入收藏

TOP

Testlink接口使用方法-python语言远程调用(一)
2017-09-30 13:31:48 】 浏览:2592
Tags:Testlink 接口 使用方法 python 语言 远程 调用
 1 deepin@deepin-pc:~/test$ cat libclienttestlink.py 
 2 #!/usr/bin/env python3
 3 # -*- coding: utf-8 -*-
 4 
 5 #! /usr/bin/python
 6 #
 7 # Testlink API Sample Python 3.1.2 getProjects() - Client implementation
 8 # 
 9 import xmlrpc.client
10 
11 class TestlinkAPIClient:        
12     # substitute your server URL Here
13     SERVER_URL = "https://******************************/xmlrpc.php"
14       
15     def __init__(self):
16         self.server = xmlrpc.client.ServerProxy(self.SERVER_URL)
17         self.devKey = "your user key"
18 
19     def getInfo(self):
20         return self.server.tl.about()
21 
22     def getProjects(self):
23         return self.server.tl.getProjects(dict(devKey=self.devKey))
24 
25     def getClientTL(self):
26         return self.server.tl
27 
28 client = TestlinkAPIClient()
29 tlclient = client.getClientTL()
30 
31 args = {}
32 args["devKey"] = client.devKey
33 args["testplanname"] = "pythontest"
34 args["testprojectname"] = "LSTest"
35 
36 client = TestlinkAPIClient()
37 tlclient = client.getClientTL()
38 
39 print(client.getInfo())
40 print("-" * 80)
41 print(tlclient.getTestPlanByName(args))

把代码中变量设置为本地环境后就可以实现远程调用Testlink了。

 

输出结果:

1 deepin@deepin-pc:~/test$ python3 libclienttestlink.py 
2  Testlink API Version: 1.0 initially written by Asiel Brumfield
3  with contributions by TestLink development Team
4 --------------------------------------------------------------------------------
5 [{'name': 'pythontest', 'is_public': '1', 'testproject_id': '56567', 'notes': '', 'is_open': '1', 'id': '56582', 'api_key': 'c48e5b0e375c13c847b4148fcf4e283615619e52b427c11ff023e4a7d9b78bd1', 'active': '1'}]
6 deepin@deepin-pc:~/test$

 

未完待续

Testlink源代码链接:

https://github.com/TestLinkOpenSourceTRMS/testlink-code/blob/5bb8e574ecc4adca5664437ee3a80c9e8d7c434d/lib/api/xmlrpc/v1/xmlrpc.class.php

'tl.reportTCResult' => 'this:reportTCResult',
'tl.setTestCaseExecutionResult' => 'this:reportTCResult',
'tl.createBuild' => 'this:createBuild',
'tl.createPlatform' => 'this:createPlatform',
'tl.createTestCase' => 'this:createTestCase',
'tl.createTestCaseSteps' => 'this:createTestCaseSteps',
'tl.createTestPlan' => 'this:createTestPlan',
'tl.createTestProject' => 'this:createTestProject',
'tl.createTestSuite' => 'this:createTestSuite',
'tl.deleteTestCaseSteps' => 'this:deleteTestCaseSteps',
'tl.deleteTestPlan' => 'this:deleteTestPlan',
'tl.deleteTestProject' => 'this:deleteTestProject',
'tl.uploadExecutionAttachment' => 'this:uploadExecutionAttachment',
'tl.uploadRequirementSpecificationAttachment' => 'this:uploadRequirementSpecificationAttachment',
'tl.uploadRequirementAttachment' => 'this:uploadRequirementAttachment',
'tl.uploadTestProjectAttachment' => 'this:uploadTestProjectAttachment',
'tl.uploadTestSuiteAttachment' => 'this:uploadTestSuiteAttachment',
'tl.uploadTestCaseAttachment' => 'this:uploadTestCaseAttachment',
'tl.uploadAttachment' => 'this:uploadAttachment',
'tl.assignRequirements' => 'this:assignRequirements',
'tl.addTestCaseToTestPlan' => 'this:addTestCaseToTestPlan',
'tl.addPlatformToTestPlan' => 'this:addPl

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python学习笔记九-文件读写 下一篇program 1 : python codes for lo..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目