diff options
author | Will Woods <wwoods@metroid.rdu.redhat.com> | 2007-08-30 18:33:13 -0400 |
---|---|---|
committer | Will Woods <wwoods@metroid.rdu.redhat.com> | 2007-08-30 18:33:13 -0400 |
commit | 425c1f74ee4eece22eacae0b27927c62a9805a06 (patch) | |
tree | 3e77d4c62eb2606046dfc73cd79a76aa4f36cb40 /selftest.py | |
parent | 40b7b7f476c02ffd98d430660292f603c734b282 (diff) | |
download | python-bugzilla-425c1f74ee4eece22eacae0b27927c62a9805a06.tar.gz python-bugzilla-425c1f74ee4eece22eacae0b27927c62a9805a06.tar.xz python-bugzilla-425c1f74ee4eece22eacae0b27927c62a9805a06.zip |
move selftest stuff to an external file
Diffstat (limited to 'selftest.py')
-rwxr-xr-x | selftest.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/selftest.py b/selftest.py new file mode 100755 index 0000000..0ae8ba4 --- /dev/null +++ b/selftest.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# Simple self-test of the bugzilla module + +from bugzilla import Bugzilla +import os, glob + +def find_firefox_cookiefile(): + cookieglob = os.path.expanduser('~/.mozilla/firefox/default.*/cookies.txt') + cookiefiles = glob.glob(cookieglob) + if cookiefiles: + # TODO return whichever is newest + return cookiefiles[0] + +def selftest(): + url = 'https://bugzilla.redhat.com/xmlrpc.cgi' + cookies = find_firefox_cookiefile() + public_bug = 1 + private_bug = 250666 + print "Woo, welcome to the bugzilla.py self-test." + print "Using bugzilla at " + url + print "Reading cookies from " + cookies + b = Bugzilla(url=url,cookies=cookies) + print "Reading product list" + print b.products() + print "Reading public bug (#%i)" % public_bug + print b.getbug(public_bug) + print "Reading private bug (#%i)" % private_bug + try: + print b.getbug(private_bug) + except xmlrpclib.Fault, e: + if 'NotPermitted' in e.faultString: + print "Failed: Not authorized." + else: + print "Failed: Unknown XMLRPC error: %s" % e + +if __name__ == '__main__': + selftest() |