From FedoraProject

< QA
Revision as of 19:50, 20 June 2008 by Bpeck (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

import random
import os
import time

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

from testopia import Testopia

import xmlrpclib
from cookielib import MozillaCookieJar
from bugzilla import *

url = ""
cookies = "cookies.txt"

cookieServerProxy = xmlrpclib.ServerProxy('',
                                          verbose = False) # or True
# Point it at your browser cookies.
# It can corrupt the file, so point it at a copy:
cookieServerProxy._ServerProxy__transport.cookiejar = MozillaCookieJar('cookies.txt')
cookieServerProxy._ServerProxy__transport.cookiejar.load() # needed for some reason

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

build       = ''
product     = 'Rawhide'
test_plan   = 'Kernel Tier1'
environment = 'x86_64'

# OK, should be able to use the interface to xmlrpc:
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.."
   build_id = t.build_check_by_name(build,product_id)['build_id']
   build_id = t.build_create(build,product_id)['build_id']
print "Lookup environment id.."
   environment_id = t.environment_check_by_name(environment,product_id)['environment_id']
   environment_id = t.environment_create(product_id, True, environment)['environment_id']

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)

# Create the Test run..
testrun = t.testrun_create(build_id, environment_id, testplan_id, 'Summary',my_id)
# Update the Test run to "Running" status
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)
   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)
# Update the Test run to "Stopped" status