Merge lp:~submarine/unity-scope-gmusicbrowser/gmusicbrowser-previews into lp:unity-scope-gmusicbrowser
- gmusicbrowser-previews
- Merge into trunk
Proposed by
Mark Tully
Status: | Merged |
---|---|
Approved by: | David Callé |
Approved revision: | 21 |
Merged at revision: | 20 |
Proposed branch: | lp:~submarine/unity-scope-gmusicbrowser/gmusicbrowser-previews |
Merge into: | lp:unity-scope-gmusicbrowser |
Diff against target: |
411 lines (+104/-167) 3 files modified
data/gmusicbrowser.scope.in (+3/-1) src/unity_gmusicbrowser_daemon.py (+92/-157) tests/test_gmusicbrowser.py (+9/-9) |
To merge this branch: | bzr merge lp:~submarine/unity-scope-gmusicbrowser/gmusicbrowser-previews |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
David Callé | Approve | ||
Review via email:
|
Commit message
Add Previews and Activation
Description of the change
Add Previews and Activation
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
review:
Needs Fixing
(continuous-integration)
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
FAILURE: http://
review:
Needs Fixing
(continuous-integration)
- 21. By Mark Tully
-
Fixed tests
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:21
http://
Executed test runs:
SUCCESS: http://
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/gmusicbrowser.scope.in' | |||
2 | --- data/gmusicbrowser.scope.in 2013-03-20 16:43:38 +0000 | |||
3 | +++ data/gmusicbrowser.scope.in 2013-04-22 13:23:30 +0000 | |||
4 | @@ -5,7 +5,9 @@ | |||
5 | 5 | QueryBinary=gmusicbrowser | 5 | QueryBinary=gmusicbrowser |
6 | 6 | _Keywords=gmusicbrowser; | 6 | _Keywords=gmusicbrowser; |
7 | 7 | RequiredMetadata= | 7 | RequiredMetadata= |
9 | 8 | OptionalMetadata= | 8 | OptionalMetadata=album[s];artist[s];genre[s];year[i];track_length[i];track_number[i] |
10 | 9 | Loader=/usr/share/unity-scopes/gmusicbrowser/unity_gmusicbrowser_daemon.py | ||
11 | 10 | RemoteContent=false | ||
12 | 9 | Type=music | 11 | Type=music |
13 | 10 | _Name=Gmusicbrowser | 12 | _Name=Gmusicbrowser |
14 | 11 | _Description=Find Gmusicbrowser items | 13 | _Description=Find Gmusicbrowser items |
15 | 12 | 14 | ||
16 | === modified file 'src/unity_gmusicbrowser_daemon.py' | |||
17 | --- src/unity_gmusicbrowser_daemon.py 2013-03-19 15:40:16 +0000 | |||
18 | +++ src/unity_gmusicbrowser_daemon.py 2013-04-22 13:23:30 +0000 | |||
19 | @@ -64,12 +64,13 @@ | |||
20 | 64 | m4 = {'id' :'year', | 64 | m4 = {'id' :'year', |
21 | 65 | 'type' :'i', | 65 | 'type' :'i', |
22 | 66 | 'field':Unity.SchemaFieldType.OPTIONAL} | 66 | 'field':Unity.SchemaFieldType.OPTIONAL} |
29 | 67 | EXTRA_METADATA = [m1, m2, m3, m4] | 67 | m5 = {'id': 'track_length', |
30 | 68 | 68 | 'type': 'i', | |
31 | 69 | REFRESH_TIMEOUT = 300 | 69 | 'field': Unity.SchemaFieldType.OPTIONAL} |
32 | 70 | PREVIEW_PLAYER_DBUS_NAME = "com.canonical.Unity.Lens.Music.PreviewPlayer" | 70 | m6 = {'id': 'track_number', |
33 | 71 | PREVIEW_PLAYER_DBUS_PATH = "/com/canonical/Unity/Lens/Music/PreviewPlayer" | 71 | 'type': 'i', |
34 | 72 | PREVIEW_PLAYER_DBUS_IFACE = PREVIEW_PLAYER_DBUS_NAME | 72 | 'field': Unity.SchemaFieldType.OPTIONAL} |
35 | 73 | EXTRA_METADATA = [m1, m2, m3, m4, m5, m6] | ||
36 | 73 | 74 | ||
37 | 74 | tracks = [] | 75 | tracks = [] |
38 | 75 | albumart = [] | 76 | albumart = [] |
39 | @@ -77,6 +78,8 @@ | |||
40 | 77 | 78 | ||
41 | 78 | def get_music_from_gmusicbrowser(): | 79 | def get_music_from_gmusicbrowser(): |
42 | 79 | """Parses GMusicBrowser's collection into a form we can use""" | 80 | """Parses GMusicBrowser's collection into a form we can use""" |
43 | 81 | global tracks | ||
44 | 82 | global albumart | ||
45 | 80 | tracks = [] | 83 | tracks = [] |
46 | 81 | albumart = [] | 84 | albumart = [] |
47 | 82 | songlist = [] | 85 | songlist = [] |
48 | @@ -95,7 +98,6 @@ | |||
49 | 95 | albumstart = index | 98 | albumstart = index |
50 | 96 | if item == '[artist]\n': | 99 | if item == '[artist]\n': |
51 | 97 | artiststart = index | 100 | artiststart = index |
52 | 98 | print(songstart) | ||
53 | 99 | except: | 101 | except: |
54 | 100 | return tracks | 102 | return tracks |
55 | 101 | 103 | ||
56 | @@ -122,7 +124,7 @@ | |||
57 | 122 | if track[7] == "": | 124 | if track[7] == "": |
58 | 123 | track[7] = "0" | 125 | track[7] = "0" |
59 | 124 | track[8] = 0 if fields[32] is None else fields[32] | 126 | track[8] = 0 if fields[32] is None else fields[32] |
61 | 125 | track[9] = fields[32] | 127 | track[9] = int(fields[32]) |
62 | 126 | track[10] = fields[17] | 128 | track[10] = fields[17] |
63 | 127 | tracks.append(track) | 129 | tracks.append(track) |
64 | 128 | albumartlist = database[albumstart + 2:artiststart - 1] | 130 | albumartlist = database[albumstart + 2:artiststart - 1] |
65 | @@ -135,7 +137,8 @@ | |||
66 | 135 | albumarta[2] = fields[1] | 137 | albumarta[2] = fields[1] |
67 | 136 | albumart.append(albumarta) | 138 | albumart.append(albumarta) |
68 | 137 | print("Updated tracks from GMusicBrowser database") | 139 | print("Updated tracks from GMusicBrowser database") |
70 | 138 | 140 | ||
71 | 141 | tracks.sort(key=lambda track: track[9]) | ||
72 | 139 | return albumart, tracks | 142 | return albumart, tracks |
73 | 140 | 143 | ||
74 | 141 | 144 | ||
75 | @@ -149,6 +152,8 @@ | |||
76 | 149 | ''' | 152 | ''' |
77 | 150 | Search for help documents matching the search string | 153 | Search for help documents matching the search string |
78 | 151 | ''' | 154 | ''' |
79 | 155 | global tracks | ||
80 | 156 | global albumart | ||
81 | 152 | results = [] | 157 | results = [] |
82 | 153 | albums, tracks = get_music_from_gmusicbrowser() | 158 | albums, tracks = get_music_from_gmusicbrowser() |
83 | 154 | trackresults = [] | 159 | trackresults = [] |
84 | @@ -162,166 +167,75 @@ | |||
85 | 162 | albumartist = "" if track[5] is None else track[5] | 167 | albumartist = "" if track[5] is None else track[5] |
86 | 163 | year = 0 if track[7] is None else int(track[7]) | 168 | year = 0 if track[7] is None else int(track[7]) |
87 | 164 | genre = "" if track[6] is None else track[6] | 169 | genre = "" if track[6] is None else track[6] |
88 | 170 | track_length = 0 if track[10] is None else int(track[10]) | ||
89 | 171 | track_number = 0 if track[9] is None else int(track[9]) | ||
90 | 165 | trackname = title + " - " + album + " - " + artist | 172 | trackname = title + " - " + album + " - " + artist |
91 | 166 | if search.lower() in trackname.lower(): | 173 | if search.lower() in trackname.lower(): |
93 | 167 | albumart = get_album_art(track, albums) | 174 | albumart = 'file://' + get_album_art(track, albums).replace('\n', '') |
94 | 168 | albumuri = "album://" + albumartist + "/" + album | 175 | albumuri = "album://" + albumartist + "/" + album |
95 | 169 | if track not in trackresults: | 176 | if track not in trackresults: |
96 | 170 | results.append({'uri': uri, | 177 | results.append({'uri': uri, |
97 | 171 | 'icon': albumart, | 178 | 'icon': albumart, |
98 | 172 | 'category': 0, | 179 | 'category': 0, |
99 | 173 | 'mimetype': mimetype, | ||
100 | 174 | 'title': title, | 180 | 'title': title, |
101 | 175 | 'comment': artist, | ||
102 | 176 | 'album':GLib.Variant('s', album), | 181 | 'album':GLib.Variant('s', album), |
103 | 177 | 'artist':GLib.Variant('s', artist), | 182 | 'artist':GLib.Variant('s', artist), |
104 | 178 | 'genre':GLib.Variant('s', genre), | 183 | 'genre':GLib.Variant('s', genre), |
106 | 179 | 'year':GLib.Variant('i', year)}) | 184 | 'year':GLib.Variant('i', year), |
107 | 185 | 'track_length': GLib.Variant('i', track_length), | ||
108 | 186 | 'track_number': GLib.Variant('i', track_number)}) | ||
109 | 180 | trackresults.append(track) | 187 | trackresults.append(track) |
110 | 181 | 188 | ||
111 | 182 | if album not in albumresults: | 189 | if album not in albumresults: |
112 | 183 | results.append({'uri': albumuri, | 190 | results.append({'uri': albumuri, |
113 | 184 | 'icon': albumart, | 191 | 'icon': albumart, |
114 | 185 | 'category': 1, | 192 | 'category': 1, |
115 | 186 | 'mimetype': mimetype, | ||
116 | 187 | 'title': album, | 193 | 'title': album, |
117 | 188 | 'comment': artist, | ||
118 | 189 | 'album':GLib.Variant('s', album), | 194 | 'album':GLib.Variant('s', album), |
119 | 190 | 'artist':GLib.Variant('s', artist), | 195 | 'artist':GLib.Variant('s', artist), |
120 | 191 | 'genre':GLib.Variant('s', genre), | 196 | 'genre':GLib.Variant('s', genre), |
122 | 192 | 'year':GLib.Variant('i', year)}) | 197 | 'year':GLib.Variant('i', year), |
123 | 198 | 'track_length': GLib.Variant('i', track_length), | ||
124 | 199 | 'track_number': GLib.Variant('i', track_number)}) | ||
125 | 193 | albumresults.append(album) | 200 | albumresults.append(album) |
126 | 194 | return results | 201 | return results |
127 | 195 | 202 | ||
128 | 196 | 203 | ||
257 | 197 | def activate(scope, uri): | 204 | class Preview(Unity.ResultPreviewer): |
258 | 198 | import subprocess | 205 | |
259 | 199 | albumtracks = [] | 206 | def do_run(self): |
260 | 200 | albumtracks.append("gmusicbrowser") | 207 | global tracks |
261 | 201 | albumtracks.append("-play") | 208 | album = self.result.metadata['album'].get_string() |
262 | 202 | albumtracks.append("-playlist") | 209 | artist = self.result.metadata['artist'].get_string() |
263 | 203 | # If uri starts with album:// then we need to play all the songs on it | 210 | preview = Unity.MusicPreview.new(self.result.title, '', None) |
264 | 204 | if uri.startswith("album://"): | 211 | preview.props.image_source_uri = self.result.icon_hint |
265 | 205 | trackdetails = [] | 212 | preview.props.subtitle = self.result.metadata['artist'].get_string() |
266 | 206 | for track in tracks: | 213 | if self.result.uri.startswith("album://"): |
267 | 207 | trackdetail = [] | 214 | for track in tracks: |
268 | 208 | album = "album://" + track[5] + "/" + track[3] | 215 | if album in track[3] and artist in track[2]: |
269 | 209 | if not album.find(uri) == -1: | 216 | track = Unity.TrackMetadata.full(track[1], |
270 | 210 | albumtrack = track[1] | 217 | int(track[9]), |
271 | 211 | trackdetail.append(albumtrack) | 218 | track[0], |
272 | 212 | trackdetail.append(track[8]) | 219 | track[2], |
273 | 213 | trackdetails.append(trackdetail) | 220 | track[3], |
274 | 214 | trackdetails.sort(key=lambda track: int(track[1])) | 221 | int(track[10])) |
275 | 215 | for track in trackdetails: | 222 | preview.add_track(track) |
276 | 216 | albumtracks.append(track[0]) | 223 | else: |
277 | 217 | subprocess.Popen(albumtracks) | 224 | print(self.result.uri) |
278 | 218 | else: | 225 | track = Unity.TrackMetadata.full('file://%s' % self.result.uri.replace(' ', '%20'), |
279 | 219 | albumtracks.append("file://" + uri) | 226 | self.result.metadata['track_number'].get_int32(), |
280 | 220 | subprocess.Popen(albumtracks) | 227 | self.result.title, |
281 | 221 | return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri='') | 228 | self.result.metadata['artist'].get_string(), |
282 | 222 | 229 | self.result.metadata['album'].get_string(), | |
283 | 223 | 230 | self.result.metadata['track_length'].get_int32()) | |
284 | 224 | def show_in_folder(scope, uri): | 231 | preview.add_track(track) |
285 | 225 | """ Shows the folder containing the selected track as requested from the Preview | 232 | |
286 | 226 | """ | 233 | view_action = Unity.PreviewAction.new("play", _("Play"), None) |
287 | 227 | if uri.startswith("album://"): | 234 | preview.add_action(view_action) |
288 | 228 | for track in tracks: | 235 | show_action = Unity.PreviewAction.new("show", _("Show in Folder"), None) |
289 | 229 | album = "album://" + track[2] + "/" + track[3] | 236 | preview.add_action(show_action) |
290 | 230 | if not album.find(uri) == -1: | 237 | return preview |
291 | 231 | filename = track[1] | 238 | |
164 | 232 | continue | ||
165 | 233 | else: | ||
166 | 234 | filename = uri | ||
167 | 235 | dirname = os.path.dirname(filename) | ||
168 | 236 | dirname = dirname.replace("%20", "\ ") | ||
169 | 237 | os.system("xdg-open '%s'" % str(dirname)) | ||
170 | 238 | return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri='') | ||
171 | 239 | |||
172 | 240 | |||
173 | 241 | def preview_uri(scope, uri): | ||
174 | 242 | """Preview request handler""" | ||
175 | 243 | albumtracks = [] | ||
176 | 244 | isalbum = False | ||
177 | 245 | if uri.startswith("album://"): | ||
178 | 246 | isalbum = True | ||
179 | 247 | for track in tracks: | ||
180 | 248 | album = "album://" + track[2] + "/" + track[3] | ||
181 | 249 | if not album.find(uri) == -1: | ||
182 | 250 | albumtracks.append(track) | ||
183 | 251 | albumtracks.sort(key=lambda track: int(track[7])) | ||
184 | 252 | else: | ||
185 | 253 | for track in tracks: | ||
186 | 254 | album = "file://" + track[1] | ||
187 | 255 | if not album.find(uri) == -1: | ||
188 | 256 | albumtracks.append(track) | ||
189 | 257 | iteration = model.get_first_iter() | ||
190 | 258 | end_iter = model.get_last_iter() | ||
191 | 259 | while iteration != end_iter: | ||
192 | 260 | if model.get_value(iteration, 0) == uri: | ||
193 | 261 | title = model.get_value(iteration, 5) | ||
194 | 262 | description = model.get_value(iteration, 6) | ||
195 | 263 | if model.get_value(iteration, 1) == "musique": | ||
196 | 264 | image = "file:///usr/share/icons/hicolor/scalable/apps/audacious.svg" | ||
197 | 265 | else: | ||
198 | 266 | image = "file://%s" % model.get_value(iteration, 1) | ||
199 | 267 | |||
200 | 268 | preview = Unity.MusicPreview.new(title, description, None) | ||
201 | 269 | preview.props.image_source_uri = image | ||
202 | 270 | for albumtrack in albumtracks: | ||
203 | 271 | if isalbum: | ||
204 | 272 | track = Unity.TrackMetadata.full("file://" + urllib.parse.unquote(str(albumtrack[1])), # uri | ||
205 | 273 | int(albumtrack[7]), # track number | ||
206 | 274 | albumtrack[0], # track title | ||
207 | 275 | albumtrack[2], # artist | ||
208 | 276 | albumtrack[3], # album | ||
209 | 277 | int(albumtrack[8]) / 1000) # track length | ||
210 | 278 | else: | ||
211 | 279 | preview = Unity.MusicPreview.new(albumtrack[0], "", None) | ||
212 | 280 | preview.props.image_source_uri = image | ||
213 | 281 | track = Unity.TrackMetadata.full("file://" + urllib.parse.unquote(str(albumtrack[1])), | ||
214 | 282 | int(albumtrack[7]), | ||
215 | 283 | albumtrack[0], | ||
216 | 284 | albumtrack[2], | ||
217 | 285 | albumtrack[3], | ||
218 | 286 | int(albumtrack[8]) / 1000) | ||
219 | 287 | preview.add_track(track) | ||
220 | 288 | |||
221 | 289 | # Add the "Play" action | ||
222 | 290 | play_action = Unity.PreviewAction.new("activate_uri", "Play", None) | ||
223 | 291 | play_action.connect("activated", activate) | ||
224 | 292 | preview.add_action(play_action) | ||
225 | 293 | |||
226 | 294 | # Add the "Show in folder" action | ||
227 | 295 | show_action = Unity.PreviewAction.new("show_in_folder", "Show In Folder", None) | ||
228 | 296 | show_action.connect("activated", show_in_folder) | ||
229 | 297 | preview.add_action(show_action) | ||
230 | 298 | |||
231 | 299 | preview.connect("play", play) | ||
232 | 300 | preview.connect("pause", pause) | ||
233 | 301 | preview.connect("closed", closed) | ||
234 | 302 | break | ||
235 | 303 | iteration = model.next(iteration) | ||
236 | 304 | if preview is None: | ||
237 | 305 | print("Couldn't find model row for requested preview uri: '%s'", uri) | ||
238 | 306 | return preview | ||
239 | 307 | |||
240 | 308 | |||
241 | 309 | def play(preview, uri): | ||
242 | 310 | """Plays the selected track as selected in the Preview""" | ||
243 | 311 | player = self.bus.get_object(PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH) | ||
244 | 312 | dbus.Interface(player, PREVIEW_PLAYER_DBUS_IFACE).Play(uri) | ||
245 | 313 | |||
246 | 314 | |||
247 | 315 | def pause(preview, uri): | ||
248 | 316 | """Pauses the selected track as selected in the Preview""" | ||
249 | 317 | player = self.bus.get_object(PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH) | ||
250 | 318 | dbus.Interface(player, PREVIEW_PLAYER_DBUS_IFACE).Pause() | ||
251 | 319 | |||
252 | 320 | |||
253 | 321 | def closed(preview): | ||
254 | 322 | """Stops playing when the previre is closed""" | ||
255 | 323 | player = self.bus.get_object(PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH) | ||
256 | 324 | dbus.Interface(player, PREVIEW_PLAYER_DBUS_IFACE).Close() | ||
292 | 325 | 239 | ||
293 | 326 | # Classes below this point establish communication | 240 | # Classes below this point establish communication |
294 | 327 | # with Unity, you probably shouldn't modify them. | 241 | # with Unity, you probably shouldn't modify them. |
295 | @@ -356,19 +270,8 @@ | |||
296 | 356 | i['comment'] = '' | 270 | i['comment'] = '' |
297 | 357 | if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '': | 271 | if not 'dnd_uri' in i or not i['dnd_uri'] or i['dnd_uri'] == '': |
298 | 358 | i['dnd_uri'] = i['uri'] | 272 | i['dnd_uri'] = i['uri'] |
312 | 359 | i['metadata'] = {} | 273 | i['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS) |
313 | 360 | if EXTRA_METADATA: | 274 | result_set.add_result(**i) |
301 | 361 | for e in i: | ||
302 | 362 | for m in EXTRA_METADATA: | ||
303 | 363 | if m['id'] == e: | ||
304 | 364 | i['metadata'][e] = i[e] | ||
305 | 365 | i['metadata']['provider_credits'] = GLib.Variant('s', PROVIDER_CREDITS) | ||
306 | 366 | result = Unity.ScopeResult.create(str(i['uri']), str(i['icon']), | ||
307 | 367 | i['category'], i['result_type'], | ||
308 | 368 | str(i['mimetype']), str(i['title']), | ||
309 | 369 | str(i['comment']), str(i['dnd_uri']), | ||
310 | 370 | i['metadata']) | ||
311 | 371 | result_set.add_result(result) | ||
314 | 372 | except Exception as error: | 275 | except Exception as error: |
315 | 373 | print(error) | 276 | print(error) |
316 | 374 | 277 | ||
317 | @@ -424,6 +327,38 @@ | |||
318 | 424 | se = MySearch(search_context) | 327 | se = MySearch(search_context) |
319 | 425 | return se | 328 | return se |
320 | 426 | 329 | ||
321 | 330 | def do_activate(self, result, metadata, id): | ||
322 | 331 | album = result.metadata['album'].get_string() | ||
323 | 332 | artist = result.metadata['artist'].get_string() | ||
324 | 333 | global tracks | ||
325 | 334 | if id == 'show': | ||
326 | 335 | if result.uri.startswith("album://"): | ||
327 | 336 | for track in tracks: | ||
328 | 337 | if album in track[3] and artist in track[2]: | ||
329 | 338 | filename = tracks[1] | ||
330 | 339 | continue | ||
331 | 340 | else: | ||
332 | 341 | filename = result.uri | ||
333 | 342 | dirname = os.path.dirname(filename) | ||
334 | 343 | os.system("xdg-open '%s'" % str(dirname)) | ||
335 | 344 | else: | ||
336 | 345 | albumtracks = '' | ||
337 | 346 | if result.uri.startswith('album://'): | ||
338 | 347 | for track in tracks: | ||
339 | 348 | if album in track[3] and artist in track[2]: | ||
340 | 349 | albumtracks = albumtracks + ' \'%s\'' % (track[1]) | ||
341 | 350 | else: | ||
342 | 351 | albumtracks = '\'%s\'' % result.uri | ||
343 | 352 | os.system('gmusicbrowser -play -playlist %s' % albumtracks) | ||
344 | 353 | |||
345 | 354 | return Unity.ActivationResponse(handled=Unity.HandledType.HIDE_DASH, goto_uri=None) | ||
346 | 355 | |||
347 | 356 | def do_create_previewer(self, result, metadata): | ||
348 | 357 | rp = Preview() | ||
349 | 358 | rp.set_scope_result(result) | ||
350 | 359 | rp.set_search_metadata(metadata) | ||
351 | 360 | return rp | ||
352 | 361 | |||
353 | 427 | 362 | ||
354 | 428 | def load_scope(): | 363 | def load_scope(): |
355 | 429 | return Scope() | 364 | return Scope() |
356 | 430 | 365 | ||
357 | === modified file 'tests/test_gmusicbrowser.py' | |||
358 | --- tests/test_gmusicbrowser.py 2013-03-03 19:20:19 +0000 | |||
359 | +++ tests/test_gmusicbrowser.py 2013-04-22 13:23:30 +0000 | |||
360 | @@ -11,17 +11,18 @@ | |||
361 | 11 | self.results = [] | 11 | self.results = [] |
362 | 12 | 12 | ||
363 | 13 | def do_add_result(self, result): | 13 | def do_add_result(self, result): |
368 | 14 | self.results.append({'uri':result.uri, | 14 | self.results.append({'uri': result.uri, |
369 | 15 | 'title':result.title, | 15 | 'title': result.title, |
370 | 16 | 'comment':result.comment, | 16 | 'comment': result.comment, |
371 | 17 | 'icon':result.icon_hint}) | 17 | 'icon': result.icon_hint}) |
372 | 18 | |||
373 | 18 | 19 | ||
374 | 19 | class ScopeTestCase(TestCase): | 20 | class ScopeTestCase(TestCase): |
375 | 20 | def init_scope(self, scope_path): | 21 | def init_scope(self, scope_path): |
376 | 21 | self.scope_module = imp.load_source('scope', scope_path) | 22 | self.scope_module = imp.load_source('scope', scope_path) |
377 | 22 | self.scope = self.scope_module.load_scope() | 23 | self.scope = self.scope_module.load_scope() |
378 | 23 | 24 | ||
380 | 24 | def perform_query(self, query, filter_set = Unity.FilterSet.new()): | 25 | def perform_query(self, query, filter_set=Unity.FilterSet.new()): |
381 | 25 | result_set = ResultSet() | 26 | result_set = ResultSet() |
382 | 26 | ctx = Unity.SearchContext.create(query, 0, filter_set, | 27 | ctx = Unity.SearchContext.create(query, 0, filter_set, |
383 | 27 | None, result_set, None) | 28 | None, result_set, None) |
384 | @@ -30,7 +31,7 @@ | |||
385 | 30 | return result_set | 31 | return result_set |
386 | 31 | 32 | ||
387 | 32 | 33 | ||
389 | 33 | class TestAskUbuntu(ScopeTestCase): | 34 | class TestGmusicbrowser(ScopeTestCase): |
390 | 34 | def setUp(self): | 35 | def setUp(self): |
391 | 35 | self.init_scope('src/unity_gmusicbrowser_daemon.py') | 36 | self.init_scope('src/unity_gmusicbrowser_daemon.py') |
392 | 36 | 37 | ||
393 | @@ -38,7 +39,7 @@ | |||
394 | 38 | self.scope = None | 39 | self.scope = None |
395 | 39 | self.scope_module = None | 40 | self.scope_module = None |
396 | 40 | 41 | ||
398 | 41 | def test_questions_search(self): | 42 | def test_qsearch(self): |
399 | 42 | self.scope_module.GMUSICBROWSER_DBFILE = 'tests/data/mock_gmusicbrowser_pass' | 43 | self.scope_module.GMUSICBROWSER_DBFILE = 'tests/data/mock_gmusicbrowser_pass' |
400 | 43 | expected_results = ["/home/mark/Music/Jacques Dutronc/En Vogue/02. Mini, Mini, Mini.mp3", | 44 | expected_results = ["/home/mark/Music/Jacques Dutronc/En Vogue/02. Mini, Mini, Mini.mp3", |
401 | 44 | "Mini, Mini, Mini"] | 45 | "Mini, Mini, Mini"] |
402 | @@ -49,8 +50,7 @@ | |||
403 | 49 | results.append(result_set.results[0]['title']) | 50 | results.append(result_set.results[0]['title']) |
404 | 50 | self.assertEqual(results, expected_results) | 51 | self.assertEqual(results, expected_results) |
405 | 51 | 52 | ||
408 | 52 | 53 | def test_failing_search(self): | |
407 | 53 | def test_questions_failing_search(self): | ||
409 | 54 | self.scope_module.GMUSICBROWSER_DBFILE = 'tests/data/mock_gmusicbrowser_fail' | 54 | self.scope_module.GMUSICBROWSER_DBFILE = 'tests/data/mock_gmusicbrowser_fail' |
410 | 55 | for s in ['upnriitnyt']: | 55 | for s in ['upnriitnyt']: |
411 | 56 | result_set = self.perform_query(s) | 56 | result_set = self.perform_query(s) |
FAILED: Continuous integration, rev:20 jenkins. qa.ubuntu. com/job/ unity-scope- gmusicbrowser- ci/1/ jenkins. qa.ubuntu. com/job/ unity-scope- gmusicbrowser- raring- amd64-ci/ 1/console
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ unity-scope- gmusicbrowser- ci/1/rebuild
http://