summaryrefslogtreecommitdiffstats
path: root/layman/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'layman/api.py')
-rwxr-xr-x[-rw-r--r--]layman/api.py62
1 files changed, 61 insertions, 1 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()