summaryrefslogtreecommitdiffstats
path: root/layman
diff options
context:
space:
mode:
authordol-sen <brian.dolbec@gmail.com>2011-07-28 14:32:02 -0700
committerdol-sen <brian.dolbec@gmail.com>2011-07-28 14:32:02 -0700
commita0592d60f5420e13e3833fed2e3e8885c4b033e1 (patch)
tree0082c268f89450e3fad967600fddd6ae643e8fea /layman
parent10dddbc5d9fb6d33d881f17ffb864c40b04ed31c (diff)
downloadlayman-a0592d60f5420e13e3833fed2e3e8885c4b033e1.tar.gz
layman-a0592d60f5420e13e3833fed2e3e8885c4b033e1.tar.bz2
layman-a0592d60f5420e13e3833fed2e3e8885c4b033e1.zip
add api.py to the tests. create first api test.
Diffstat (limited to 'layman')
-rwxr-xr-x[-rw-r--r--]layman/api.py62
-rwxr-xr-xlayman/tests/dtest.py4
2 files changed, 63 insertions, 3 deletions
diff --git a/layman/api.py b/layman/api.py
index 985eee0..fefb6a0 100644..100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -376,7 +376,57 @@ class LaymanAPI(object):
def fetch_remote_list(self):
- """Fetches the latest remote overlay list"""
+ """Fetches the latest remote overlay list
+
+
+ >>> import os
+ >>> here = os.path.dirname(os.path.realpath(__file__))
+ >>> cache = os.tmpnam()
+ >>> from layman.config import OptionConfig
+ >>> opts = {'overlays' :
+ ... ['file://' + here + '/tests/testfiles/global-overlays.xml'],
+ ... 'cache' : cache,
+ ... 'nocheck' : 'yes',
+ ... 'proxy' : None,
+ ... 'svn_command':'/usr/bin/svn',
+ ... 'rsync_command':'/usr/bin/rsync'}
+ >>> config = OptionConfig(opts)
+ >>> config.set_option('quietness', 3)
+ >>> api = LaymanAPI(config)
+ >>> api.fetch_remote_list()
+ True
+ >>> api.get_errors()
+ []
+ >>> filename = api._get_remote_db().filepath(config['overlays'])+'.xml'
+ >>> b = open(filename)
+ >>> b.readlines()[24]
+ ' A collection of ebuilds from Gunnar Wrobel [wrobel@gentoo.org].\\n'
+
+ >>> b.close()
+
+ >>> api.get_available()
+ [u'wrobel', u'wrobel-stable']
+ >>> all = api.get_all_info(u'wrobel')
+ >>> info = all['wrobel']
+ >>> info['status']
+ u'official'
+ >>> info['description']
+ u'Test'
+ >>> info['sources']
+ [(u'https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
+
+ #{u'wrobel': {'status': u'official',
+ #'owner_name': None, 'description': u'Test',
+ #'src_uris': <generator object source_uris at 0x167c3c0>,
+ #'owner_email': u'nobody@gentoo.org',
+ #'quality': u'experimental', 'name': u'wrobel', 'supported': True,
+ #'src_types': <generator object source_types at 0x167c370>,
+ #'official': True,
+ #'priority': 10, 'feeds': [], 'irc': None, 'homepage': None}}
+
+ >>> os.unlink(filename)
+ """
+
try:
dbreload = self._get_remote_db().cache()
self.output.debug(
@@ -460,3 +510,13 @@ def create_fd():
return (read, write, fd_r, fd_w)
+if __name__ == '__main__':
+ import doctest, sys
+
+ # Ignore warnings here. We are just testing
+ from warnings import filterwarnings, resetwarnings
+ filterwarnings('ignore')
+
+ doctest.testmod(sys.modules[__name__])
+
+ resetwarnings()
diff --git a/layman/tests/dtest.py b/layman/tests/dtest.py
index 4bf3437..fe973d9 100755
--- a/layman/tests/dtest.py
+++ b/layman/tests/dtest.py
@@ -49,7 +49,7 @@ import unittest, doctest
# clean but no testing : CN
# unclean but no testing: UN
-#import layman.api #CT
+import layman.api #CT
import layman.argsparser #CT
import layman.cli #CT
import layman.config #CT
@@ -67,7 +67,7 @@ import layman.overlays.tar #CT
def test_suite():
return unittest.TestSuite((
- #doctest.DocTestSuite(layman.api),
+ doctest.DocTestSuite(layman.api),
doctest.DocTestSuite(layman.config),
doctest.DocTestSuite(layman.argsparser),
doctest.DocTestSuite(layman.db),