lpltk/ 0000775 0000000 0001751 00000000000 12071171760 007114 5 ustar lpltk/NEWS 0000664 0000000 0001751 00000005620 11753031405 007613 0 ustar May 24, 2011 - Version 0.4.5 ============================ The past year has seen a lot of growth for lpltk. Wrapper classes have been quite fully fleshed out, and a good bit of convenience functionality has been added as well. Brad has added a few tutorial scripts to the examples directory. Some unit tests are starting to be written and can be invoked via the run-tests script. It seems launchpadlib has been moving towards use of gnome-keyring over credentials files, so with this version we're re-introducing credential file management into lpltk. -- Bryce July 22, 2010 - Version 0.4 =========================== Brad Figg has been hammering out wrapper classes for Launchpad API objects. These do call caching and provide other convenience functions to simplify use of launchpadlib. LaunchpadLib now mostly handles credentials now via login_anonymously() and login_with(), so we've transitioned launchpadlib-toolkit (or lpltk as we're nicknaming it now) to using those calls rather than manage the credentials at this level. While this package is not intended to be a collection of scripts, we've included a few small tools in the scripts directory that may be useful in other scripts, where you need to e.g. dynamically look up the name of the current version of ubuntu under development. -- Bryce June, 2010 - Version 0.3 ======================== python-launchpadlib-toolkit's scope is gradually increasing. This version adds several useful scripts from Arsenal that require nothing more than the toolkit itself, and that may be of general interest. -- Bryce Oct 09, 2009 - Version 0.2 ========================== This version adds some fault handling and assorted fixes. -- Bryce Sept 29, 2009 - Version 0.1 =========================== This is a first draft of the python-launchpadlib-toolkit package. The principle motivation is the widespread duplication of effort in implementing credential handling across a vast array of launchpadlib applications. At Plumbers' it seems there is strong desire for more collaboration between LPL scripters. Since pretty much every LPL script needs to do credentials management, standardizing this into a sharable library seems like a logical first step. There's so much similarity from one credentials implementation to another that this probably could have started from anyone's code. I opted to start with my own implementation from Arsenal since that's the one I'm most familiar with. I've integrated some good implementation ideas from Markus Korn's work on ilaunchpad-shell and ubuntu-dev-tools, such as the nifty DebugStdOut trickery, the use of environment variables for configuration, and the essense of his HTTPError exception handling. One of my major design goals was to keep it simple, so there's been several ideas I've left out simply on the grounds that I wasn't sure if they'd be that useful in real-world cases. Stuff can always be added later as it's proven necessary! -- Bryce lpltk/Makefile 0000664 0000000 0001751 00000001423 11756537714 010572 0 ustar APPNAME=lpltk APPURL=http://launchpad.net/lpltk # Run all the tests check: ./run-tests clean: rm -rf doc/api find . -name '*.pyc' -print0 | xargs -0 rm -f find . -name '*~' -print0 | xargs -0 rm -f # Check for common & easily catchable Python mistakes. pyflakes: pyflakes $(APPNAME) # Check for coding standard violations. pep8: find . -name '*.py' -print0 | xargs -0 pep8 --ignore E221,E222 find . -name '*.py' -print0 | xargs -0 pep8 --ignore E221,E222 --repeat | wc -l apidocs: mkdir -p doc pydoctor --add-package $(APPNAME) \ --make-html --html-output=doc/api \ --project-name=$(APPNAME) \ --project-url=$(APPURL) lint: pyflakes pep8 .PHONY: check lint pyflakes pep8 apidocs clean # Ignore pyflakes exit code so pep8 will run for 'make lint' .IGNORE: pyflakes lpltk/tests/ 0000775 0000000 0001751 00000000000 12002341133 010241 5 ustar lpltk/tests/test-bug-task.py 0000664 0000000 0001751 00000002041 11773460511 013322 0 ustar #!/usr/bin/python import os import sys, os.path sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) import unittest from lpltk import LaunchpadService class TestBugTask(unittest.TestCase): # setUp # def setUp(self): self.configuration = {} self.configuration['launchpad_services_root'] = 'staging' def test_to_dict(self): ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) bug_task = bug.tasks[0] d = bug_task.to_dict() self.assertEqual(d['target'], "Launchpad itself") self.assertEqual(d['date_created'], "2004-12-21T16:33:36.359671+00:00") self.assertEqual(len(d.keys()), 8) def test_status_age(self): import datetime ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) bug_task = bug.tasks[0] self.assertEqual(datetime.timedelta, type(bug_task.status_age())) if __name__ == '__main__': unittest.main() # vi:set ts=4 sw=4 expandtab: lpltk/tests/test-tags.py 0000664 0000000 0001751 00000010305 11753031405 012537 0 ustar #!/usr/bin/python import os import sys, os.path sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) import unittest from lpltk.LaunchpadService import LaunchpadService from lpltk.utils import o2str class TestTags(unittest.TestCase): # setUp # def setUp(self): self.configuration = {} self.configuration['launchpad_services_root'] = 'staging' # tearDown # def tearDown(self): ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) tags = [] for tag in bug.tags: tags.append(tag) for tag in tags: bug.tags.remove(o2str(tag)) bug.tags.append('feature') # test__init__ # def test__init__(self): # Tags object creation # try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) tags = bug.tags finally: bug = None ls = None # test__contains__ # def test__contains__(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) self.assertTrue('feature' in bug.tags) self.assertTrue('foo' not in bug.tags) finally: bug = None ls = None # test__setitem__ # def test__setitem__(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) bug.tags[0] = 'setitem' self.assertTrue('setitem' == bug.tags[0]) bug.tags[0] = 'feature' self.assertTrue('feature' == bug.tags[0]) finally: bug = None ls = None # test__getitem__ # def test__getitem__(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) self.assertTrue('feature' == bug.tags[0]) finally: bug = None ls = None # test__iter__ # def test__iter__(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) ct = 0 for tag in bug.tags: ct += 1 self.assertTrue('feature' == bug.tags[0]) self.assertTrue(ct == 1) finally: bug = None ls = None # test_len # def test_len(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) self.assertTrue(len(bug.tags) == 1) finally: bug = None ls = None # test_append # def test_append(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) bug.tags.append('append') self.assertTrue(len(bug.tags) == 2) self.assertTrue('append' in bug.tags) self.assertTrue('append' == bug.tags[0]) finally: bug = None ls = None # test_extend # def test_extend(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) tags_ct = len(bug.tags) # We don't know which order the tests will be run bug.tags.extend(['extend', 'extend2']) self.assertTrue(len(bug.tags) == (tags_ct + 2)) self.assertTrue('extend' in bug.tags) self.assertTrue('extend2' in bug.tags) finally: bug = None ls = None # test_remove # def test_remove(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) tags_ct = len(bug.tags) # We don't know which order the tests will be run bug.tags.extend(['remove1', 'remove2']) self.assertTrue(len(bug.tags) == (tags_ct + 2)) self.assertTrue('remove1' in bug.tags) self.assertTrue('remove2' in bug.tags) bug.tags.remove('remove1') bug.tags.remove('remove2') finally: bug = None ls = None if __name__ == '__main__': unittest.main() # vi:set ts=4 sw=4 expandtab: lpltk/tests/test-bug.py 0000664 0000000 0001751 00000006370 11753031405 012365 0 ustar #!/usr/bin/python import os import sys, os.path sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) import unittest from lpltk import LaunchpadService class TestBug(unittest.TestCase): # setUp # def setUp(self): self.configuration = {} self.configuration['launchpad_services_root'] = 'staging' # test__init__ # def test__init__(self): # Basic instance creation. # try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) except: self.assertTrue(False) finally: bug = None ls = None # test_get_title # def test_get_title(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) title = bug.title self.assertEqual(title, 'Custom information for each translation team') finally: bug = None ls = None # test_set_title # def test_set_title(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) original_title = bug.title bug.title = "Testing Bug.title property" self.assertEqual(bug.title, 'Testing Bug.title property') bug.title = original_title self.assertEqual(bug.title, original_title) finally: bug = None ls = None # test_get_description # def test_get_description(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) description = bug.description if "It would be nice if we could easily add *MUST READ* type of links" not in description: self.assertTrue(False) finally: bug = None ls = None # test_set_description # def test_set_description(self): try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) original_description = bug.description bug.description = "Testing Bug.title property" self.assertEqual(bug.description, 'Testing Bug.title property') bug.description = original_description self.assertEqual(bug.description, original_description) finally: bug = None ls = None # test_owner_full_name # def test_owner_full_name(self): ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) self.assertEqual("Jordi Mallach", bug.owner.full_name) # test_owner_first_name # def test_owner_first_name(self): ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) self.assertEqual("Jordi", bug.owner.first_name) def test_to_dict(self): ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) d = bug.to_dict() self.assertEqual(d['id'], 3) self.assertEqual(d['owner_name'], "jordi") self.assertEqual(d['date_created'], "Tue Dec 21 00:00:00 2004") self.assertEqual(len(d.keys()), 26) if __name__ == '__main__': unittest.main() # vi:set ts=4 sw=4 expandtab: lpltk/tests/test-attachments.py 0000664 0000000 0001751 00000012424 12001205315 014106 0 ustar #!/usr/bin/python import sys, os.path sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) import unittest from lpltk.LaunchpadService import LaunchpadService from lpltk.attachments import * from lpltk.person import * class TestTags(unittest.TestCase): # setUp # def setUp(self): self.configuration = {} self.configuration['launchpad_services_root'] = 'edge' self.configuration['read_only'] = True # tearDown # def tearDown(self): pass # test__init__ # def test__init__(self): # Attachments object creation # print try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(107232) attachments = bug.attachments print "Class: %s" %(type(attachments)) print "Atts: %d" %(len(attachments)) for attachment in attachments: print " Type: %s" %(type(attachment)) print " Title: %s" %(attachment.title) print " Kind: %s" %(attachment.kind) print finally: bug = None ls = None def test_attachment_owner(self): print try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(107232) attachments = bug.attachments for attachment in attachments: assert(attachment.owner) print " Owner: %s" %(attachment.owner.lpperson) print " First: %s" %(attachment.owner.first_name) print " Msg: %s chars" %(len(attachment.message.content)) print " Age: %s days" %(attachment.age) print finally: bug = None ls = None def test_attachment_contents(self): print try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(107232) attachments = bug.attachments for attachment in attachments: print " filename: %s" %(attachment.filename) print " content-type: %s" %(attachment.content_type) print " content: %s chars" %(len(attachment.content)) print " patch? %s" %(attachment.is_patch()) print " archive? %s" %(attachment.is_archive()) print finally: bug = None ls = None def test_containment(self): print try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(107232) attachments = bug.attachments # Test containment attachment = attachments[0] if not attachment in attachments: raise AssertionError else: print "Located attachment in collection" finally: bug = None ls = None def test_requirements(self): print try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(107232) attachments = bug.attachments missing = attachments.check_required_files(['*.tar.gz', 'alsa.*', 'faslkjasdfnfds*asdfdsaa']) if len(missing)>1: print "Unexpectedly missing files %s" %(missing) raise AssertionError print "Required files present and accounted for, except: %s" %(missing) finally: bug = None ls = None def test_owner_filtered_attachments(self): print try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(107232) lark = Person(bug, ls.launchpad.people['florent-g']) attachments = bug.attachments # Test len() print " %d attachments before filtering" %(len(attachments)) attachments.add_filter(filter_owned_by_person, [lark]) print " %d attachments after filtering" %(len(attachments)) print # Test iteration for attachment in attachments: print " Type: %s" %(type(attachment)) print " Title: %s" %(attachment.title) print " Owner: %s" %(attachment.owner.full_name) print finally: bug = None ls = None def test_filename_filtered_attachments(self): print try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(570228) attachments = bug.attachments glob_patterns = ["*Xorg*Log*", "*Dmesg.txt"] print " %d attachments before filtering" %(len(attachments)) attachments.add_filter(filter_filename_matches_globs, glob_patterns) print " %d attachments after filtering on filenames" %(len(attachments)) age = 0 for attachment in attachments: age = attachment.age attachments.add_filter(filter_age_between, [age-1, age+1]) print " %d attachments after filtering on age" %(len(attachments)) print finally: bug = None ls = None if __name__ == '__main__': unittest.main() # vi:set ts=4 sw=4 expandtab: lpltk/tests/test-launchpad-service.py 0000664 0000000 0001751 00000007127 11753031405 015206 0 ustar #!/usr/bin/python import os import sys, os.path sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) import unittest from lpltk import LaunchpadService class TestLaunchpadService(unittest.TestCase): # setUp # def setUp(self): pass # test__init__ # def test__init__(self): # Basic instance creation. # try: ls = LaunchpadService() ls = None except: self.assertTrue(False) # Verify default configuration parameters are set correctly. # try: ls = LaunchpadService() self.assertEqual(ls.config['launchpad_client_name'], 'lpltk') self.assertEqual(ls.config['launchpad_services_root'], 'production') self.assertEqual(ls.config['project_name'], '') self.assertEqual(ls.config['read_only'], False) self.assertEqual(ls.config['launchpad_cachedir'], os.path.join(os.path.expanduser('~'), '.cache', ls.config['launchpad_client_name'])) ls = None except: self.assertTrue(False) # Verify that the default configuration parameters will be overridden by # the passed in config dictionary. # try: cfg = {} cfg['launchpad_client_name'] = 'bilbo' cfg['launchpad_services_root'] = 'edge' cfg['project_name'] = 'linux' cfg['read_only'] = True cfg['launchpad_cachedir'] = 'deadEnd' ls = LaunchpadService(cfg) for k in cfg: self.assertEqual(ls.config[k], cfg[k]) ls = None except: self.assertTrue(False) # Verify that we actually connected to Launchpad by getting back the title # or bug #1 # try: ls = LaunchpadService() self.assertEqual(ls.launchpad.bugs[1].title, 'Microsoft has a majority market share') ls = None except: self.assertTrue(False) # Verify that I can connect to Launchpad in "read_only" mode. # try: cfg = {} cfg['read_only'] = True ls = LaunchpadService(cfg) self.assertEqual(ls.launchpad.bugs[1].title, 'Microsoft has a majority market share') ls = None except: self.assertTrue(False) # test_get_launchpad_bug # def test_get_launchpad_bug(self): try: ls = LaunchpadService() b = ls.get_launchpad_bug(1) self.assertEqual(b.title, 'Microsoft has a majority market share') ls = None except: self.assertTrue(False) # test_load_project # def test_load_project(self): # Verify that a specific projct can be loaded # try: ls = LaunchpadService() p = ls.load_project('ubuntu') self.assertEqual(p.display_name, 'Ubuntu') self.assertEqual(p.owner.display_name, 'Ubuntu Drivers') ls = None except: self.assertTrue(False) # test_reset # def test_reset(self): try: ls = LaunchpadService() ls.reset() b = ls.get_launchpad_bug(1) self.assertEqual(b.title, 'Microsoft has a majority market share') ls = None except: self.assertTrue(False) # test_new_bug # def test_new_bug(self): pass if __name__ == '__main__': unittest.main() # vi:set ts=4 sw=4 expandtab: lpltk/tests/test_script_syntax.sh 0000775 0000000 0001751 00000002417 11753031405 014567 0 ustar #!/bin/bash display_result() { if [ $1 == 0 ]; then echo "pass ${2} ${3}" else echo "FAIL ${2} ${3}" fi } ignorable() { for ext in '~' '~c' .pyc .o ; do if [ ${file_name%${ext}} != ${file_name} ]; then return 0 fi done return 1 } # Basic syntax checking for script in scripts/* ; do file_type=$(file -b ${script}) file_name=$(basename $script) # Compiled objects and other cruft if ignorable ${file_name} ; then continue fi # Bash case ${file_type} in *troff*) ;; *byte-compiled*) ;; *bash*) bash -n $script >/dev/null 2>&1 display_result $? 'bash' ${script} ;; *Bourne*) bash -n $script >/dev/null 2>&1 display_result $? 'bash' ${script} ;; *perl*) perl -c $script >/dev/null 2>&1 display_result $? 'perl' ${script} ;; *python*script*) python -m py_compile ${script} display_result $? 'python' ${script} if [ -e ${script}c ]; then rm ${script}c fi ;; *) echo "Unknown script type '${file_type}'" display_result 1 ${script} esac done lpltk/tests/test-template.py 0000664 0000000 0001751 00000001403 11753031405 013413 0 ustar #!/usr/bin/python import sys, os.path sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))) import unittest from lpltk.LaunchpadService import LaunchpadService class TestTags(unittest.TestCase): # setUp # def setUp(self): self.configuration = {} self.configuration['launchpad_services_root'] = 'staging' # tearDown # def tearDown(self): pass # test__init__ # def test__init__(self): # Tags object creation # try: ls = LaunchpadService(self.configuration) bug = ls.get_bug(3) finally: bug = None ls = None if __name__ == '__main__': unittest.main() # vi:set ts=4 sw=4 expandtab: lpltk/doc/ 0000775 0000000 0001751 00000000000 11756537721 007675 5 ustar lpltk/doc/api/ 0000775 0000000 0001751 00000000000 11756537722 010447 5 ustar lpltk/doc/api/lpltk.bug_activity.html 0000664 0000000 0001751 00000002473 11756540206 015150 0 ustar
Part of lpltk
Class | Activity | Undocumented |
Class | BugActivity | Undocumented |