Merge lp:~nskaggs/music-app/fix-tests-mediascanner into lp:music-app/trusty

Proposed by Nicholas Skaggs
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 141
Merged at revision: 146
Proposed branch: lp:~nskaggs/music-app/fix-tests-mediascanner
Merge into: lp:music-app/trusty
Diff against target: 119 lines (+23/-26)
2 files modified
tests/autopilot/music_app/tests/__init__.py (+15/-7)
tests/autopilot/music_app/tests/test_music.py (+8/-19)
To merge this branch: bzr merge lp:~nskaggs/music-app/fix-tests-mediascanner
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+188915@code.launchpad.net

Commit message

Fix autopilot tests to run in lab

Description of the change

Correct lab issues with the mediascanner tests (and hopefully not get this merged before it's ready :-) )

To post a comment you must log in.
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: Needs Fixing (continuous-integration)
138. By Nicholas Skaggs

add xauthority fix

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

combine play/pause tests and add extra asserts to wait for objects to ensure they exist

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

add the notequals

141. By Nicholas Skaggs

remove unneeded contains

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) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/autopilot/music_app/tests/__init__.py'
--- tests/autopilot/music_app/tests/__init__.py 2013-10-01 19:26:29 +0000
+++ tests/autopilot/music_app/tests/__init__.py 2013-10-02 20:57:26 +0000
@@ -82,6 +82,14 @@
82 os.mkdir(temp_dir)82 os.mkdir(temp_dir)
83 logger.debug("Created fake home directory " + temp_dir)83 logger.debug("Created fake home directory " + temp_dir)
84 self.addCleanup(shutil.rmtree, temp_dir)84 self.addCleanup(shutil.rmtree, temp_dir)
85 #if the Xauthority file is in home directory
86 #make sure we copy it to temp home, otherwise do nothing
87 xauth = os.path.expanduser(os.path.join('~', '.Xauthority'))
88 if os.path.isfile(xauth):
89 logger.debug("Copying .Xauthority to fake home " + temp_dir)
90 shutil.copyfile(
91 os.path.expanduser(os.path.join('~', '.Xauthority')),
92 os.path.join(temp_dir, '.Xauthority'))
85 patcher = mock.patch.dict('os.environ', {'HOME': temp_dir})93 patcher = mock.patch.dict('os.environ', {'HOME': temp_dir})
86 patcher.start()94 patcher.start()
87 logger.debug("Patched home to fake home directory " + temp_dir)95 logger.debug("Patched home to fake home directory " + temp_dir)
@@ -97,13 +105,7 @@
97 os.mkdir(musicpath)105 os.mkdir(musicpath)
98 logger.debug("Mediascanner path set to " + mediascannerpath)106 logger.debug("Mediascanner path set to " + mediascannerpath)
99107
100 #copy over our index108 #copy over the music and index
101 shutil.copytree(self.working_dir + '/music_app/content/mediascanner',
102 mediascannerpath)
103
104 logger.debug("Mediascanner database copied, files " + str(os.listdir(mediascannerpath)))
105
106 #copy over the music
107 if os.path.exists(self.local_location):109 if os.path.exists(self.local_location):
108 shutil.copy(self.working_dir + '/music_app/content/'110 shutil.copy(self.working_dir + '/music_app/content/'
109 +'1.ogg',111 +'1.ogg',
@@ -111,6 +113,9 @@
111 shutil.copy(self.working_dir + '/music_app/content/'113 shutil.copy(self.working_dir + '/music_app/content/'
112 +'2.ogg',114 +'2.ogg',
113 musicpath)115 musicpath)
116 shutil.copytree(self.working_dir + '/music_app/content/mediascanner',
117 mediascannerpath)
118
114 else:119 else:
115 shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'120 shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'
116 +'1.ogg',121 +'1.ogg',
@@ -118,8 +123,11 @@
118 shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'123 shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'
119 +'2.ogg',124 +'2.ogg',
120 musicpath)125 musicpath)
126 shutil.copytree('/usr/lib/python2.7/dist-packages/music_app/content/mediascanner',
127 mediascannerpath)
121128
122 logger.debug("Music copied, files " + str(os.listdir(musicpath)))129 logger.debug("Music copied, files " + str(os.listdir(musicpath)))
130 logger.debug("Mediascanner database copied, files " + str(os.listdir(mediascannerpath)))
123131
124 #do some inline db patching132 #do some inline db patching
125 #patch mediaindex to proper home133 #patch mediaindex to proper home
126134
=== modified file 'tests/autopilot/music_app/tests/test_music.py'
--- tests/autopilot/music_app/tests/test_music.py 2013-10-01 19:26:29 +0000
+++ tests/autopilot/music_app/tests/test_music.py 2013-10-02 20:57:26 +0000
@@ -10,8 +10,7 @@
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12from autopilot.matchers import Eventually12from autopilot.matchers import Eventually
13from testtools.matchers import Equals13from testtools.matchers import Equals, NotEquals
14from testtools.matchers import Contains
1514
16from music_app.tests import MusicTestCase15from music_app.tests import MusicTestCase
1716
@@ -22,15 +21,17 @@
22 """ tests if the music library is populated from our21 """ tests if the music library is populated from our
23 fake mediascanner database"""22 fake mediascanner database"""
2423
24 self.assertThat(self.main_view.get_main_view, Eventually(NotEquals(None)))
25 mainView = self.main_view.get_main_view()25 mainView = self.main_view.get_main_view()
26 title = lambda: mainView.currentTracktitle26 title = lambda: mainView.currentTracktitle
27 artist = lambda: mainView.currentArtist27 artist = lambda: mainView.currentArtist
28 self.assertThat(title, Eventually(Equals("Foss Yeaaaah! (Radio Edit)")))28 self.assertThat(title, Eventually(Equals("Foss Yeaaaah! (Radio Edit)")))
29 self.assertThat(artist, Eventually(Equals("Benjamin Kerensa")))29 self.assertThat(artist, Eventually(Equals("Benjamin Kerensa")))
3030
31 def test_play(self):31 def test_play_pause(self):
32 """ Test Playing a track (Music Library must exist) """32 """ Test playing and pausing a track (Music Library must exist) """
3333
34 self.assertThat(self.main_view.get_play_button, Eventually(NotEquals(None)))
34 playbutton = self.main_view.get_play_button()35 playbutton = self.main_view.get_play_button()
35 mainView = self.main_view.get_main_view()36 mainView = self.main_view.get_main_view()
3637
@@ -41,26 +42,14 @@
41 """ Track is playing"""42 """ Track is playing"""
42 self.assertThat(mainView.isPlaying, Eventually(Equals(True)))43 self.assertThat(mainView.isPlaying, Eventually(Equals(True)))
4344
44 def test_pause(self):45 """ Track is not playing"""
45 """ Test Pausing a track (Music Library must exist) """46 self.pointing_device.click_object(playbutton)
46
47 playbutton = self.main_view.get_play_button()
48 mainView = self.main_view.get_main_view()
49
50 """ Track is not playing"""
51 self.assertThat(mainView.isPlaying, Equals(False))
52 self.pointing_device.click_object(playbutton)
53
54 """ Track is playing"""
55 self.assertThat(mainView.isPlaying, Eventually(Equals(True)))
56 self.pointing_device.click_object(playbutton)
57
58 """ Track is not playing"""
59 self.assertThat(mainView.isPlaying, Eventually(Equals(False)))47 self.assertThat(mainView.isPlaying, Eventually(Equals(False)))
6048
61 def test_next(self):49 def test_next(self):
62 """ Test going to next track (Music Library must exist) """50 """ Test going to next track (Music Library must exist) """
6351
52 self.assertThat(self.main_view.get_forward_button, Eventually(NotEquals(None)))
64 forwardbutton = self.main_view.get_forward_button()53 forwardbutton = self.main_view.get_forward_button()
65 mainView = self.main_view.get_main_view()54 mainView = self.main_view.get_main_view()
66 title = lambda: mainView.currentTracktitle55 title = lambda: mainView.currentTracktitle

Subscribers

People subscribed via source and target branches

to status/vote changes: