Page 1 of 1

Question on Python example for API in 1.8 RC3

Posted: Thu Jan 29, 2009 5:31 pm
by johnzan
Hi,

I have been trying to run the sample_clients with no joy, specifically the python one.

here is the scriptt (the one provided):

----8<-- start script ------------------------------------
#! /usr/bin/python
"""
Testlink API Sample Python Client implementation
"""
import xmlrpclib

class TestlinkAPIClient:
# substitute your server URL Here
SERVER_URL = "http://localhost/testlink_io/lib/api/xmlrpc.php"

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

def reportTCResult(self, tcid, tpid, status):
data = {"devKey":self.devKey, "tcid":tcid, "tpid":tpid, "status":status}
return self.server.tl.reportTCResult(data)

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

# substitute your Dev Key Here
client = TestlinkAPIClient("25c6115ae2559c87be3b57027506e880")
# get info about the server
print client.getInfo()
# Substitute for tcid and tpid that apply to your project
result = client.reportTCResult(1132, 56646, "p")
# Typically you'd want to validate the result here and probably do something more useful with it
print "reportTCResult result was: %s" %(result)
----8<-- end script ------------------------------------


When I run this I get the following


----8<-- start script outout ------------------------------------
[root@cactus python]# python clientSample.py
Testlink API Version: 1.0 Beta 4 initially written by Asiel Brumfield
with contributions by TestLink development Team
reportTCResult result was: [{'message': 'No Test Case ID provided. A valid Test Case ID must be provided!', 'code': 110}]
----8<-- end script outout ------------------------------------

The issue is with the line: result = client.reportTCResult(1132, 56646, "p")

How/Where can I find/get the values referenced in the comment:
# Substitute for tcid and tpid that apply to your project

Thanks for any help,
J.

Posted: Wed Feb 11, 2009 2:54 pm
by AnneGaelle
Hello !

I don't know if you got an answer to your problem. I had the same issue some days ago. In fact, it is not :
def reportTCResult(self, tcid, tpid, status):
data = {"devKey":self.devKey, "tcid":tcid, "tpid":tpid, "status":status}
return self.server.tl.reportTCResult(data)
but

def reportTCResult(self, testcaseid, testplanid, status):
data = {"devKey":self.devKey, "ttestcaseid":testcaseid, "testplanid":testplanid "status":status}
return self.server.tl.reportTCResult(data)

Moreover the testcaseid and testplanid required are those available in your database, look into your "nodes_hierarchy" table, here are the suitable ID (id) for testcaseid and you will find the testplanid in the "testplans" table (id)

Normally it works well !

Posted: Wed Feb 11, 2009 4:25 pm
by fman
we work 99% on PHP, then other samples can be not updated (sorry)