From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QkVxq-0004aY-50 for garchives@archives.gentoo.org; Sat, 23 Jul 2011 06:45:30 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EEFC621C0F2; Sat, 23 Jul 2011 06:45:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id A23FE21C0F2 for ; Sat, 23 Jul 2011 06:45:07 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A21F71B4025 for ; Sat, 23 Jul 2011 06:45:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id B7A838004C for ; Sat, 23 Jul 2011 06:45:05 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <7fa3a45f35d8571e384f8648aed49384de0d8a4d.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/, layman/tests/ X-VCS-Repository: proj/layman X-VCS-Files: layman/db.py layman/dbbase.py layman/overlays/overlay.py layman/tests/dtest.py layman/tests/external.py X-VCS-Directories: layman/overlays/ layman/ layman/tests/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 7fa3a45f35d8571e384f8648aed49384de0d8a4d Date: Sat, 23 Jul 2011 06:45:05 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: e6d42d0ce2a0be5f9a10ebe01416f167 commit: 7fa3a45f35d8571e384f8648aed49384de0d8a4d Author: dol-sen gmail com> AuthorDate: Sat Jul 23 06:43:29 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Sat Jul 23 06:43:29 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3D7fa3a45f update all tests to pass --- layman/db.py | 60 +++++++++++++++++++++++++-------------= ------ layman/dbbase.py | 32 ++++++++++++++--------- layman/overlays/overlay.py | 18 +++++++++---- layman/tests/dtest.py | 1 + layman/tests/external.py | 18 ++++++++----- 5 files changed, 78 insertions(+), 51 deletions(-) diff --git a/layman/db.py b/layman/db.py index 747eb4b..bb6fd81 100644 --- a/layman/db.py +++ b/layman/db.py @@ -78,24 +78,27 @@ class DB(DbBase): >>> write2 =3D os.tmpnam() >>> write3 =3D os.tmpnam() >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> config =3D {'local_list' : + >>> from layman.config import OptionConfig + >>> myoptions =3D {'local_list' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : write2, - ... 'nocheck' : True, - ... 'storage' : write3, - ... 'quietness':3} + ... 'nocheck' : 'yes', + ... 'storage' : write3} =20 - >>> here =3D os.path.dirname(os.path.realpath(__file__)) + >>> config =3D OptionConfig(myoptions) + >>> config.set_option('quietness', 3) >>> a =3D DB(config) - >>> config['local_list'] =3D write + >>> config.set_option('local_list', write) >>> b =3D DB(config) - >>> OUT.color_off() + >>> config['output'].set_colorize(False) =20 >>> m =3D MakeConf(config, b.overlays) >>> m.path =3D write2 - >>> m.write() + >>> success =3D m.write() + >>> success + True =20 - Commented out since it needs network access: + # Commented out since it needs network access: =20 # >>> b.add(a.select('wrobel-stable')) #doctest: +ELLIPSIS # * Running command "/usr/bin/rsync -rlptDvz --progress --delete= --delete-after --timeout=3D180 --exclude=3D"distfiles/*" --exclude=3D"lo= cal/*" --exclude=3D"packages/*" "rsync://gunnarwrobel.de/wrobel-stable/*"= "/tmp/file.../wrobel-stable""... @@ -107,11 +110,10 @@ class DB(DbBase): # >>> [i.name for i in m.overlays] #doctest: +ELLIPSIS # [u'wrobel-stable'] =20 - # >>> os.unlink(write) >>> os.unlink(write2) - >>> import shutil =20 + #>>> import shutil # >>> shutil.rmtree(write3) ''' =20 @@ -155,25 +157,28 @@ class DB(DbBase): >>> write2 =3D os.tmpnam() >>> write3 =3D os.tmpnam() >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> config =3D {'local_list' : + >>> from layman.config import OptionConfig + >>> myoptions =3D {'local_list' : ... here + '/tests/testfiles/global-overlays.xml', ... 'make_conf' : write2, - ... 'nocheck' : True, - ... 'storage' : write3, - ... 'quietness':3} + ... 'nocheck' : 'yes', + ... 'storage' : write3} =20 - >>> here =3D os.path.dirname(os.path.realpath(__file__)) + >>> config =3D OptionConfig(myoptions) + >>> config.set_option('quietness', 3) >>> a =3D DB(config) - >>> config['local_list'] =3D write + >>> config.set_option('local_list', write) >>> b =3D DB(config) - >>> .color_off() + >>> config['output'].set_colorize(False) =20 >>> m =3D MakeConf(config, b.overlays) >>> m.path =3D here + '/tests/testfiles/make.conf' >>> m.read() + True =20 >>> m.path =3D write2 >>> m.write() + True =20 # >>> b.add(a.select('wrobel-stable')) #doctest: +ELLIPSIS # * Running command "/usr/bin/rsync -rlptDvz --progress --delete= --delete-after --timeout=3D180 --exclude=3D"distfiles/*" --exclude=3D"lo= cal/*" --exclude=3D"packages/*" "rsync://gunnarwrobel.de/wrobel-stable/*"= "/tmp/file.../wrobel-stable""... @@ -194,8 +199,8 @@ class DB(DbBase): =20 # >>> os.unlink(write) >>> os.unlink(write2) - >>> import shutil =20 + #>>> import shutil # >>> shutil.rmtree(write3) ''' =20 @@ -270,20 +275,23 @@ class RemoteDB(DbBase): =20 >>> here =3D os.path.dirname(os.path.realpath(__file__)) >>> cache =3D os.tmpnam() - >>> config =3D {'overlays' : - ... 'file://' + here + '/tests/testfiles/global-overla= ys.xml', + >>> myoptions =3D {'overlays' : + ... ['file://' + here + '/tests/testfiles/global-overl= ays.xml'], ... 'cache' : cache, - ... 'nocheck' : True, - ... 'proxy' : None, - ... 'quietness':3} + ... 'nocheck' : 'yes', + ... 'proxy' : None} + >>> from layman.config import OptionConfig + >>> config =3D OptionConfig(myoptions) + >>> config.set_option('quietness', 3) >>> a =3D RemoteDB(config) >>> a.cache() - >>> b =3D open(a.path(config['overlays'])) + True + >>> b =3D open(a.filepath(config['overlays'])+'.xml') >>> b.readlines()[24] ' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo= .org].\\n' =20 >>> b.close() - >>> os.unlink(a.path(config['overlays'])) + >>> os.unlink(a.filepath(config['overlays'])+'.xml') =20 >>> a.overlays.keys() [u'wrobel', u'wrobel-stable'] diff --git a/layman/dbbase.py b/layman/dbbase.py index 48199a6..b6b0e6d 100644 --- a/layman/dbbase.py +++ b/layman/dbbase.py @@ -136,8 +136,10 @@ class DbBase: Read an xml list of overlays (adding to and potentially overwrit= ing existing entries) =20 >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> config =3D {'svn_command': '/usr/bin/svn', 'rsync_command':'= /usr/bin/rsync'} - >>> a =3D DbBase([here + '/tests/testfiles/global-overlays.xml',= ], config) + >>> from layman.output import Message + >>> output =3D Message() + >>> config =3D {'output': output, 'svn_command': '/usr/bin/svn',= 'rsync_command':'/usr/bin/rsync'} + >>> a =3D DbBase(config, [here + '/tests/testfiles/global-overla= ys.xml', ]) >>> a.overlays.keys() [u'wrobel', u'wrobel-stable'] =20 @@ -193,12 +195,14 @@ class DbBase: =20 >>> write =3D os.tmpnam() >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> config =3D {'svn_command': '/usr/bin/svn', 'rsync_command':'= /usr/bin/rsync'} - >>> a =3D DbBase([here + '/tests/testfiles/global-overlays.xml',= ], config) - >>> b =3D DbBase([write,], dict()) + >>> from layman.config import BareConfig + >>> config =3D BareConfig() + >>> a =3D DbBase(config, [here + '/tests/testfiles/global-overla= ys.xml', ]) + >>> from layman.output import Message + >>> b =3D DbBase({"output": Message() }, [write,]) >>> b.overlays['wrobel-stable'] =3D a.overlays['wrobel-stable'] >>> b.write(write) - >>> c =3D DbBase([write,], dict()) + >>> c =3D DbBase({"output": Message() }, [write,]) >>> c.overlays.keys() [u'wrobel-stable'] =20 @@ -225,8 +229,10 @@ class DbBase: Select an overlay from the list. =20 >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> config =3D {'svn_command': '/usr/bin/svn', 'rsync_command':'= /usr/bin/rsync'} - >>> a =3D DbBase([here + '/tests/testfiles/global-overlays.xml',= ], config) + >>> from layman.output import Message + >>> output =3D Message() + >>> config =3D {'output': output, 'svn_command': '/usr/bin/svn',= 'rsync_command':'/usr/bin/rsync'} + >>> a =3D DbBase(config, [here + '/tests/testfiles/global-overla= ys.xml', ]) >>> list(a.select('wrobel-stable').source_uris()) [u'rsync://gunnarwrobel.de/wrobel-stable'] ''' @@ -239,9 +245,11 @@ class DbBase: List all overlays. =20 >>> here =3D os.path.dirname(os.path.realpath(__file__)) - >>> config =3D {'svn_command': '/usr/bin/svn', 'rsync_command':'= /usr/bin/rsync'} - >>> a =3D DbBase([here + '/tests/testfiles/global-overlays.xml',= ], config) - >>> for i in a.list(True): + >>> from layman.output import Message + >>> output =3D Message() + >>> config =3D {'output': output, 'svn_command': '/usr/bin/svn',= 'rsync_command':'/usr/bin/rsync'} + >>> a =3D DbBase(config, [here + '/tests/testfiles/global-overla= ys.xml', ]) + >>> for i in a.list(verbose=3DTrue): ... print(i[0]) wrobel ~~~~~~ @@ -264,7 +272,7 @@ class DbBase: A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org]= . =20 - >>> for i in a.list(False, 80): + >>> for i in a.list(verbose=3DFalse, width=3D80): ... print(i[0]) wrobel [Subversion] (https://o.g.o/svn/dev/wr= obel ) wrobel-stable [Rsync ] (rsync://gunnarwrobel.de/= wrobel-stable) diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py index d57fe22..60d57d4 100644 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -80,7 +80,9 @@ class Overlay(object): >>> import xml.etree.ElementTree as ET # Python 2.5 >>> document =3DET.parse(here + '/../tests/testfiles/global-over= lays.xml') >>> overlays =3D document.findall('overlay') + document.findall(= 'repo') - >>> a =3D Overlay(overlays[0], dict()) + >>> from layman.output import Message + >>> output =3D Message() + >>> a =3D Overlay({'output': output}, overlays[0]) >>> a.name u'wrobel' >>> a.is_official() @@ -93,7 +95,7 @@ class Overlay(object): u'Test' >>> a.priority 10 - >>> b =3D Overlay(overlays[1], dict()) + >>> b =3D Overlay({'output': output}, overlays[1]) >>> b.is_official() False ''' @@ -433,8 +435,10 @@ class Overlay(object): >>> import xml.etree.ElementTree as ET # Python 2.5 >>> document =3DET.parse(here + '/../tests/testfiles/global-over= lays.xml') >>> overlays =3D document.findall('overlay') + document.findall(= 'repo') - >>> a =3D Overlay(overlays[0], dict()) - >>> print str(a) + >>> from layman.output import Message + >>> output =3D Message() + >>> a =3D Overlay({'output': output}, overlays[0]) + >>> print a.get_infostr() wrobel ~~~~~~ Source : https://overlays.gentoo.org/svn/dev/wrobel @@ -506,9 +510,11 @@ class Overlay(object): >>> import xml.etree.ElementTree as ET # Python 2.5 >>> document =3DET.parse(here + '/../tests/testfiles/global-over= lays.xml') >>> overlays =3D document.findall('repo') + document.findall('ov= erlay') - >>> a =3D Overlay(overlays[0], dict()) + >>> from layman.output import Message + >>> output =3D Message() + >>> a =3D Overlay({'output': output}, overlays[0]) >>> print a.short_list(80) - wrobel [Subversion] (https://o.g.o/svn/dev/wrobel = ) + wrobel [Subversion] (https://o.g.o/svn/dev/wr= obel ) ''' name =3D pad(self.name, 25) =20 diff --git a/layman/tests/dtest.py b/layman/tests/dtest.py index 15e0900..4bf3437 100755 --- a/layman/tests/dtest.py +++ b/layman/tests/dtest.py @@ -69,6 +69,7 @@ def test_suite(): return unittest.TestSuite(( #doctest.DocTestSuite(layman.api), doctest.DocTestSuite(layman.config), + doctest.DocTestSuite(layman.argsparser), doctest.DocTestSuite(layman.db), doctest.DocTestSuite(layman.dbbase), doctest.DocTestSuite(layman.utils), diff --git a/layman/tests/external.py b/layman/tests/external.py index 3c23373..e5e8c4e 100755 --- a/layman/tests/external.py +++ b/layman/tests/external.py @@ -21,6 +21,8 @@ import tempfile import shutil import urllib from layman.dbbase import DbBase +from layman.output import Message +from layman.config import BareConfig from warnings import filterwarnings, resetwarnings =20 HERE =3D os.path.dirname(os.path.realpath(__file__)) @@ -28,9 +30,9 @@ HERE =3D os.path.dirname(os.path.realpath(__file__)) =20 class Unicode(unittest.TestCase): def _overlays_bug(self, number): - config =3D {} + config =3D BareConfig() filename =3D os.path.join(HERE, 'testfiles', 'overlays_bug_%d.xm= l' % number) - o =3D DbBase([filename], config) + o =3D DbBase(config, [filename]) for verbose in (True, False): for t in o.list(verbose=3Dverbose): print t[0] @@ -45,15 +47,16 @@ class Unicode(unittest.TestCase): =20 class FormatSubpathCategory(unittest.TestCase): def _run(self, number): - config =3D {} + #config =3D {'output': Message()} + config =3D BareConfig() filename1 =3D os.path.join(HERE, 'testfiles', 'subpath-%d.xml' % number) =20 # Read, write, re-read, compare - os1 =3D DbBase([filename1], config) + os1 =3D DbBase(config, [filename1]) filename2 =3D os.tmpnam() os1.write(filename2) - os2 =3D DbBase([filename2], config) + os2 =3D DbBase(config, [filename2]) os.unlink(filename2) self.assertTrue(os1 =3D=3D os2) =20 @@ -103,8 +106,9 @@ class TarAddRemoveSync(unittest.TestCase): temp_dir_path =3D tempfile.mkdtemp() =20 # Make DB from it - config =3D {'tar_command':'/bin/tar'} - db =3D DbBase([temp_collection_path], config) + #config =3D {'output': Message(), 'tar_command':'/bin/tar'} + config =3D BareConfig() + db =3D DbBase(config, [temp_collection_path]) =20 specific_overlay_path =3D os.path.join(temp_dir_path, repo_name) o =3D db.select('tar-test-overlay')