QA/Testopia/XmlRpcReporting


 * 1) !/usr/bin/python

import random import os import time

from pprint import pprint
 * 1) We'll be working with nested dictionaries etc, so we'll want pretty-printing
 * 2) support to keep us sane:

from testopia import Testopia

import xmlrpclib from cookielib import MozillaCookieJar from bugzilla import *

url = "https://publictest2.fedoraproject.org/bugzilla/xmlrpc.cgi" cookies = "cookies.txt"

cookieServerProxy = xmlrpclib.ServerProxy('https://publictest2.fedoraproject.org/bugzilla/tr_xmlrpc.cgi',                                         transport=SafeCookieTransport,                                          verbose = False) # or True cookieServerProxy._ServerProxy__transport.cookiejar = MozillaCookieJar('cookies.txt') cookieServerProxy._ServerProxy__transport.cookiejar.load # needed for some reason
 * 1) Point it at your browser cookies.
 * 2) It can corrupt the file, so point it at a copy:

t = Testopia('foo', 'bar') t.server = cookieServerProxy
 * 1) a cookie-based implementation

build      = '2.6.25.6-58.fc9.i686' product    = 'Rawhide' test_plan  = 'Kernel Tier1' environment = 'x86_64'

print "Lookup userid.." my_id = 6 print "Lookup testplan id.." testplan_id = t.testplan_list(name=test_plan)[0]['plan_id'] print "Lookup product id.." product_id = t.product_check_by_name(product)['id'] print "Lookup build id.." try: build_id = t.build_check_by_name(build,product_id)['build_id'] except: build_id = t.build_create(build,product_id)['build_id'] print "Lookup environment id.." try: environment_id = t.environment_check_by_name(environment,product_id)['environment_id'] except: environment_id = t.environment_create(product_id, True, environment)['environment_id']
 * OK, should be able to use the interface to xmlrpc:

print "Product[%s] ID:%s, TestPlan[%s] ID:%s, Build[%s] ID:%s Environment[%s] ID:%s" % (product,product_id,test_plan,testplan_id,build,build_id, environment, environment_id)

testrun = t.testrun_create(build_id, environment_id, testplan_id, 'Summary',my_id) t.testrun_update(testrun['run_id'],1,build_id,environment_id,my_id) for testcase in t.testplan_get_test_cases(testplan_id): print "Create test case %s" % testcase['summary'] testcaserun = t.testcaserun_create(my_id, build_id, testcase['case_id'],                                     environment_id, testrun['run_id']) print "running..." t.testcaserun_update(testrun['run_id'], testcase['case_id'], build_id,                       environment_id, case_run_status_id=4) time.sleep(10) status = random.randrange(2,4) print "Filing status %s" % status t.testcaserun_update(testrun['run_id'], testcase['case_id'], build_id,                       environment_id, case_run_status_id=status) t.testrun_update(testrun['run_id'],0,build_id,environment_id,my_id)
 * 1) Create the Test run..
 * 1) Update the Test run to "Running" status
 * 1) Update the Test run to "Stopped" status