How to get/set builds in Testlink thru API using Python?

Discussion and information for XML-RPC interface.

Moderators: Amaradana, TurboPT, TL Developers

How to get/set builds in Testlink thru API using Python?

Postby SQADude » Wed Jan 20, 2010 4:37 am

I am writing a script that will report our nightly test results into Testlink.

The test results will map to individual testcases.

However, I need a way to get or set the build in testlink.

The nightly test will generate a unique build number that will be obtained thru a system call to SGVN. This build number will be the build number in testlink.

I need to do this in Python.

The pseudocode would be:

if (build doesn't exist)
create build in testlink

report test execution using testcase ID and build number.

What is the API function that allows me to check if a build number exists for a testplan in testLink?

What is the API function that allows me to create a build in testLink for a particular testplan?

TestLink user
Posts: 9
Joined: Wed Jan 20, 2010 4:31 am

Postby djazz » Thu Feb 04, 2010 10:57 am

Hi SQLDude,

here is the code i just successfully tested to create a build (coming from the sample) :
Code: Select all
  1 #! /usr/bin/python
  2 """
  3 Testlink API Sample Python Client implementation
  4 """
  5 import xmlrpclib
  7 class TestlinkAPIClient:
  8     # substitute your server URL Here
  9     SERVER_URL = "http://myurl/lib/api/xmlrpc.php"
 11     def __init__(self, devKey):
 12         self.server = xmlrpclib.Server(self.SERVER_URL)
 13         self.devKey = devKey
 15     def reportTCResult(self, tcid, tpid, status):
 16         data = {"devKey":self.devKey, "tcid":tcid, "tpid":tpid, "status":status}
 17         return
 19     def createBuild(self, tpid, buildname, buildnotes):
 20         data = {"devKey":self.devKey, "testplanid":tpid, "buildname":buildname, "buildnotes":buildnotes}
 21         return
 23     def getInfo(self):
 24         return
 26 # substitute your Dev Key Here
 27 client = TestlinkAPIClient("11111111111111111111111111111111")
 28 # get info about the server
 29 print client.getInfo()
 30 result = client.createBuild(8, "My Build Name", "Classic Build")
 31 # Substitute for tcid and tpid that apply to your project
 32 #result = client.reportTCResult(1132, 56646, "p")
 33 # Typically you'd want to validate the result here and probably do something more useful with it
 34 print "createBuild result was: %s" %(result)

You will have to provide your test plan id in createBuild, take a look at the id in the database with SQL command "select * from testplans;"
TestLink user
Posts: 8
Joined: Thu Feb 04, 2010 10:54 am

Return to XML-RPC API

Who is online

Users browsing this forum: No registered users and 1 guest