Showing posts with label python with hp OTA. Show all posts
Showing posts with label python with hp OTA. Show all posts

Tuesday, December 20, 2011

Python with HP Quality center

As promised, check the code below will let you connect to QC
the below walks you through the test tree and updates the status of test cases.
you can use this as a function can call it in python script to update.
this was pretty useful to me , hops is the same case with you.

import win32com
from win32com.client import Dispatch

qcServer = "http://xxxxxxxxx/qcbin/"
qcUser = "xxxxx"
qcPassword = "xxxxx"
qcDomain = "xxxx"
qcProject = "xxxx"

t = win32com.client.Dispatch("TDApiOle80.TDConnection.1")
t.InitConnectionEx(qcServer)
t.Login(qcUser,qcPassword)
t.Connect(qcDomain,qcProject)

print "Logged in"

mg=t.TreeManager
npath="Root\xxxxxx"
tsFolder = t.TestSetTreeManager.NodeByPath(npath)
print tsFolder
tfactory=tsFolder.TestSetFactory
td_tsff=tfactory.Filter
td_testset=td_tsff.NewList()

for otest in td_testset:
print otest.Name
td_TSTestSetFactory = otest.TSTestFactory
td_tstsff = td_TSTestSetFactory.NewList("")


for otestitem in td_tstsff:
print otestitem.Name
td_RunFactory = otestitem.RunFactory
obj_theRun = td_RunFactory.AddItem("testrun")
obj_theRun.Status = "Passed"
otestitem.Status= "Passed"
obj_theRun.Post()
print otestitem.Status
next
next

tsFolder = None
tfactory = None
td_testset = None
td_TSTestSetFactory = None
td_RunFactory = None
obj_theRun = None
t.logout
t = None

print "done"