Skip navigation

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

  1. 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!

  2. have you created an API key for yourself?

  3. 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.


Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.