There are lots of Testlink API client examples in Python. None-of-them-work. I’d like to think mine does:

#!/usr/bin/env python
import xmlrpclib

class TestlinkAPIClient:
    SERVER_URL = "http://testlink.splunk.com/lib/api/xmlrpc.php"

    def __init__(self, devKey):
        self.server = xmlrpclib.Server(self.SERVER_URL)
        self.devKey = devKey

    def reportTCResult(self, testcaseexternalid, testplanid, status):
        # fyi: this is XML-RPC, the order of our parameters matters.
        data = {"devKey":self.devKey, "testcaseid":testcaseid, \
        "testplanid":testplanid, "status":status, "guess":True}
        return self.server.tl.reportTCResult(data)

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

# substitute your Dev Key Here
client = TestlinkAPIClient(devKey="xxx")

# get info about the server
print client.getInfo()

# Substitute for tcid and tpid that apply to your project
print client.reportTCResult(testcaseexternalid='splunk-655', \
testplanid=1328, status="p")

Post a Comment

*
*