Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/, layman/tests/
Date: Thu, 28 Jul 2011 21:33:12
Message-Id: a0592d60f5420e13e3833fed2e3e8885c4b033e1.dol-sen@gentoo
1 commit: a0592d60f5420e13e3833fed2e3e8885c4b033e1
2 Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Thu Jul 28 21:32:02 2011 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Thu Jul 28 21:32:02 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a0592d60
7
8 add api.py to the tests. create first api test.
9
10 ---
11 layman/api.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-
12 layman/tests/dtest.py | 4 +-
13 2 files changed, 63 insertions(+), 3 deletions(-)
14
15 diff --git a/layman/api.py b/layman/api.py
16 old mode 100644
17 new mode 100755
18 index 985eee0..fefb6a0
19 --- a/layman/api.py
20 +++ b/layman/api.py
21 @@ -376,7 +376,57 @@ class LaymanAPI(object):
22
23
24 def fetch_remote_list(self):
25 - """Fetches the latest remote overlay list"""
26 + """Fetches the latest remote overlay list
27 +
28 +
29 + >>> import os
30 + >>> here = os.path.dirname(os.path.realpath(__file__))
31 + >>> cache = os.tmpnam()
32 + >>> from layman.config import OptionConfig
33 + >>> opts = {'overlays' :
34 + ... ['file://' + here + '/tests/testfiles/global-overlays.xml'],
35 + ... 'cache' : cache,
36 + ... 'nocheck' : 'yes',
37 + ... 'proxy' : None,
38 + ... 'svn_command':'/usr/bin/svn',
39 + ... 'rsync_command':'/usr/bin/rsync'}
40 + >>> config = OptionConfig(opts)
41 + >>> config.set_option('quietness', 3)
42 + >>> api = LaymanAPI(config)
43 + >>> api.fetch_remote_list()
44 + True
45 + >>> api.get_errors()
46 + []
47 + >>> filename = api._get_remote_db().filepath(config['overlays'])+'.xml'
48 + >>> b = open(filename)
49 + >>> b.readlines()[24]
50 + ' A collection of ebuilds from Gunnar Wrobel [wrobel@g.o].\\n'
51 +
52 + >>> b.close()
53 +
54 + >>> api.get_available()
55 + [u'wrobel', u'wrobel-stable']
56 + >>> all = api.get_all_info(u'wrobel')
57 + >>> info = all['wrobel']
58 + >>> info['status']
59 + u'official'
60 + >>> info['description']
61 + u'Test'
62 + >>> info['sources']
63 + [(u'https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion', None)]
64 +
65 + #{u'wrobel': {'status': u'official',
66 + #'owner_name': None, 'description': u'Test',
67 + #'src_uris': <generator object source_uris at 0x167c3c0>,
68 + #'owner_email': u'nobody@g.o',
69 + #'quality': u'experimental', 'name': u'wrobel', 'supported': True,
70 + #'src_types': <generator object source_types at 0x167c370>,
71 + #'official': True,
72 + #'priority': 10, 'feeds': [], 'irc': None, 'homepage': None}}
73 +
74 + >>> os.unlink(filename)
75 + """
76 +
77 try:
78 dbreload = self._get_remote_db().cache()
79 self.output.debug(
80 @@ -460,3 +510,13 @@ def create_fd():
81 return (read, write, fd_r, fd_w)
82
83
84 +if __name__ == '__main__':
85 + import doctest, sys
86 +
87 + # Ignore warnings here. We are just testing
88 + from warnings import filterwarnings, resetwarnings
89 + filterwarnings('ignore')
90 +
91 + doctest.testmod(sys.modules[__name__])
92 +
93 + resetwarnings()
94
95 diff --git a/layman/tests/dtest.py b/layman/tests/dtest.py
96 index 4bf3437..fe973d9 100755
97 --- a/layman/tests/dtest.py
98 +++ b/layman/tests/dtest.py
99 @@ -49,7 +49,7 @@ import unittest, doctest
100 # clean but no testing : CN
101 # unclean but no testing: UN
102
103 -#import layman.api #CT
104 +import layman.api #CT
105 import layman.argsparser #CT
106 import layman.cli #CT
107 import layman.config #CT
108 @@ -67,7 +67,7 @@ import layman.overlays.tar #CT
109
110 def test_suite():
111 return unittest.TestSuite((
112 - #doctest.DocTestSuite(layman.api),
113 + doctest.DocTestSuite(layman.api),
114 doctest.DocTestSuite(layman.config),
115 doctest.DocTestSuite(layman.argsparser),
116 doctest.DocTestSuite(layman.db),