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")
Advertisement
3 Comments
hi,
I was trying out the sample code given on the Testlink website and i got a INVALID_AUTH –> authentication error. Do have any idea waht might have gone wrong.
Note: I have just copy pasted the same code!
have you created an API key for yourself?
Your example doesn’t work either. In the function ‘reportTCResult’ the ‘data’ dictionary key ‘testcaseid’ has an undefined value, ‘testcaseid’; I suspect you meant to use ‘testcaseexternalid’ here, as this is what you have in the function definition.