From Fedora Project Wiki

< QA

I've cleaned up the stuff below somewhat and posted as a patch to:

  - see patch attached to https://bugzilla.mozilla.org/show_bug.cgi?id=423637

Usage:

from pprint import pprint

from testopia import Testopia

t = Testopia('me@example.com', 'my_password', 'https://publictest2.fedoraproject.org/bugzilla/tr_xmlrpc.cgi')

# OK, should be able to use the interface to xmlrpc:
pprint (t.testcase_list())

Older version

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

# testopia tarball's "contrib" subdir has a testopia.py module that wraps
# the XML-RPC interface, supplying handy marshalling that hides some of
# the Perl/Python mismatches
# I have this installed in site-packages for now, to avoid having
# to set import path etc:
from testopia import Testopia

# Unfortunately, the above seems to expect x509 certs for auth
# So we'll hack around it, by passing dummy values, then overriding to use
# a cookie-based implementation

import xmlrpclib
from cookielib import MozillaCookieJar
# wwoods' interface to rh bugzilla has a different xmlrpc mechanism, but we'll
# use the cookie-handling from it:
from bugzilla import SafeCookieTransport

cookieServerProxy = xmlrpclib.ServerProxy('https://publictest2.fedoraproject.org/bugzilla/tr_xmlrpc.cgi',
                                          transport=SafeCookieTransport(),
                                          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('epiphany-cookies.txt')
cookieServerProxy._ServerProxy__transport.cookiejar.load() # needed for some reason

# Hack around assumptions in Testopia class, by passing dummy values, then overriding to use
# a cookie-based implementation
t = Testopia('foo', 'bar')
t.server = cookieServerProxy

# OK, should be able to use the interface to xmlrpc:
pprint (t.testcase_list())

for case in t.testcase_list():
    print case['summary']

# etc