NOTE: hard coded numbers are my local numbers for my own testcases. You will need to dig through the output of the "getTestCases" method to find the real tc_id because I was not able to find it in the testlink database(it's in there, I just don't know where) and it sure as hell isn't displayed through the Testlink GUI hehe.
Also, you will need to manually update your user account with a custom dev key. I couldn't figure out how to access the APIKey.php through python (or any other way for that matter) so i just manually added all 1's to my script_key field in the database.. here's the appropriate mysql command:
UPDATE users SET script_key="11111111111111111111111111111111" WHERE id="6"
Anyhow, this automatically updates my testcase. 2 files:
delete.py
import unittest, time, re
from Testlink.testlink import TestlinkAPIClient
if __name__ == "__main__":
client = TestlinkAPIClient()
print client.getInfo()
print client.getTestCases(109)
# Substitute for tcid and tpid that apply to your project
if 0: # BAD BAD I KNOW, I TOGGLED IT TO SEE IF PASS AND FAIL WERE WORKING
result = client.reportTCResult(103, 109, "p")
else:
result = client.reportTCResult(103, 109, "f")
# Typically you'd want to validate the result here and probably do something more useful with it
print "reportTCResult result was: %s" %(result)
testlink.py
"""
Testlink API Sample Python Client implementation
"""
import xmlrpclib
class TestlinkAPIClient:
# substitute your server URL Here
SERVER_URL = "http://localhost/testlink_beta3/lib/api/xmlrpc.php"
DEV_KEY = "11111111111111111111111111111111"
def __init__(self):
self.server = xmlrpclib.Server(self.SERVER_URL)
def reportTCResult(self, tcid, tpid, status):
data = {"devKey":self.DEV_KEY, "testcaseid":tcid, "testplanid":tpid, "status":status, "guess":"true"}
return self.server.tl.reportTCResult(data)
def getInfo(self):
return self.server.tl.about()
def getTestCases(self, tpid):
data = {"devKey":self.DEV_KEY, "testplanid":tpid}
return self.server.tl.getTestCasesForTestPlan(data)
*Working* Python API example
Moderators: Amaradana, TurboPT, TL Developers