summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordol-sen <brian.dolbec@gmail.com>2011-07-22 23:43:29 -0700
committerdol-sen <brian.dolbec@gmail.com>2011-07-22 23:43:29 -0700
commit7fa3a45f35d8571e384f8648aed49384de0d8a4d (patch)
tree8bf77cdba537fb13d0a7a807169de5eaf7818f30
parent76631892e26c1f08d3a00232e58f454acda09fef (diff)
downloadlayman-7fa3a45f35d8571e384f8648aed49384de0d8a4d.tar.gz
layman-7fa3a45f35d8571e384f8648aed49384de0d8a4d.tar.bz2
layman-7fa3a45f35d8571e384f8648aed49384de0d8a4d.zip
update all tests to pass
-rw-r--r--layman/db.py60
-rw-r--r--layman/dbbase.py32
-rw-r--r--layman/overlays/overlay.py18
-rwxr-xr-xlayman/tests/dtest.py1
-rwxr-xr-xlayman/tests/external.py18
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 = os.tmpnam()
>>> write3 = os.tmpnam()
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> config = {'local_list' :
+ >>> from layman.config import OptionConfig
+ >>> myoptions = {'local_list' :
... here + '/tests/testfiles/global-overlays.xml',
... 'make_conf' : write2,
- ... 'nocheck' : True,
- ... 'storage' : write3,
- ... 'quietness':3}
+ ... 'nocheck' : 'yes',
+ ... 'storage' : write3}
- >>> here = os.path.dirname(os.path.realpath(__file__))
+ >>> config = OptionConfig(myoptions)
+ >>> config.set_option('quietness', 3)
>>> a = DB(config)
- >>> config['local_list'] = write
+ >>> config.set_option('local_list', write)
>>> b = DB(config)
- >>> OUT.color_off()
+ >>> config['output'].set_colorize(False)
>>> m = MakeConf(config, b.overlays)
>>> m.path = write2
- >>> m.write()
+ >>> success = m.write()
+ >>> success
+ True
- Commented out since it needs network access:
+ # Commented out since it needs network access:
# >>> b.add(a.select('wrobel-stable')) #doctest: +ELLIPSIS
# * Running command "/usr/bin/rsync -rlptDvz --progress --delete --delete-after --timeout=180 --exclude="distfiles/*" --exclude="local/*" --exclude="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']
-
# >>> os.unlink(write)
>>> os.unlink(write2)
- >>> import shutil
+ #>>> import shutil
# >>> shutil.rmtree(write3)
'''
@@ -155,25 +157,28 @@ class DB(DbBase):
>>> write2 = os.tmpnam()
>>> write3 = os.tmpnam()
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> config = {'local_list' :
+ >>> from layman.config import OptionConfig
+ >>> myoptions = {'local_list' :
... here + '/tests/testfiles/global-overlays.xml',
... 'make_conf' : write2,
- ... 'nocheck' : True,
- ... 'storage' : write3,
- ... 'quietness':3}
+ ... 'nocheck' : 'yes',
+ ... 'storage' : write3}
- >>> here = os.path.dirname(os.path.realpath(__file__))
+ >>> config = OptionConfig(myoptions)
+ >>> config.set_option('quietness', 3)
>>> a = DB(config)
- >>> config['local_list'] = write
+ >>> config.set_option('local_list', write)
>>> b = DB(config)
- >>> .color_off()
+ >>> config['output'].set_colorize(False)
>>> m = MakeConf(config, b.overlays)
>>> m.path = here + '/tests/testfiles/make.conf'
>>> m.read()
+ True
>>> m.path = write2
>>> m.write()
+ True
# >>> b.add(a.select('wrobel-stable')) #doctest: +ELLIPSIS
# * Running command "/usr/bin/rsync -rlptDvz --progress --delete --delete-after --timeout=180 --exclude="distfiles/*" --exclude="local/*" --exclude="packages/*" "rsync://gunnarwrobel.de/wrobel-stable/*" "/tmp/file.../wrobel-stable""...
@@ -194,8 +199,8 @@ class DB(DbBase):
# >>> os.unlink(write)
>>> os.unlink(write2)
- >>> import shutil
+ #>>> import shutil
# >>> shutil.rmtree(write3)
'''
@@ -270,20 +275,23 @@ class RemoteDB(DbBase):
>>> here = os.path.dirname(os.path.realpath(__file__))
>>> cache = os.tmpnam()
- >>> config = {'overlays' :
- ... 'file://' + here + '/tests/testfiles/global-overlays.xml',
+ >>> myoptions = {'overlays' :
+ ... ['file://' + here + '/tests/testfiles/global-overlays.xml'],
... 'cache' : cache,
- ... 'nocheck' : True,
- ... 'proxy' : None,
- ... 'quietness':3}
+ ... 'nocheck' : 'yes',
+ ... 'proxy' : None}
+ >>> from layman.config import OptionConfig
+ >>> config = OptionConfig(myoptions)
+ >>> config.set_option('quietness', 3)
>>> a = RemoteDB(config)
>>> a.cache()
- >>> b = open(a.path(config['overlays']))
+ True
+ >>> b = open(a.filepath(config['overlays'])+'.xml')
>>> b.readlines()[24]
' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org].\\n'
>>> b.close()
- >>> os.unlink(a.path(config['overlays']))
+ >>> os.unlink(a.filepath(config['overlays'])+'.xml')
>>> 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 overwriting existing entries)
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
- >>> a = DbBase([here + '/tests/testfiles/global-overlays.xml', ], config)
+ >>> from layman.output import Message
+ >>> output = Message()
+ >>> config = {'output': output, 'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
+ >>> a = DbBase(config, [here + '/tests/testfiles/global-overlays.xml', ])
>>> a.overlays.keys()
[u'wrobel', u'wrobel-stable']
@@ -193,12 +195,14 @@ class DbBase:
>>> write = os.tmpnam()
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
- >>> a = DbBase([here + '/tests/testfiles/global-overlays.xml', ], config)
- >>> b = DbBase([write,], dict())
+ >>> from layman.config import BareConfig
+ >>> config = BareConfig()
+ >>> a = DbBase(config, [here + '/tests/testfiles/global-overlays.xml', ])
+ >>> from layman.output import Message
+ >>> b = DbBase({"output": Message() }, [write,])
>>> b.overlays['wrobel-stable'] = a.overlays['wrobel-stable']
>>> b.write(write)
- >>> c = DbBase([write,], dict())
+ >>> c = DbBase({"output": Message() }, [write,])
>>> c.overlays.keys()
[u'wrobel-stable']
@@ -225,8 +229,10 @@ class DbBase:
Select an overlay from the list.
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
- >>> a = DbBase([here + '/tests/testfiles/global-overlays.xml', ], config)
+ >>> from layman.output import Message
+ >>> output = Message()
+ >>> config = {'output': output, 'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
+ >>> a = DbBase(config, [here + '/tests/testfiles/global-overlays.xml', ])
>>> list(a.select('wrobel-stable').source_uris())
[u'rsync://gunnarwrobel.de/wrobel-stable']
'''
@@ -239,9 +245,11 @@ class DbBase:
List all overlays.
>>> here = os.path.dirname(os.path.realpath(__file__))
- >>> config = {'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
- >>> a = DbBase([here + '/tests/testfiles/global-overlays.xml', ], config)
- >>> for i in a.list(True):
+ >>> from layman.output import Message
+ >>> output = Message()
+ >>> config = {'output': output, 'svn_command': '/usr/bin/svn', 'rsync_command':'/usr/bin/rsync'}
+ >>> a = DbBase(config, [here + '/tests/testfiles/global-overlays.xml', ])
+ >>> for i in a.list(verbose=True):
... print(i[0])
wrobel
~~~~~~
@@ -264,7 +272,7 @@ class DbBase:
A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org].
<BLANKLINE>
- >>> for i in a.list(False, 80):
+ >>> for i in a.list(verbose=False, width=80):
... print(i[0])
wrobel [Subversion] (https://o.g.o/svn/dev/wrobel )
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 =ET.parse(here + '/../tests/testfiles/global-overlays.xml')
>>> overlays = document.findall('overlay') + document.findall('repo')
- >>> a = Overlay(overlays[0], dict())
+ >>> from layman.output import Message
+ >>> output = Message()
+ >>> a = 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 = Overlay(overlays[1], dict())
+ >>> b = 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 =ET.parse(here + '/../tests/testfiles/global-overlays.xml')
>>> overlays = document.findall('overlay') + document.findall('repo')
- >>> a = Overlay(overlays[0], dict())
- >>> print str(a)
+ >>> from layman.output import Message
+ >>> output = Message()
+ >>> a = 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 =ET.parse(here + '/../tests/testfiles/global-overlays.xml')
>>> overlays = document.findall('repo') + document.findall('overlay')
- >>> a = Overlay(overlays[0], dict())
+ >>> from layman.output import Message
+ >>> output = Message()
+ >>> a = 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/wrobel )
'''
name = pad(self.name, 25)
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
HERE = os.path.dirname(os.path.realpath(__file__))
@@ -28,9 +30,9 @@ HERE = os.path.dirname(os.path.realpath(__file__))
class Unicode(unittest.TestCase):
def _overlays_bug(self, number):
- config = {}
+ config = BareConfig()
filename = os.path.join(HERE, 'testfiles', 'overlays_bug_%d.xml' % number)
- o = DbBase([filename], config)
+ o = DbBase(config, [filename])
for verbose in (True, False):
for t in o.list(verbose=verbose):
print t[0]
@@ -45,15 +47,16 @@ class Unicode(unittest.TestCase):
class FormatSubpathCategory(unittest.TestCase):
def _run(self, number):
- config = {}
+ #config = {'output': Message()}
+ config = BareConfig()
filename1 = os.path.join(HERE, 'testfiles',
'subpath-%d.xml' % number)
# Read, write, re-read, compare
- os1 = DbBase([filename1], config)
+ os1 = DbBase(config, [filename1])
filename2 = os.tmpnam()
os1.write(filename2)
- os2 = DbBase([filename2], config)
+ os2 = DbBase(config, [filename2])
os.unlink(filename2)
self.assertTrue(os1 == os2)
@@ -103,8 +106,9 @@ class TarAddRemoveSync(unittest.TestCase):
temp_dir_path = tempfile.mkdtemp()
# Make DB from it
- config = {'tar_command':'/bin/tar'}
- db = DbBase([temp_collection_path], config)
+ #config = {'output': Message(), 'tar_command':'/bin/tar'}
+ config = BareConfig()
+ db = DbBase(config, [temp_collection_path])
specific_overlay_path = os.path.join(temp_dir_path, repo_name)
o = db.select('tar-test-overlay')