Gentoo Archives: gentoo-commits

From: Devan Franchini <twitch153@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/tests/, layman/tests/testfiles/, layman/
Date: Fri, 28 Aug 2015 03:43:30
Message-Id: 1440733215.794f56f5ae531a5b24200ad3c0d6cf7112305da8.twitch153@gentoo
1 commit: 794f56f5ae531a5b24200ad3c0d6cf7112305da8
2 Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 28 03:37:32 2015 +0000
4 Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 28 03:40:15 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=794f56f5
7
8 Deprecates get_all_info() function
9
10 The api function get_all_info() is being deprecated as it was much
11 slower than the get_info_str() function and was no longer used in
12 layman's code. The only instance found making use of it was older test
13 code which has been changed to also use the get_info_str() function.
14
15 external.py: Deprecates the get_all_info() function and adds multiple
16 owner testing compatibility.
17 api.py: Removes the get_all_info() function.
18 cli.py: Removes commented out use of get_all_info() function.
19 global-overlays.json: Changes structure of 'owner' attribute to reflect
20 changes for multiple owner support.
21
22 layman/api.py | 69 -----------------------------
23 layman/cli.py | 6 ---
24 layman/tests/external.py | 40 ++++++-----------
25 layman/tests/testfiles/global-overlays.json | 12 +++--
26 4 files changed, 22 insertions(+), 105 deletions(-)
27
28 diff --git a/layman/api.py b/layman/api.py
29 index 0718dce..20fe402 100755
30 --- a/layman/api.py
31 +++ b/layman/api.py
32 @@ -237,75 +237,6 @@ class LaymanAPI(object):
33 return True
34
35
36 - def get_all_info(self, repos, local=False):
37 - """retrieves the recorded information about the repo(s)
38 - specified by repo-id
39 -
40 - @type repos: list of strings or string
41 - @param repos: ['repo-id1', ...] or 'repo-id'
42 - @rtype list of tuples [(str, bool, bool),...]
43 - @return: dictionary of dictionaries
44 - {'ovl1':
45 - {'name': str,
46 - 'owner_name': str,
47 - 'owner_email': str,
48 - ' homepage': str,
49 - 'description': str,
50 - 'src_uris': list of str ['uri1',...]
51 - 'src_type': str,
52 - 'priority': int,
53 - 'quality': str
54 - 'status':,
55 - 'official': bool,
56 - 'supported': bool,
57 - },
58 - 'ovl2': {...}
59 - }
60 - """
61 -
62 - repos = self._check_repo_type(repos, "get_info")
63 - result = {}
64 -
65 - if local:
66 - db = self._get_installed_db()
67 - else:
68 - db = self._get_remote_db()
69 -
70 - for ovl in repos:
71 - if not self.is_repo(ovl):
72 - self.output.error(UnknownOverlayMessage(ovl))
73 - result[ovl] = ('', False, False)
74 - continue
75 - try:
76 - overlay = db.select(ovl)
77 - except UnknownOverlayException as error:
78 - self._error(error)
79 - result[ovl] = ('', False, False)
80 - else:
81 - result[ovl] = {
82 - 'name': overlay.name,
83 - 'owner_name': overlay.owner_name,
84 - 'owner_email': overlay.owner_email,
85 - 'homepage': overlay.homepage,
86 - 'irc': overlay.irc,
87 - 'description': [e for e in overlay.descriptions],
88 - 'feeds': overlay.feeds,
89 - 'sources': [(e.src, e.type, e.branch) \
90 - for e in overlay.sources],
91 - #'src_uris': [e.src for e in overlay.sources],
92 - 'src_uris': overlay.source_uris(),
93 - 'src_types': overlay.source_types(),
94 - #'src_types': [e.type for e in overlay.sources],
95 - 'priority': overlay.priority,
96 - 'quality': overlay.quality,
97 - 'status': overlay.status,
98 - 'official': overlay.is_official(),
99 - 'supported': overlay.is_supported(),
100 - }
101 -
102 - return result
103 -
104 -
105 def get_info_str(self, repos, local=True, verbose=False, width=0):
106 """retrieves the string representation of the recorded information
107 about the repo(s) specified by ovl
108
109 diff --git a/layman/cli.py b/layman/cli.py
110 index bb9ea6f..86d6e70 100644
111 --- a/layman/cli.py
112 +++ b/layman/cli.py
113 @@ -381,17 +381,11 @@ class Main(object):
114 self.output.debug('Printing installed overlays.', 6)
115 list_printer = ListPrinter(self.config)
116
117 - #
118 - # fast way
119 info = self.api.get_info_list(verbose=self.config['verbose'],
120 width=list_printer.width)
121 #self.output.debug('CLI: ListLocal() info = %s' % len(info), 4)
122 #self.output.debug('\n'.join([ str(x) for x in info]), 4)
123 list_printer.print_shortlist(info, complain=True)
124 - #
125 - # slow way
126 - #info = self.api.get_all_info(self.api.get_installed(), local=True)
127 - #list_printer.print_fulldict(info, complain=_complain)
128
129 # blank newline -- no " *"
130 self.output.notice('')
131
132 diff --git a/layman/tests/external.py b/layman/tests/external.py
133 index f61d4b6..f2b18cd 100755
134 --- a/layman/tests/external.py
135 +++ b/layman/tests/external.py
136 @@ -427,6 +427,7 @@ class FetchRemoteList(unittest.TestCase):
137 my_opts = {
138 'overlays': ['file://'\
139 + HERE + '/testfiles/global-overlays.xml'],
140 + 'db_type': 'xml',
141 'cache': cache,
142 'nocheck': 'yes',
143 'proxy': None,
144 @@ -441,7 +442,9 @@ class FetchRemoteList(unittest.TestCase):
145 filename = api._get_remote_db().filepath(config['overlays']) + '.xml'
146
147 with fileopen(filename, 'r') as b:
148 - self.assertEqual(b.readlines()[19], ' A collection of ebuilds from Gunnar Wrobel [wrobel@g.o].\n')
149 + description = b.readlines()[19]
150 + self.assertEqual(description, ' A collection of ebuilds from '\
151 + 'Gunnar Wrobel [wrobel@g.o].\n')
152 for line in b.readlines():
153 print(line, end='')
154
155 @@ -449,29 +452,16 @@ class FetchRemoteList(unittest.TestCase):
156 available = api.get_available()
157 self.assertEqual(available, ['wrobel', 'wrobel-stable'])
158
159 - # Test the info of an overlay.
160 - all_info = api.get_all_info('wrobel')
161 -
162 - test_info = {'status': 'official', 'owner_name': None,
163 - 'description': ['Test'], 'src_uris':
164 - ['https://overlays.gentoo.org/svn/dev/wrobel'],
165 - 'owner_email': 'nobody@g.o', 'sources':
166 - [('https://overlays.gentoo.org/svn/dev/wrobel',
167 - 'Subversion', None)], 'quality': 'experimental', 'name':
168 - 'wrobel', 'supported': True, 'src_types': ['Subversion'],
169 - 'official': True, 'priority': 10, 'feeds': [],
170 - 'irc': None, 'homepage': None}
171 - info = all_info['wrobel']
172 - info['src_uris'] = [e for e in info['src_uris']]
173 - info['src_types'] = [e for e in info['src_types']]
174
175 - self.assertEqual(info, test_info)
176 + # Test the info of an overlay.
177 + info = api.get_info_str(['wrobel'], verbose=True, local=False)
178 + test_info = 'wrobel\n~~~~~~\nSource : https://overlays.gentoo.org'\
179 + '/svn/dev/wrobel\nContact : nobody@g.o\nType '\
180 + ': Subversion; Priority: 10\nQuality : experimental\n\n'\
181 + 'Description:\n Test\n'
182
183 - self.assertEqual(info['status'], 'official')
184 - self.assertEqual(info['description'], ['Test'])
185 - sources = [('https://overlays.gentoo.org/svn/dev/wrobel', 'Subversion',
186 - None)]
187 - self.assertEqual(info['sources'], sources)
188 + info = info['wrobel'][0].decode('utf-8')
189 + self.assertEqual(info, test_info)
190
191 os.unlink(filename)
192 shutil.rmtree(tmpdir)
193 @@ -523,8 +513,7 @@ class MakeOverlayXML(unittest.TestCase):
194 ovl_dict = {
195 'name': 'wrobel',
196 'description': ['Test'],
197 - 'owner_name': 'nobody',
198 - 'owner_email': 'nobody@g.o',
199 + 'owner': [{'name': 'nobody', 'email': 'nobody@g.o'}],
200 'status': 'official',
201 'source': [['https://overlays.gentoo.org/svn/dev/wrobel',
202 'svn', '']],
203 @@ -555,13 +544,12 @@ class OverlayObjTest(unittest.TestCase):
204 document = ET.parse(HERE + '/testfiles/global-overlays.xml')
205 overlays = document.findall('overlay') + document.findall('repo')
206 output = Message()
207 -
208 ovl_a = Overlay({'output': output, 'db_type': 'xml'}, xml=overlays[0])
209 self.assertEqual(ovl_a.name, 'wrobel')
210 self.assertEqual(ovl_a.is_official(), True)
211 url = ['https://overlays.gentoo.org/svn/dev/wrobel']
212 self.assertEqual(list(ovl_a.source_uris()), url)
213 - self.assertEqual(ovl_a.owner_email, 'nobody@g.o')
214 + self.assertEqual(ovl_a.owners[0]['email'], 'nobody@g.o')
215 self.assertEqual(ovl_a.descriptions, ['Test'])
216 self.assertEqual(ovl_a.priority, 10)
217
218
219 diff --git a/layman/tests/testfiles/global-overlays.json b/layman/tests/testfiles/global-overlays.json
220 index 53267cf..6ff4f45 100644
221 --- a/layman/tests/testfiles/global-overlays.json
222 +++ b/layman/tests/testfiles/global-overlays.json
223 @@ -14,10 +14,12 @@
224 ],
225 "homepage": "https://github.com/twitch153/ebuilds",
226 "name": "twitch153",
227 - "owner": {
228 + "owner": [
229 + {
230 "email": "twitch153@g.o",
231 "name": "Devan Franchini"
232 - },
233 + }
234 + ],
235 "source": [
236 {
237 "#text": "git://github.com/twitch153/ebuilds.git",
238 @@ -30,9 +32,11 @@
239 "A collection of ebuilds from Gunnar Wrobel [wrobel@g.o]."
240 ],
241 "name": "wrobel-stable",
242 - "owner": {
243 + "owner": [
244 + {
245 "email": "nobody@g.o"
246 - },
247 + }
248 + ],
249 "source": [
250 {
251 "#text": "rsync://gunnarwrobel.de/wrobel-stable",