Sample Testlink API client in python

"""
Testlink API Sample Python Client implementation
"""
import xmlrpclib

class TestlinkAPIClient:
    # substitute your server URL Here
    SERVER_URL = "http://localhost/testlink/lib/api/xmlrpc.php"

    def __init__(self, devKey):
        self.server = xmlrpclib.Server(self.SERVER_URL)
        self.devKey = devKey
        print "devKey in init: %s" %devKey

    def getTestCaseIDByName(self,devKey):
        data = {"devKey":devKey, "testcasename":"Test Case 1", "testsuitename":"Test Suite 1"}
        return self.server.tl.getTestCaseIDByName(data)

    def reportTCResult(self, tcid, tpid, status):
        data = {"devKey":self.devKey, "tcid":tcid, "tpid":tpid, "status":status}
        return self.server.tl.reportTCResult(data)

    def getInfo(self):
        return self.server.tl.about()

    def sayHello (self):
        return self.server.tl.sayHello()

    def getProjects (self, devKey):
        print "DevKey: %s" %devKey
        data = {"devKey":devKey}
        return self.server.tl.getProjects(data)

if __name__ == ‘__main__‘:
    devKey = "abc04556463cd813a1ea05caf042d42f"
    # substitute your Dev Key Here
    client = TestlinkAPIClient (devKey)
    # get info about the server
    print client.getInfo()

    # retval = client.sayHello()

    #retval = client.getProjects(devKey)
    retval = client.getTestCaseIDByName(devKey)

    print ‘retval: ‘, retval

Please note, you will need to generate a devKey for this to work from within your Testlink installation.

Steps to enable Testlink API via xmlrpc and generate dev key:

  1. Open config.inc.php
  2. Search for  /** XML-RPC API availability (disabled by default) */ $tlCfg->api->enabled = FALSE;
  3. Change FALSE to TRUE $tlCfg->api->enabled = TRUE;
  4. Save config.inc.php
  5. Login to Testlink UI as admin
  6. Go to ‘My Settings‘
  7. Under API interface, click ‘Generate new key‘
  8. Copy the key generated
  9. Substitute your newly generated devKey in the client program Example: client = TestlinkAPIClient(devKey="abc04556463cd813a1ea05caf042d42f")

This should be sufficient for a test the Testlink xmlrpc API client server communication. You can then go ahead and use the client program as a library to be called from within your python test scripts (talking from a Selenium python user perspective). You could do similar implementation with other scripts.

Hope you find this useful.

时间: 2024-10-10 13:55:22

Sample Testlink API client in python的相关文章

ECSHOP /api/client/includes/lib_api.php

ecshop /api/client/api.php./api/client/includes/lib_api.php ECShop存在一个盲注漏洞,问题存在于/api/client/api.php文件中,提交特制的恶意POST请求可进行SQL注入攻击,可获得敏感信息或操作数据库. 参照以下修改: function API_UserLogin($post) { /* SQL注入过滤 */ if (get_magic_quotes_gpc()) { $post['UserId'] = $post[

[WEB API] CLIENT 指定请求及回应格式(XML/JSON)

[Web API] Client 指定请求及响应格式(xml/json) Web API 支持的格式请参考 http://www.asp.net/web-api/overview/formats-and-model-binding 本篇则要演练xml/json 回应 Get 定义 Header:Content-Type 定义 QueryString 请求 Post POST json 数据 POST xml 数据 回应 Get 定义 Header:Content-Type 测试工具:本来想用 p

kubeadm init 卡在 Created API client, waiting for the control plane to become ready

执行 kubeadm init 时出现卡在了 [apiclient] Created API client, waiting for the control plane to become ready这里,查看日志 journalctl -xeu kubelet 发现是 gcr.io/google_containers/pause-amd64:3.0 没有pull下来,找到解决方法: docker pull docker.io/kubernetes/pause docker tag docker

Windows API Hooking in Python

catalogue 0. 相关基础知识 1. Deviare API Hook Overview 2. 使用ctypes调用Windows API 3. pydbg 4. winappdbg 5. dll injection 6. process monitor with WMI 7. sobek-hids 0.  相关基础知识 0x1: Python 程序和 C 程序的整合 为了节省软件开发成本,软件开发人员希望能够缩短的软件的开发时间,希望能够在短时间内开发出稳定的产品.Python 功能强

ecshop /api/client/api.php、/api/client/includes/lib_api.php SQL Injection Vul

catalog 1. 漏洞描述 2. 漏洞触发条件 3. 漏洞影响范围 4. 漏洞代码分析 5. 防御方法 6. 攻防思考 1. 漏洞描述 ECShop存在一个盲注漏洞,问题存在于/api/client/api.php文件中,提交特制的恶意POST请求可进行SQL注入攻击,可获得敏感信息或操作数据库 http://sebug.net/vuldb/ssvid-21007 2. 漏洞触发条件 1. /api/client/api.php存在未过滤漏洞 2. 服务器magic_quote_gpc =

springCloud com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect

1.com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect 或者com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server 原因如下: 在默认设置下,Eureka服务注册中心也会将自己作为客户端来尝试注

新浪微博API的使用Python

本文记录了用新浪微博官方Python SDK调用API进行开发的流程. 准备工作 申请成为开发者并创建一个应用: 首先要有一个新浪微博的账号,然后去新浪微博开放平台(http://open.weibo.com/)创建一个应用,具体的步骤官网文档介绍的非常详细:在开发者页面点击“登录” -> “创建应用” -> 选择应用类型(如“网页应用”)-> 填写应用信息. P.S.,应用需要设置一个回调地址(CALL_BACK),可以设定为默认的回调网址:https://api.weibo.com/

文本转音频(百度语音合成api)(python)

1,UI界面设计(精简设计),使用tk框架 功能说明:1,文本标记功能整合进程序中:2,联网的http API接口整合: 1,网络检查: 2,断网异常检测: 3,网络传数据.接数据:3,文本转语音的baidu-api接口整合 1,语速,取值0-9,默认为5中语速: 2,音调,取值0-9,默认为5中语调: 3,音量,取值0-15,默认为5中音量: 4,发音人选择, 0为女声,1为男声,3为情感合成-度逍遥,4为情感合成-度丫丫,默认为普通女:4,音频保存自主设置: 注:其中的逗号.句号重复是甲方要

使用ASP.NET Web API和Web API Client Gen使Angular 2应用程序的开发更加高效

本文介绍“ 为ASP.NET Web API生成TypeScript客户端API ”,重点介绍Angular 2+代码示例和各自的SDLC.如果您正在开发.NET Core Web API后端,则可能需要阅读为ASP.NET Core Web API生成C#Client API. 背景 自WebApiClientGenAngular 2仍然在RC2时,自2016年6月v1.9.0-beta 以来,对Angular2的支持已经可用.并且在WebApiClientGenv2.0中提供了对Angula