Merge lp:~ahayzen/music-app/pep8-update-fixes into lp:music-app/trusty

Proposed by Andrew Hayzen
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 504
Merged at revision: 503
Proposed branch: lp:~ahayzen/music-app/pep8-update-fixes
Merge into: lp:music-app/trusty
Diff against target: 491 lines (+100/-97)
3 files modified
tests/autopilot/music_app/emulators.py (+3/-3)
tests/autopilot/music_app/tests/__init__.py (+63/-60)
tests/autopilot/music_app/tests/test_music.py (+34/-34)
To merge this branch: bzr merge lp:~ahayzen/music-app/pep8-update-fixes
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Music App Developers Pending
Review via email: mp+224370@code.launchpad.net

Commit message

* Fix Pep8 after update

Description of the change

* Fix Pep8 after update

PEP8 has been updated in utopic causing some styling to fail.

To post a comment you must log in.
504. By Andrew Hayzen

* Fix for incorrect formatting of string

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

So many comment changes :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/music_app/emulators.py'
2--- tests/autopilot/music_app/emulators.py 2014-06-20 21:49:33 +0000
3+++ tests/autopilot/music_app/emulators.py 2014-06-24 23:50:34 +0000
4@@ -66,16 +66,16 @@
5 # switch to albums tab
6 self.switch_to_tab("albumstab")
7
8- #select album
9+ # select album
10 albumartist = self.get_albums_albumartist(artistName)
11 self.pointing_device.click_object(albumartist)
12
13- #get track item to add to queue
14+ # get track item to add to queue
15 trackicon = self.get_album_sheet_listview_trackicon(
16 trackTitle)
17 self.pointing_device.click_object(trackicon)
18
19- #click on Add to queue
20+ # click on Add to queue
21 queueTrackLabel = self.get_album_sheet_queuetrack_label()
22 self.pointing_device.click_object(queueTrackLabel)
23
24
25=== modified file 'tests/autopilot/music_app/tests/__init__.py'
26--- tests/autopilot/music_app/tests/__init__.py 2014-06-19 01:47:36 +0000
27+++ tests/autopilot/music_app/tests/__init__.py 2014-06-24 23:50:34 +0000
28@@ -85,23 +85,23 @@
29
30 launch, self.test_type = self.setup_environment()
31
32- #Use backup and restore to setup test environment
33+ # Use backup and restore to setup test environment
34 #################################################
35- #for now, we will use real /home
36+ # for now, we will use real /home
37 logger.debug("Backup root folder %s" % self.backup_root)
38
39- #backup and wipe before testing
40+ # backup and wipe before testing
41 sqlite_dir = os.path.join(
42 os.environ.get('HOME'), '.local/share/com.ubuntu.music/Databases')
43 self.backup_folder(sqlite_dir)
44 self.addCleanup(lambda: self.restore_folder(sqlite_dir))
45
46- #backup Music folder and restore it after testing
47+ # backup Music folder and restore it after testing
48 self.backup_folder(os.path.join(os.environ.get('HOME'), 'Music'))
49 self.addCleanup(lambda: self.restore_folder(
50 os.path.join(os.environ.get('HOME'), 'Music')))
51
52- #backup mediascanner folder and restore it after testing
53+ # backup mediascanner folder and restore it after testing
54 self.backup_folder(os.path.join(os.environ.get('HOME'),
55 '.cache/mediascanner-2.0'))
56 self.addCleanup(lambda: self.restore_folder(os.path.join(
57@@ -110,43 +110,46 @@
58
59 self.home_dir = os.environ['HOME']
60 self._create_music_library()
61+
62+ '''
63 #################################################
64- #Use backup and restore to setup test environment
65-
66- #Use mocking fakehome
67- #####################
68- #self.home_dir = self._patch_home()
69-
70- #self._create_music_library()
71-
72- ##we need to also tell upstart about our fake home
73- ##and we need to do this all in one shell,
74- ##also passing along our fake env (env=env)
75- #logger.debug("Launching mediascanner")
76- #env = os.environ.copy()
77- #sethome = "initctl set-env HOME=" + self.home_dir
78- #retcode = subprocess.check_output(sethome + "; \
79- #start mediascanner-2.0",
80- #env=env,
81- #stderr=subprocess.STDOUT,
82- #shell=True)
83- #logger.debug("mediascanner launched %s" % retcode)
84- #time.sleep(10)
85-
86- #logger.debug("Launching mediascanner-dbus")
87- #retcode = subprocess.call(
88- #"/usr/lib/*/mediascanner-2.0/mediascanner-dbus-2.0 &",
89- #env=env, stderr=subprocess.STDOUT, shell=True)
90- #logger.debug("mediascanner-dbus launched %s" % retcode)
91-
92- ##we attempt to reset home for future upstart jobs
93- #retcode = subprocess.check_output("initctl reset-env",
94- #env=env, shell=True)
95- #retcode = subprocess.check_output("initctl get-env HOME",
96- #env=env, shell=True)
97- #logger.debug("reset initctl home %s" % retcode)
98- #####################
99- #Use mocking fakehome
100+ # Use backup and restore to setup test environment
101+
102+ # Use mocking fakehome
103+ #####################
104+ self.home_dir = self._patch_home()
105+
106+ self._create_music_library()
107+
108+ # we need to also tell upstart about our fake home
109+ # and we need to do this all in one shell,
110+ # also passing along our fake env (env=env)
111+ logger.debug("Launching mediascanner")
112+ env = os.environ.copy()
113+ sethome = "initctl set-env HOME=" + self.home_dir
114+ retcode = subprocess.check_output(sethome + "; \
115+ start mediascanner-2.0",
116+ env=env,
117+ stderr=subprocess.STDOUT,
118+ shell=True)
119+ logger.debug("mediascanner launched %s" % retcode)
120+ time.sleep(10)
121+
122+ logger.debug("Launching mediascanner-dbus")
123+ retcode = subprocess.call(
124+ "/usr/lib/*/mediascanner-2.0/mediascanner-dbus-2.0 &",
125+ env=env, stderr=subprocess.STDOUT, shell=True)
126+ logger.debug("mediascanner-dbus launched %s" % retcode)
127+
128+ # we attempt to reset home for future upstart jobs
129+ retcode = subprocess.check_output("initctl reset-env",
130+ env=env, shell=True)
131+ retcode = subprocess.check_output("initctl get-env HOME",
132+ env=env, shell=True)
133+ logger.debug("reset initctl home %s" % retcode)
134+ #####################
135+ # Use mocking fakehome
136+ '''
137
138 self.pointing_device = Pointer(self.input_device_class.create())
139 super(MusicTestCase, self).setUp()
140@@ -179,10 +182,10 @@
141 def _copy_xauthority_file(self, directory):
142 """ Copy .Xauthority file to directory, if it exists in /home
143 """
144- #If running under xvfb, as jenkins does,
145- #xsession will fail to start without xauthority file
146- #Thus if the Xauthority file is in the home directory
147- #make sure we copy it to our temp home directory
148+ # If running under xvfb, as jenkins does,
149+ # xsession will fail to start without xauthority file
150+ # Thus if the Xauthority file is in the home directory
151+ # make sure we copy it to our temp home directory
152
153 xauth = os.path.expanduser(os.path.join(os.environ.get('HOME'),
154 '.Xauthority'))
155@@ -196,8 +199,8 @@
156 def _patch_home(self):
157 """ mock /home for testing purposes to preserve user data
158 """
159- #click requires apparmor profile, and writing to special dir
160- #but the desktop can write to a traditional /tmp directory
161+ # click requires apparmor profile, and writing to special dir
162+ # but the desktop can write to a traditional /tmp directory
163 if self.test_type == 'click':
164 env_dir = os.path.join(os.environ.get('HOME'), 'autopilot',
165 'fakeenv')
166@@ -208,8 +211,8 @@
167 temp_dir_fixture = fixtures.TempDir(env_dir)
168 self.useFixture(temp_dir_fixture)
169
170- #apparmor doesn't allow the app to create needed directories,
171- #so we create them now
172+ # apparmor doesn't allow the app to create needed directories,
173+ # so we create them now
174 temp_dir = temp_dir_fixture.path
175 temp_dir_cache = os.path.join(temp_dir, '.cache')
176 temp_dir_cache_font = os.path.join(temp_dir_cache, 'fontconfig')
177@@ -242,7 +245,7 @@
178 if not os.path.exists(temp_dir_confined):
179 os.makedirs(temp_dir_confined)
180
181- #before we set fixture, copy xauthority if needed
182+ # before we set fixture, copy xauthority if needed
183 self._copy_xauthority_file(temp_dir)
184 self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable(
185 HOME=temp_dir))
186@@ -251,7 +254,7 @@
187 self.useFixture(temp_dir_fixture)
188 temp_dir = temp_dir_fixture.path
189
190- #before we set fixture, copy xauthority if needed
191+ # before we set fixture, copy xauthority if needed
192 self._copy_xauthority_file(temp_dir)
193 self.useFixture(fixtures.EnvironmentVariable('HOME',
194 newvalue=temp_dir))
195@@ -270,13 +273,13 @@
196 os.makedirs(musicpath)
197 logger.debug("Mediascanner path set to %s" % mediascannerpath)
198
199- #set content path
200+ # set content path
201 content_dir = os.path.join(os.path.dirname(music_app.__file__),
202 'content')
203
204 logger.debug("Content dir set to %s" % content_dir)
205
206- #copy content
207+ # copy content
208 shutil.copy(os.path.join(content_dir, '1.ogg'), musicpath)
209 shutil.copy(os.path.join(content_dir, '2.ogg'), musicpath)
210 shutil.copy(os.path.join(content_dir, '3.mp3'), musicpath)
211@@ -292,9 +295,9 @@
212 str(os.listdir(mediascannerpath)))
213
214 def _patch_mediascanner_home(self, mediascannerpath):
215- #do some inline db patching
216- #patch mediaindex to proper home
217- #these values are dependent upon our sampled db
218+ # do some inline db patching
219+ # patch mediaindex to proper home
220+ # these values are dependent upon our sampled db
221 logger.debug("Patching fake mediascanner database in %s" %
222 mediascannerpath)
223 logger.debug(
224@@ -303,7 +306,7 @@
225
226 relhome = self.home_dir[1:]
227 dblocation = "home/phablet"
228- #patch mediaindex
229+ # patch mediaindex
230 self._file_find_replace(mediascannerpath +
231 "/mediastore.sql", dblocation, relhome)
232
233@@ -315,8 +318,8 @@
234 con.close()
235
236 def _file_find_replace(self, in_filename, find, replace):
237- #replace all occurences of string find with string replace
238- #in the given file
239+ # replace all occurences of string find with string replace
240+ # in the given file
241 out_filename = in_filename + ".tmp"
242 infile = open(in_filename, 'rb')
243 outfile = open(out_filename, 'wb')
244@@ -325,7 +328,7 @@
245 infile.close()
246 outfile.close()
247
248- #remove original file and copy new file back
249+ # remove original file and copy new file back
250 os.remove(in_filename)
251 os.rename(out_filename, in_filename)
252
253
254=== modified file 'tests/autopilot/music_app/tests/test_music.py'
255--- tests/autopilot/music_app/tests/test_music.py 2014-06-20 21:45:24 +0000
256+++ tests/autopilot/music_app/tests/test_music.py 2014-06-24 23:50:34 +0000
257@@ -27,7 +27,7 @@
258 self.assertThat(
259 self.main_view.visible, Eventually(Equals(True)))
260
261- #wait for activity indicator to stop spinning
262+ # wait for activity indicator to stop spinning
263 spinner = lambda: self.main_view.get_spinner().running
264 self.assertThat(spinner, Eventually(Equals(False)))
265 self.trackTitle = u"Gran Vals"
266@@ -111,12 +111,12 @@
267 endtracksCount = self.main_view.get_queue_track_count()
268 self.assertThat(endtracksCount, Equals(initialtracksCount + 1))
269
270- #Assert that the song added to the list is not playing
271+ # Assert that the song added to the list is not playing
272 self.assertThat(self.player.currentIndex,
273 Eventually(NotEquals(endtracksCount)))
274 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
275
276- #verify song's metadata matches the item added to the Now Playing view
277+ # verify song's metadata matches the item added to the Now Playing view
278 queueArtistName = self.main_view.get_queue_now_playing_artist(
279 self.artistName)
280 self.assertThat(queueArtistName.text, Equals(self.artistName))
281@@ -176,7 +176,7 @@
282 orgTitle = self.player.currentMetaTitle
283 orgArtist = self.player.currentMetaArtist
284
285- #check original track
286+ # check original track
287 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
288 logger.debug("Original Song %s, %s" % (orgTitle, orgArtist))
289
290@@ -187,7 +187,7 @@
291 self.turn_shuffle_off()
292
293 """ Select next """
294- #goal is to go back and forth and ensure 2 different songs
295+ # goal is to go back and forth and ensure 2 different songs
296 forwardbutton = self.main_view.get_forward_button()
297 self.pointing_device.click_object(forwardbutton)
298 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
299@@ -196,7 +196,7 @@
300 self.pointing_device.click_object(playbutton)
301 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
302
303- #ensure different song
304+ # ensure different song
305 self.assertThat(title, Eventually(NotEquals(orgTitle)))
306 self.assertThat(artist, Eventually(NotEquals(orgArtist)))
307 nextTitle = self.player.currentMetaTitle
308@@ -215,7 +215,7 @@
309 self.pointing_device.click_object(playbutton)
310 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
311
312- #ensure we're back to original song
313+ # ensure we're back to original song
314 self.assertThat(title, Eventually(Equals(orgTitle)))
315 self.assertThat(artist, Eventually(Equals(orgArtist)))
316
317@@ -234,8 +234,8 @@
318
319 """ Track is playing """
320 count = 1
321- #ensure track appears before looping through queue more than once
322- #needs to contain test mp3 metadata and end in *.mp3
323+ # ensure track appears before looping through queue more than once
324+ # needs to contain test mp3 metadata and end in *.mp3
325 queue = self.main_view.get_queue_track_count()
326 while title != "TestMP3Title" and artist != "TestMP3Artist":
327 self.assertThat(count, LessThan(queue))
328@@ -256,7 +256,7 @@
329
330 count = count + 1
331
332- #make sure mp3 plays
333+ # make sure mp3 plays
334 self.assertThat(self.player.source.endswith("mp3"),
335 Equals(True))
336 self.pointing_device.click_object(playbutton)
337@@ -273,7 +273,7 @@
338 playbutton = self.main_view.get_now_playing_play_button()
339 previousbutton = self.main_view.get_previous_button()
340
341- #play for a second, then pause
342+ # play for a second, then pause
343 if not self.player.isPlaying:
344 logger.debug("Play not selected")
345 self.pointing_device.click_object(playbutton)
346@@ -289,10 +289,10 @@
347 while True:
348 self.assertThat(count, LessThan(100))
349
350- #goal is to hit next under shuffle mode
351- #then verify original track is not the previous track
352- #this means a true shuffle happened
353- #if it doesn't try again, up to count times
354+ # goal is to hit next under shuffle mode
355+ # then verify original track is not the previous track
356+ # this means a true shuffle happened
357+ # if it doesn't try again, up to count times
358
359 orgTitle = self.player.currentMetaTitle
360 orgArtist = self.player.currentMetaArtist
361@@ -310,8 +310,8 @@
362 artist = self.player.currentMetaArtist
363 logger.debug("Current Song %s, %s" % (title, artist))
364
365- #go back to previous and check against original
366- #play song, then pause before switching
367+ # go back to previous and check against original
368+ # play song, then pause before switching
369 time.sleep(1)
370 self.pointing_device.click_object(playbutton)
371 self.assertThat(self.player.isPlaying,
372@@ -325,7 +325,7 @@
373 artist = self.player.currentMetaArtist
374
375 if title != orgTitle and artist != orgArtist:
376- #we shuffled properly
377+ # we shuffled properly
378 logger.debug("Yay, shuffled %s, %s" % (title, artist))
379 break
380 else:
381@@ -338,11 +338,11 @@
382 # switch to albums tab
383 self.main_view.switch_to_tab("albumstab")
384
385- #select album
386+ # select album
387 albumartist = self.main_view.get_albums_albumartist(self.artistName)
388 self.pointing_device.click_object(albumartist)
389
390- #get album sheet album artist
391+ # get album sheet album artist
392 sheet_albumartist = self.main_view.get_album_sheet_artist()
393 self.assertThat(sheet_albumartist.text, Equals(self.artistName))
394
395@@ -364,12 +364,12 @@
396 endtracksCount = self.main_view.get_queue_track_count()
397 self.assertThat(endtracksCount, Equals(initialtracksCount + 1))
398
399- #Assert that the song added to the list is not playing
400+ # Assert that the song added to the list is not playing
401 self.assertThat(self.player.currentIndex,
402 Eventually(NotEquals(endtracksCount)))
403 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
404
405- #verify song's metadata matches the item added to the Now Playing view
406+ # verify song's metadata matches the item added to the Now Playing view
407 queueArtistName = self.main_view.get_queue_now_playing_artist(
408 self.artistName)
409 self.assertThat(queueArtistName.text, Equals(self.artistName))
410@@ -494,11 +494,11 @@
411 # switch to artists tab
412 self.main_view.switch_to_tab("artiststab")
413
414- #select artist
415+ # select artist
416 artist = self.main_view.get_artists_artist(self.artistName)
417 self.pointing_device.click_object(artist)
418
419- #get album sheet album artist
420+ # get album sheet album artist
421 sheet_albumartist = self.main_view.get_artist_sheet_artist()
422 self.assertThat(sheet_albumartist.text, Equals(self.artistName))
423
424@@ -506,14 +506,14 @@
425 sheet_albumartist = self.main_view.get_artist_sheet_artist_cover()
426 self.pointing_device.click_object(sheet_albumartist)
427
428- #get song sheet album artist
429+ # get song sheet album artist
430 sheet_albumartist = self.main_view.get_album_sheet_artist()
431 self.assertThat(sheet_albumartist.text, Equals(self.artistName))
432
433 # click on song to populate queue and start playing
434 self.pointing_device.click_object(sheet_albumartist)
435
436- #select artist
437+ # select artist
438 track = self.main_view.get_album_sheet_listview_tracktitle(
439 self.trackTitle)
440 self.pointing_device.click_object(track)
441@@ -580,12 +580,12 @@
442
443 num_tracks = self.main_view.get_queue_track_count()
444
445- #Skip through all songs in queue, stopping on last one.
446+ # Skip through all songs in queue, stopping on last one.
447 forward_button = self.main_view.get_forward_button()
448 for count in range(0, num_tracks - 1):
449 self.pointing_device.click_object(forward_button)
450
451- #When the last song ends, playback should stop
452+ # When the last song ends, playback should stop
453 self.assertThat(self.player.isPlaying, Eventually(Equals(False)))
454
455 def test_playback_repeats_when_last_song_ends_and_repeat_on(self):
456@@ -598,12 +598,12 @@
457 self.turn_repeat_on()
458
459 num_titles = self.main_view.get_queue_track_count()
460- #Skip through all songs in queue, stopping on last one.
461+ # Skip through all songs in queue, stopping on last one.
462 forward_button = self.main_view.get_forward_button()
463 for count in range(0, num_titles - 1):
464 self.pointing_device.click_object(forward_button)
465
466- #Make sure we loop back to first song after last song ends
467+ # Make sure we loop back to first song after last song ends
468 actual_title = lambda: self.player.currentMetaTitle
469 self.assertThat(actual_title, Eventually(Equals(self.trackTitle)))
470 self.assertThat(self.player.isPlaying, Eventually(Equals(True)))
471@@ -618,7 +618,7 @@
472 self.turn_repeat_on()
473
474 num_titles = self.main_view.get_queue_track_count()
475- #Skip through all songs in queue, INCLUDING last one.
476+ # Skip through all songs in queue, INCLUDING last one.
477 forward_button = self.main_view.get_forward_button()
478 for count in range(0, num_titles - 1):
479 self.pointing_device.click_object(forward_button)
480@@ -639,9 +639,9 @@
481 prev_button = self.main_view.get_previous_button()
482 initial_song = self.player.currentMetaTitle
483 self.pointing_device.click_object(prev_button)
484- #If we're far enough into a song, pressing prev just takes us to the
485- #beginning of that track. In that case, hit prev again to actually
486- #skip over the track.
487+ # If we're far enough into a song, pressing prev just takes us to the
488+ # beginning of that track. In that case, hit prev again to actually
489+ # skip over the track.
490 if self.player.currentMetaTitle == initial_song:
491 self.pointing_device.click_object(prev_button)
492

Subscribers

People subscribed via source and target branches

to status/vote changes: