Merge lp:~canonical-platform-qa/ubuntu-weather-app/fix1365279-setup_once into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Leo Arias
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 353
Merged at revision: 353
Proposed branch: lp:~canonical-platform-qa/ubuntu-weather-app/fix1365279-setup_once
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 230 lines (+71/-66)
3 files modified
po/com.ubuntu.weather.pot (+1/-1)
tests/autopilot/ubuntu_weather_app/tests/__init__.py (+3/-1)
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+67/-64)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-weather-app/fix1365279-setup_once
Reviewer Review Type Date Requested Status
Martin Borho Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Canonical Platform QA Team Pending
Review via email: mp+233305@code.launchpad.net

Commit message

Fixed the set up of the location tests.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

There are many things to fix on the weather tests. I'm ignoring all of them for now, as I just want the tests to start passing. I've added a TODO to clean things up after RTM.

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

Fixed pep8.

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
Martin Borho (martin-borho) wrote :

Looks good to me, thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'po/com.ubuntu.weather.pot'
2--- po/com.ubuntu.weather.pot 2014-08-16 17:45:06 +0000
3+++ po/com.ubuntu.weather.pot 2014-09-04 06:38:11 +0000
4@@ -8,7 +8,7 @@
5 msgstr ""
6 "Project-Id-Version: ubuntu-weather-app\n"
7 "Report-Msgid-Bugs-To: \n"
8-"POT-Creation-Date: 2014-08-16 12:44-0500\n"
9+"POT-Creation-Date: 2014-09-03 23:29-0600\n"
10 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
12 "Language-Team: LANGUAGE <LL@li.org>\n"
13
14=== modified file 'tests/autopilot/ubuntu_weather_app/tests/__init__.py'
15--- tests/autopilot/ubuntu_weather_app/tests/__init__.py 2014-06-26 09:29:19 +0000
16+++ tests/autopilot/ubuntu_weather_app/tests/__init__.py 2014-09-04 06:38:11 +0000
17@@ -43,11 +43,13 @@
18
19 local_location = "../../ubuntu-weather-app.qml"
20 installed_location = "/usr/share/ubuntu-weather-app/ubuntu-weather-app.qml"
21+ should_launch_app = True
22
23 def setUp(self):
24 super(WeatherTestCase, self).setUp()
25 self.pointing_device = Pointer(self.input_device_class.create())
26- self.launch_app()
27+ if self.should_launch_app:
28+ self.launch_app()
29
30 def launch_app(self):
31 if os.path.exists(self.local_location):
32
33=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
34--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2014-07-10 19:34:54 +0000
35+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2014-09-04 06:38:11 +0000
36@@ -27,29 +27,10 @@
37 logger = logging.getLogger(__name__)
38
39
40-class TestLocationManager(WeatherTestCase, DatabaseMixin, SheetMixin,
41- LocationManagerMixin):
42-
43- def setUp(self):
44- # we want to start with no database
45- self.clean_db()
46- super(TestLocationManager, self).setUp()
47- self.assertThat(
48- self.main_view.visible, Eventually(Equals(True)))
49-
50- def _preload_database_and_launch(self):
51- # we want to start with existing data
52- logger.debug("Closing app")
53- self.doCleanups()
54- # wipe the existing database and create a new blank one
55- self.create_blank_db()
56- # add locations to storage
57- logger.debug("Adding fake data to new database")
58- self.add_locations_to_database()
59- logger.debug("Re-Launching app to introspect")
60- super(TestLocationManager, self).setUp()
61- self.assertThat(
62- self.main_view.visible, Eventually(Equals(True)))
63+# FIXME Use fixtures instead of the complex multiple inheritance.
64+# --elopio - 2014-09-03
65+class BaseTestLocationManager(
66+ WeatherTestCase, DatabaseMixin, SheetMixin, LocationManagerMixin):
67
68 def _open_location_manager(self, kb=False):
69 """Opens the location manager"""
70@@ -81,6 +62,30 @@
71 "QQuickListView")
72 return qqlw.count
73
74+ def _add_location(self, location):
75+ self._open_add_location_page()
76+
77+ # insert city name to search for
78+ self._search_for_city(location)
79+
80+ # wait for results and click on the first item
81+ self.main_view.wait_for_activity_to_finish()
82+ resultsList = self.main_view.select_single(
83+ 'QQuickListView', objectName='SearchResultList')
84+ self.assertThat(resultsList.visible, Eventually(Equals(True)))
85+ firstResult = self.main_view.wait_select_single(
86+ 'Label', objectName='searchResult0')
87+ self.pointing_device.move_to_object(firstResult)
88+ self.pointing_device.click()
89+
90+ # LocationManagerPage should be visible and location added
91+ addedItem = self.main_view.wait_select_single('Label', text=location)
92+ self.assertThat(addedItem.text, Eventually(Equals(location)))
93+ self._click_sheet_confirm()
94+
95+ # back to locations, wait till data is loaded
96+ self.main_view.wait_for_activity_to_finish()
97+
98 def _search_for_city(self, city):
99 searchField = self.main_view.wait_select_single(
100 "TextField", objectName="SearchField")
101@@ -96,34 +101,15 @@
102 self.keyboard.press_and_release('Enter')
103 return searchField
104
105- def _add_location(self, location):
106- self._open_add_location_page()
107-
108- # insert city name to search for
109- self._search_for_city(location)
110-
111- # wait for results and click on the first item
112- self.main_view.wait_for_activity_to_finish()
113- resultsList = self.main_view.select_single(
114- 'QQuickListView', objectName='SearchResultList')
115- self.assertThat(resultsList.visible, Eventually(Equals(True)))
116- firstResult = self.main_view.wait_select_single(
117- 'Label', objectName='searchResult0')
118- self.pointing_device.move_to_object(firstResult)
119- self.pointing_device.click()
120-
121- # LocationManagerPage should be visible and location added
122- addedItem = self.main_view.wait_select_single('Label', text=location)
123- self.assertThat(addedItem.text, Eventually(Equals(location)))
124- self._click_sheet_confirm()
125-
126- # back to locations, wait till data is loaded
127- self.main_view.wait_for_activity_to_finish()
128-
129- def _remove_location(self):
130- self._open_location_manager()
131- self._swipe_first_location_to_remove()
132- self._click_sheet_confirm()
133+
134+class TestLocationManager(BaseTestLocationManager):
135+
136+ def setUp(self):
137+ # we want to start with no database
138+ self.clean_db()
139+ super(TestLocationManager, self).setUp()
140+ self.assertThat(
141+ self.main_view.visible, Eventually(Equals(True)))
142
143 def _verify_location(self, title, index):
144 location = self.main_view.wait_select_single(
145@@ -132,10 +118,6 @@
146 self.assertThat(location.index, Equals(index))
147 self.assertThat(location.visible, Equals(True))
148
149- def _wait_for_tab(self):
150- loadingPage = self.main_view.get_tabs()
151- self.assertThat(loadingPage.visible, Eventually(Equals(True)))
152-
153 def test_add_location(self):
154 """Adds a location"""
155
156@@ -257,10 +239,38 @@
157 # only location is there
158 self._verify_location(location_name, 0)
159
160+
161+class TestLocationManagerWithPreloadDatabase(BaseTestLocationManager):
162+
163+ should_launch_app = False
164+
165+ def setUp(self):
166+ # we want to start with no database
167+ super(TestLocationManagerWithPreloadDatabase, self).setUp()
168+ self._preload_database()
169+ self.launch_app()
170+ self.assertThat(
171+ self.main_view.visible, Eventually(Equals(True)))
172+
173+ def _preload_database(self):
174+ # wipe the existing database and create a new blank one
175+ self.create_blank_db()
176+ # add locations to storage
177+ logger.debug("Adding fake data to new database")
178+ self.add_locations_to_database()
179+ logger.debug("Re-Launching app to introspect")
180+
181+ def _remove_location(self):
182+ self._open_location_manager()
183+ self._swipe_first_location_to_remove()
184+ self._click_sheet_confirm()
185+
186+ def _wait_for_tab(self):
187+ loadingPage = self.main_view.get_tabs()
188+ self.assertThat(loadingPage.visible, Eventually(Equals(True)))
189+
190 def test_remove_location(self):
191 """Removes location"""
192- self._preload_database_and_launch()
193-
194 # wait till data is loaded
195 self._wait_for_tab()
196
197@@ -278,8 +288,6 @@
198
199 def test_cancel_remove_location(self):
200 """Cancels removing of location"""
201- self._preload_database_and_launch()
202-
203 # wait data is loaded
204 self._wait_for_tab()
205
206@@ -300,9 +308,6 @@
207 def test_del_add_bug(self):
208 """Tests if removing and add a location in one action works
209 https://bugs.launchpad.net/ubuntu-weather-app/+bug/1230297"""
210-
211- self._preload_database_and_launch()
212-
213 # remove a location
214 self._remove_location()
215
216@@ -324,7 +329,6 @@
217 def test_open_location_manager_keyboard(self):
218 if self.platform_model != "Desktop":
219 return
220- self._preload_database_and_launch()
221 self._open_location_manager(kb=True)
222
223 # close sheet by keyboard and test
224@@ -337,7 +341,6 @@
225 def test_add_location_keyboard(self):
226 if self.platform_model != "Desktop":
227 return
228- self._preload_database_and_launch()
229 self._open_location_manager(kb=True)
230 self._open_add_location_page()
231

Subscribers

People subscribed via source and target branches