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
1=== modified file 'tests/autopilot/music_app/tests/__init__.py'
2--- tests/autopilot/music_app/tests/__init__.py 2013-10-01 19:26:29 +0000
3+++ tests/autopilot/music_app/tests/__init__.py 2013-10-02 20:57:26 +0000
4@@ -82,6 +82,14 @@
5 os.mkdir(temp_dir)
6 logger.debug("Created fake home directory " + temp_dir)
7 self.addCleanup(shutil.rmtree, temp_dir)
8+ #if the Xauthority file is in home directory
9+ #make sure we copy it to temp home, otherwise do nothing
10+ xauth = os.path.expanduser(os.path.join('~', '.Xauthority'))
11+ if os.path.isfile(xauth):
12+ logger.debug("Copying .Xauthority to fake home " + temp_dir)
13+ shutil.copyfile(
14+ os.path.expanduser(os.path.join('~', '.Xauthority')),
15+ os.path.join(temp_dir, '.Xauthority'))
16 patcher = mock.patch.dict('os.environ', {'HOME': temp_dir})
17 patcher.start()
18 logger.debug("Patched home to fake home directory " + temp_dir)
19@@ -97,13 +105,7 @@
20 os.mkdir(musicpath)
21 logger.debug("Mediascanner path set to " + mediascannerpath)
22
23- #copy over our index
24- shutil.copytree(self.working_dir + '/music_app/content/mediascanner',
25- mediascannerpath)
26-
27- logger.debug("Mediascanner database copied, files " + str(os.listdir(mediascannerpath)))
28-
29- #copy over the music
30+ #copy over the music and index
31 if os.path.exists(self.local_location):
32 shutil.copy(self.working_dir + '/music_app/content/'
33 +'1.ogg',
34@@ -111,6 +113,9 @@
35 shutil.copy(self.working_dir + '/music_app/content/'
36 +'2.ogg',
37 musicpath)
38+ shutil.copytree(self.working_dir + '/music_app/content/mediascanner',
39+ mediascannerpath)
40+
41 else:
42 shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'
43 +'1.ogg',
44@@ -118,8 +123,11 @@
45 shutil.copy('/usr/lib/python2.7/dist-packages/music_app/content/'
46 +'2.ogg',
47 musicpath)
48+ shutil.copytree('/usr/lib/python2.7/dist-packages/music_app/content/mediascanner',
49+ mediascannerpath)
50
51 logger.debug("Music copied, files " + str(os.listdir(musicpath)))
52+ logger.debug("Mediascanner database copied, files " + str(os.listdir(mediascannerpath)))
53
54 #do some inline db patching
55 #patch mediaindex to proper home
56
57=== modified file 'tests/autopilot/music_app/tests/test_music.py'
58--- tests/autopilot/music_app/tests/test_music.py 2013-10-01 19:26:29 +0000
59+++ tests/autopilot/music_app/tests/test_music.py 2013-10-02 20:57:26 +0000
60@@ -10,8 +10,7 @@
61 from __future__ import absolute_import
62
63 from autopilot.matchers import Eventually
64-from testtools.matchers import Equals
65-from testtools.matchers import Contains
66+from testtools.matchers import Equals, NotEquals
67
68 from music_app.tests import MusicTestCase
69
70@@ -22,15 +21,17 @@
71 """ tests if the music library is populated from our
72 fake mediascanner database"""
73
74+ self.assertThat(self.main_view.get_main_view, Eventually(NotEquals(None)))
75 mainView = self.main_view.get_main_view()
76 title = lambda: mainView.currentTracktitle
77 artist = lambda: mainView.currentArtist
78 self.assertThat(title, Eventually(Equals("Foss Yeaaaah! (Radio Edit)")))
79 self.assertThat(artist, Eventually(Equals("Benjamin Kerensa")))
80
81- def test_play(self):
82- """ Test Playing a track (Music Library must exist) """
83+ def test_play_pause(self):
84+ """ Test playing and pausing a track (Music Library must exist) """
85
86+ self.assertThat(self.main_view.get_play_button, Eventually(NotEquals(None)))
87 playbutton = self.main_view.get_play_button()
88 mainView = self.main_view.get_main_view()
89
90@@ -41,26 +42,14 @@
91 """ Track is playing"""
92 self.assertThat(mainView.isPlaying, Eventually(Equals(True)))
93
94- def test_pause(self):
95- """ Test Pausing a track (Music Library must exist) """
96-
97- playbutton = self.main_view.get_play_button()
98- mainView = self.main_view.get_main_view()
99-
100- """ Track is not playing"""
101- self.assertThat(mainView.isPlaying, Equals(False))
102- self.pointing_device.click_object(playbutton)
103-
104- """ Track is playing"""
105- self.assertThat(mainView.isPlaying, Eventually(Equals(True)))
106- self.pointing_device.click_object(playbutton)
107-
108- """ Track is not playing"""
109+ """ Track is not playing"""
110+ self.pointing_device.click_object(playbutton)
111 self.assertThat(mainView.isPlaying, Eventually(Equals(False)))
112
113 def test_next(self):
114 """ Test going to next track (Music Library must exist) """
115
116+ self.assertThat(self.main_view.get_forward_button, Eventually(NotEquals(None)))
117 forwardbutton = self.main_view.get_forward_button()
118 mainView = self.main_view.get_main_view()
119 title = lambda: mainView.currentTracktitle

Subscribers

People subscribed via source and target branches

to status/vote changes: