Merge lp:~nskaggs/music-app/drop-ap-mocking into lp:music-app/remix
- drop-ap-mocking
- Merge into remix
Proposed by
Nicholas Skaggs
Status: | Superseded |
---|---|
Proposed branch: | lp:~nskaggs/music-app/drop-ap-mocking |
Merge into: | lp:music-app/remix |
Diff against target: |
221 lines (+40/-106) 1 file modified
tests/autopilot/music_app/tests/__init__.py (+40/-106) |
To merge this branch: | bzr merge lp:~nskaggs/music-app/drop-ap-mocking |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Music App Developers | Pending | ||
Review via email: mp+241627@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-11-12.
Commit message
Drop AP mocking
Description of the change
Drop AP mocking
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:
Approve
(continuous-integration)
- 738. By Nicholas Skaggs
-
don't patch ms on devices
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:738
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
review:
Approve
(continuous-integration)
Unmerged revisions
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 2014-09-25 00:39:47 +0000 | |||
3 | +++ tests/autopilot/music_app/tests/__init__.py 2014-11-12 22:01:06 +0000 | |||
4 | @@ -1,9 +1,18 @@ | |||
5 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
11 | 2 | # Copyright 2013, 2014 Canonical | 2 | # |
12 | 3 | # | 3 | # Copyright (C) 2013, 2014 Canonical Ltd |
13 | 4 | # This program is free software: you can redistribute it and/or modify it | 4 | # |
14 | 5 | # under the terms of the GNU General Public License version 3, as published | 5 | # This program is free software: you can redistribute it and/or modify |
15 | 6 | # by the Free Software Foundation. | 6 | # it under the terms of the GNU General Public License version 3 as |
16 | 7 | # published by the Free Software Foundation. | ||
17 | 8 | # | ||
18 | 9 | # This program is distributed in the hope that it will be useful, | ||
19 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | 12 | # GNU General Public License for more details. | ||
22 | 13 | # | ||
23 | 14 | # You should have received a copy of the GNU General Public License | ||
24 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
25 | 7 | 16 | ||
26 | 8 | """Music app autopilot tests.""" | 17 | """Music app autopilot tests.""" |
27 | 9 | 18 | ||
28 | @@ -18,16 +27,10 @@ | |||
29 | 18 | from music_app import MusicApp | 27 | from music_app import MusicApp |
30 | 19 | 28 | ||
31 | 20 | from autopilot import logging as autopilot_logging | 29 | from autopilot import logging as autopilot_logging |
32 | 21 | from autopilot.input import Mouse, Touch | ||
33 | 22 | from autopilot.platform import model | ||
34 | 23 | from autopilot.testcase import AutopilotTestCase | 30 | from autopilot.testcase import AutopilotTestCase |
35 | 24 | 31 | ||
36 | 25 | import ubuntuuitoolkit | 32 | import ubuntuuitoolkit |
42 | 26 | from ubuntuuitoolkit import ( | 33 | from ubuntuuitoolkit import base |
38 | 27 | base, | ||
39 | 28 | fixture_setup as toolkit_fixtures | ||
40 | 29 | ) | ||
41 | 30 | |||
43 | 31 | 34 | ||
44 | 32 | logger = logging.getLogger(__name__) | 35 | logger = logging.getLogger(__name__) |
45 | 33 | 36 | ||
46 | @@ -38,10 +41,6 @@ | |||
47 | 38 | music-app tests. | 41 | music-app tests. |
48 | 39 | 42 | ||
49 | 40 | """ | 43 | """ |
50 | 41 | if model() == 'Desktop': | ||
51 | 42 | scenarios = [('with mouse', dict(input_device_class=Mouse))] | ||
52 | 43 | else: | ||
53 | 44 | scenarios = [('with touch', dict(input_device_class=Touch))] | ||
54 | 45 | 44 | ||
55 | 46 | working_dir = os.getcwd() | 45 | working_dir = os.getcwd() |
56 | 47 | local_location_dir = os.path.dirname(os.path.dirname(working_dir)) | 46 | local_location_dir = os.path.dirname(os.path.dirname(working_dir)) |
57 | @@ -62,10 +61,9 @@ | |||
58 | 62 | 61 | ||
59 | 63 | def setUp(self): | 62 | def setUp(self): |
60 | 64 | super(BaseTestCaseWithPatchedHome, self).setUp() | 63 | super(BaseTestCaseWithPatchedHome, self).setUp() |
65 | 65 | _, test_type = self.get_launcher_method_and_type() | 64 | self.launcher, self.test_type = self.get_launcher_method_and_type() |
66 | 66 | self.home_dir = self._patch_home(test_type) | 65 | self.home_dir = self._patch_home() |
67 | 67 | 66 | self._create_music_library() | |
64 | 68 | self._create_music_library(test_type) | ||
68 | 69 | 67 | ||
69 | 70 | @autopilot_logging.log_action(logger.info) | 68 | @autopilot_logging.log_action(logger.info) |
70 | 71 | def launch_test_local(self): | 69 | def launch_test_local(self): |
71 | @@ -108,63 +106,17 @@ | |||
72 | 108 | '.Xauthority')), | 106 | '.Xauthority')), |
73 | 109 | os.path.join(directory, '.Xauthority')) | 107 | os.path.join(directory, '.Xauthority')) |
74 | 110 | 108 | ||
76 | 111 | def _patch_home(self, test_type): | 109 | def _patch_home(self): |
77 | 112 | """ mock /home for testing purposes to preserve user data | 110 | """ mock /home for testing purposes to preserve user data |
78 | 113 | """ | 111 | """ |
79 | 114 | 112 | ||
133 | 115 | original_home = os.environ.get('HOME') | 113 | # if running on non-phablet device, |
134 | 116 | original_ual = os.environ.get('UBUNTU_APP_LAUNCH_LINK_FARM') | 114 | # run in temp folder to avoid mucking up home |
135 | 117 | 115 | # bug 1316746 | |
136 | 118 | # click requires apparmor profile, and writing to special dir | 116 | # bug 1376423 |
137 | 119 | # but the desktop can write to a traditional /tmp directory | 117 | if self.test_type is 'click': |
138 | 120 | if test_type == 'click': | 118 | # just use home for now on devices |
139 | 121 | env_dir = os.path.join(os.environ.get('HOME'), 'autopilot', | 119 | temp_dir = os.environ.get('HOME') |
87 | 122 | 'fakeenv') | ||
88 | 123 | |||
89 | 124 | if not os.path.exists(env_dir): | ||
90 | 125 | os.makedirs(env_dir) | ||
91 | 126 | |||
92 | 127 | temp_dir_fixture = fixtures.TempDir(env_dir) | ||
93 | 128 | self.useFixture(temp_dir_fixture) | ||
94 | 129 | |||
95 | 130 | # apparmor doesn't allow the app to create needed directories, | ||
96 | 131 | # so we create them now | ||
97 | 132 | temp_dir = temp_dir_fixture.path | ||
98 | 133 | temp_dir_cache = os.path.join(temp_dir, '.cache') | ||
99 | 134 | temp_dir_cache_font = os.path.join(temp_dir_cache, 'fontconfig') | ||
100 | 135 | temp_dir_cache_media = os.path.join(temp_dir_cache, 'media-art') | ||
101 | 136 | temp_dir_cache_write = os.path.join(temp_dir_cache, | ||
102 | 137 | 'tncache-write-text.null') | ||
103 | 138 | temp_dir_config = os.path.join(temp_dir, '.config') | ||
104 | 139 | temp_dir_toolkit = os.path.join(temp_dir_config, | ||
105 | 140 | 'ubuntu-ui-toolkit') | ||
106 | 141 | temp_dir_font = os.path.join(temp_dir_cache, '.fontconfig') | ||
107 | 142 | temp_dir_local = os.path.join(temp_dir, '.local', 'share') | ||
108 | 143 | temp_dir_confined = os.path.join(temp_dir, 'confined') | ||
109 | 144 | |||
110 | 145 | if not os.path.exists(temp_dir_cache): | ||
111 | 146 | os.makedirs(temp_dir_cache) | ||
112 | 147 | if not os.path.exists(temp_dir_cache_font): | ||
113 | 148 | os.makedirs(temp_dir_cache_font) | ||
114 | 149 | if not os.path.exists(temp_dir_cache_media): | ||
115 | 150 | os.makedirs(temp_dir_cache_media) | ||
116 | 151 | if not os.path.exists(temp_dir_cache_write): | ||
117 | 152 | os.makedirs(temp_dir_cache_write) | ||
118 | 153 | if not os.path.exists(temp_dir_config): | ||
119 | 154 | os.makedirs(temp_dir_config) | ||
120 | 155 | if not os.path.exists(temp_dir_toolkit): | ||
121 | 156 | os.makedirs(temp_dir_toolkit) | ||
122 | 157 | if not os.path.exists(temp_dir_font): | ||
123 | 158 | os.makedirs(temp_dir_font) | ||
124 | 159 | if not os.path.exists(temp_dir_local): | ||
125 | 160 | os.makedirs(temp_dir_local) | ||
126 | 161 | if not os.path.exists(temp_dir_confined): | ||
127 | 162 | os.makedirs(temp_dir_confined) | ||
128 | 163 | |||
129 | 164 | # before we set fixture, copy xauthority if needed | ||
130 | 165 | self._copy_xauthority_file(temp_dir) | ||
131 | 166 | self.useFixture(toolkit_fixtures.InitctlEnvironmentVariable( | ||
132 | 167 | HOME=temp_dir)) | ||
140 | 168 | else: | 120 | else: |
141 | 169 | temp_dir_fixture = fixtures.TempDir() | 121 | temp_dir_fixture = fixtures.TempDir() |
142 | 170 | self.useFixture(temp_dir_fixture) | 122 | self.useFixture(temp_dir_fixture) |
143 | @@ -175,29 +127,11 @@ | |||
144 | 175 | self.useFixture(fixtures.EnvironmentVariable('HOME', | 127 | self.useFixture(fixtures.EnvironmentVariable('HOME', |
145 | 176 | newvalue=temp_dir)) | 128 | newvalue=temp_dir)) |
146 | 177 | 129 | ||
166 | 178 | def undo_patch(key, value): | 130 | logger.debug("Patched home to fake home directory %s" % temp_dir) |
148 | 179 | logging.info( | ||
149 | 180 | "Resetting environment variable '%s' to '%s'", | ||
150 | 181 | key, | ||
151 | 182 | value | ||
152 | 183 | ) | ||
153 | 184 | |||
154 | 185 | os.environ[key] = value | ||
155 | 186 | |||
156 | 187 | # TODO: Remove code once pad.lv/1370800 is fixed | ||
157 | 188 | os.environ["HOME"] = temp_dir | ||
158 | 189 | os.environ["UBUNTU_APP_LAUNCH_LINK_FARM"] = original_home + "/.cache" \ | ||
159 | 190 | "/ubuntu-app-launch/desktop" | ||
160 | 191 | |||
161 | 192 | self.addCleanup(undo_patch, "HOME", original_home) | ||
162 | 193 | self.addCleanup(undo_patch, "UBUNTU_APP_LAUNCH_LINK_FARM", | ||
163 | 194 | original_ual or "") | ||
164 | 195 | |||
165 | 196 | logger.debug("Patched home to fake home directory %s" % temp_dir) | ||
167 | 197 | return temp_dir | 131 | return temp_dir |
168 | 198 | 132 | ||
171 | 199 | def _create_music_library(self, test_type): | 133 | def _create_music_library(self): |
172 | 200 | logger.debug("Creating music library for %s test" % test_type) | 134 | logger.debug("Creating music library for %s test" % self.test_type) |
173 | 201 | logger.debug("Home set to %s" % self.home_dir) | 135 | logger.debug("Home set to %s" % self.home_dir) |
174 | 202 | musicpath = os.path.join(self.home_dir, 'Music') | 136 | musicpath = os.path.join(self.home_dir, 'Music') |
175 | 203 | logger.debug("Music path set to %s" % musicpath) | 137 | logger.debug("Music path set to %s" % musicpath) |
176 | @@ -217,21 +151,18 @@ | |||
177 | 217 | shutil.copy(os.path.join(content_dir, '1.ogg'), musicpath) | 151 | shutil.copy(os.path.join(content_dir, '1.ogg'), musicpath) |
178 | 218 | shutil.copy(os.path.join(content_dir, '2.ogg'), musicpath) | 152 | shutil.copy(os.path.join(content_dir, '2.ogg'), musicpath) |
179 | 219 | shutil.copy(os.path.join(content_dir, '3.mp3'), musicpath) | 153 | shutil.copy(os.path.join(content_dir, '3.mp3'), musicpath) |
180 | 220 | shutil.copytree( | ||
181 | 221 | os.path.join(content_dir, 'mediascanner-2.0'), mediascannerpath) | ||
182 | 222 | 154 | ||
183 | 223 | logger.debug("Music copied, files " + str(os.listdir(musicpath))) | 155 | logger.debug("Music copied, files " + str(os.listdir(musicpath))) |
184 | 224 | 156 | ||
192 | 225 | self._patch_mediascanner_home(mediascannerpath) | 157 | if self.test_type is not 'click': |
193 | 226 | 158 | self._patch_mediascanner_home(content_dir, mediascannerpath) | |
194 | 227 | logger.debug( | 159 | |
195 | 228 | "Mediascanner database copied, files " + | 160 | def _patch_mediascanner_home(self, content_dir, mediascannerpath): |
189 | 229 | str(os.listdir(mediascannerpath))) | ||
190 | 230 | |||
191 | 231 | def _patch_mediascanner_home(self, mediascannerpath): | ||
196 | 232 | # do some inline db patching | 161 | # do some inline db patching |
197 | 233 | # patch mediaindex to proper home | 162 | # patch mediaindex to proper home |
198 | 234 | # these values are dependent upon our sampled db | 163 | # these values are dependent upon our sampled db |
199 | 164 | shutil.copytree( | ||
200 | 165 | os.path.join(content_dir, 'mediascanner-2.0'), mediascannerpath) | ||
201 | 235 | logger.debug("Patching fake mediascanner database in %s" % | 166 | logger.debug("Patching fake mediascanner database in %s" % |
202 | 236 | mediascannerpath) | 167 | mediascannerpath) |
203 | 237 | logger.debug( | 168 | logger.debug( |
204 | @@ -251,6 +182,10 @@ | |||
205 | 251 | cur.executescript(sql) | 182 | cur.executescript(sql) |
206 | 252 | con.close() | 183 | con.close() |
207 | 253 | 184 | ||
208 | 185 | logger.debug( | ||
209 | 186 | "Mediascanner database copied, files " + | ||
210 | 187 | str(os.listdir(mediascannerpath))) | ||
211 | 188 | |||
212 | 254 | def _file_find_replace(self, in_filename, find, replace): | 189 | def _file_find_replace(self, in_filename, find, replace): |
213 | 255 | # replace all occurences of string find with string replace | 190 | # replace all occurences of string find with string replace |
214 | 256 | # in the given file | 191 | # in the given file |
215 | @@ -273,5 +208,4 @@ | |||
216 | 273 | 208 | ||
217 | 274 | def setUp(self): | 209 | def setUp(self): |
218 | 275 | super(MusicAppTestCase, self).setUp() | 210 | super(MusicAppTestCase, self).setUp() |
221 | 276 | launcher_method, _ = self.get_launcher_method_and_type() | 211 | self.app = MusicApp(self.launcher()) |
220 | 277 | self.app = MusicApp(launcher_method()) |
PASSED: Continuous integration, rev:737 91.189. 93.70:8080/ job/music- app-remix- ci/256/ 91.189. 93.70:8080/ job/generic- mediumtests- vivid/182 91.189. 93.70:8080/ job/generic- mediumtests- vivid/182/ artifact/ work/output/ *zip*/output. zip 91.189. 93.70:8080/ job/music- app-remix- vivid-amd64- ci/31
http://
Executed test runs:
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.70:8080/ job/music- app-remix- ci/256/ rebuild
http://