Merge lp:~martin-borho/ubuntu-weather-app/lamda_asserts into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Merged
Approved by: Nicholas Skaggs
Approved revision: 95
Merged at revision: 94
Proposed branch: lp:~martin-borho/ubuntu-weather-app/lamda_asserts
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 239 lines (+31/-30)
3 files modified
tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py (+20/-20)
tests/autopilot/ubuntu_weather_app/tests/test_mainview.py (+3/-3)
tests/autopilot/ubuntu_weather_app/tests/test_settings.py (+8/-7)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/lamda_asserts
Reviewer Review Type Date Requested Status
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Nicholas Skaggs (community) Approve
Review via email: mp+180237@code.launchpad.net

Commit message

using lambda asserts on objects beforehand

Description of the change

using lambda asserts on objects beforehand

To post a comment you must log in.
Revision history for this message
Nicholas Skaggs (nskaggs) :
review: Approve
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
95. By Martin Borho

fix for swipe_to_delete gesture

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
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/ubuntu_weather_app/tests/test_locationmanager.py'
2--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-12 18:34:13 +0000
3+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-14 21:31:47 +0000
4@@ -9,7 +9,7 @@
5
6 from __future__ import absolute_import
7
8-from testtools.matchers import Equals, NotEquals
9+from testtools.matchers import Equals, NotEquals, Is, Not
10 from autopilot.matchers import Eventually
11
12 from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin
13@@ -26,8 +26,8 @@
14 self.get_qml_view().visible, Eventually(Equals(True)))
15
16 def search_for_city(self, city):
17+ self.assertThat(lambda: self.main_window.get_object('TextField', 'SearchField'), Eventually(Not(Is(None))))
18 searchField = self.main_window.get_object("TextField", "SearchField")
19- self.assertThat(lambda: searchField.visible, Eventually(Equals(True)))
20 #poll clicking for focus for lack of better method, due to screen switching animation
21 #is there a property we can use instead?
22 timeout = 0
23@@ -43,8 +43,8 @@
24 def _open_add_location_page(self):
25 """Opens the AddLocationPage"""
26 # click on listitem to open AddLocationPage
27+ self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
28 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
29- self.assertThat(lambda: locationList.visible, Eventually(Equals(True)))
30 addCityItem = locationList.get_children()[0]
31 self.assertThat(lambda: addCityItem.visible, Eventually(Equals(True)))
32 self.pointing_device.move_to_object(addCityItem)
33@@ -73,22 +73,22 @@
34 self.search_for_city("London")
35
36 # wait for results and click on the first item
37- http_failed = self.main_window.get_object('Dialog', 'HTTPFailedDialog')
38- self.assertThat(lambda: http_failed.visible, Eventually(NotEquals(True)))
39+ http_failed = lambda: self.main_window.get_object('Dialog', 'HTTPFailedDialog').visible
40+ self.assertThat(http_failed, Eventually(NotEquals(True)))
41 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
42 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
43 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
44 self.assertThat(resultsList.visible, Eventually(Equals(True)))
45+ self.assertThat(lambda: self.main_window.get_object('Standard', 'searchResult0'), Eventually(Not(Is(None))))
46 firstResult = self.main_window.get_object('Standard', 'searchResult0')
47- self.assertThat(lambda: firstResult, Eventually(NotEquals(None)))
48 self.pointing_device.move_to_object(firstResult)
49 self.pointing_device.click()
50
51 # LocationManagerPage should be visible and "London" added
52+ self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
53 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
54- self.assertThat(lambda: locationList, Eventually(NotEquals(None)))
55+ self.assertThat(lambda: self.main_window.get_object('Standard', 'existingLocation0'), Eventually(Not(Is(None))))
56 addedItem = self.main_window.get_object('Standard', "existingLocation0")
57- self.assertThat(lambda: addedItem, Eventually(NotEquals(None)))
58 self.assertThat(addedItem.text, Eventually(Equals("London")))
59 self._click_sheet_confirm()
60
61@@ -110,19 +110,19 @@
62 searchField = self.search_for_city("London")
63
64 # wait for results and click on the first item
65- http_failed = self.main_window.get_object('Dialog', 'HTTPFailedDialog')
66- self.assertThat(lambda: http_failed.visible, Eventually(NotEquals(True)))
67+ http_failed = lambda: self.main_window.get_object('Dialog', 'HTTPFailedDialog').visible
68+ self.assertThat(http_failed, Eventually(NotEquals(True)))
69 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
70 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
71 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
72 self.assertThat(resultsList.visible, Eventually(Equals(True)))
73+ self.assertThat(lambda: self.main_window.get_object('Standard', 'searchResult0'), Eventually(Not(Is(None))))
74 firstResult = self.select_single_retry("Standard", objectName="searchResult0")
75- self.assertThat(lambda: firstResult, Eventually(NotEquals(None)))
76- self.assertThat(firstResult.text, Eventually(Equals("London, GB")))
77+ self.assertThat(firstResult.text, Eventually(Equals("London, United Kingdom")))
78
79 # clear search field and do another search
80+ self.assertThat(lambda: self.main_window.select_single('AbstractButton'), Eventually(Not(Is(None))))
81 clear_button = searchField.select_single("AbstractButton")
82- self.assertThat(lambda: clear_button, Eventually(NotEquals(None)))
83 self.pointing_device.click_object(clear_button)
84 self.assertThat(searchField.text, Eventually(Equals("")))
85
86@@ -132,14 +132,15 @@
87 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
88 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
89 self.assertThat(resultsList.visible, Eventually(Equals(True)))
90+ self.assertThat(lambda: self.main_window.get_object('Standard', 'searchResult0'), Eventually(Not(Is(None))))
91 firstResult = self.select_single_retry("Standard", objectName="searchResult0")
92- self.assertThat(lambda: firstResult, Eventually(NotEquals(None)))
93- self.assertThat(firstResult.text, Eventually(Equals("Hamburg, DE")))
94+ self.assertThat(firstResult.text, Eventually(Equals("Hamburg, Germany")))
95
96 def test_cancel_adding_location(self):
97 """Cancel the cities search"""
98 self._open_add_location_page()
99 self._click_sheet_cancel()
100+ self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
101 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
102 self.assertThat(locationList.visible, Eventually(Equals(True)))
103
104@@ -151,8 +152,8 @@
105 self.search_for_city("UbuntuCity")
106
107 # wait for result and look if label is shown
108- http_failed = self.main_window.get_object('Dialog', 'HTTPFailedDialog')
109- self.assertThat(lambda: http_failed.visible, Eventually(NotEquals(True)))
110+ http_failed = lambda: self.main_window.get_object('Dialog', 'HTTPFailedDialog').visible
111+ self.assertThat(http_failed, Eventually(NotEquals(True)))
112 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
113 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
114 errorLabel = self.main_window.get_object('Label', 'noCityError')
115@@ -176,14 +177,13 @@
116 def _swipe_location_to_remove(self):
117 """Swipe right to delete the first location"""
118 number_of_locations = self._get_number_of_locations()
119+ self.assertThat(lambda: self.app.select_single('Standard', objectName='existingLocation0'), Eventually(Not(Is(None))))
120 firstLocation = self.app.select_single("Standard", objectName="existingLocation0")
121- self.assertThat(lambda: firstLocation, Eventually(NotEquals(None)))
122
123 x, y, w, h = firstLocation.globalRect
124 tx = x + (w / 8)
125 ty = y + (h / 2)
126-
127- self.pointing_device.drag(tx, ty, w - (w / 8), ty)
128+ self.pointing_device.drag(tx, ty, tx + (w - w / 8), ty)
129 self.assertThat(
130 self._get_number_of_locations(),
131 Eventually(Equals(number_of_locations-1)))
132
133=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
134--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-13 04:56:41 +0000
135+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-14 21:31:47 +0000
136@@ -11,7 +11,7 @@
137
138 from __future__ import absolute_import
139
140-from testtools.matchers import NotEquals, Equals
141+from testtools.matchers import NotEquals, Equals, Is, Not
142 from autopilot.matchers import Eventually
143
144 import unittest
145@@ -56,8 +56,8 @@
146
147 def test_refresh_tabs(self):
148 # get the dates from the test data
149+ self.assertThat(lambda: self.main_window.get_objects('Label', 'DayDateLabel'), Eventually(Not(Is(None))))
150 curr_dates = self.main_window.get_objects('Label','DayDateLabel')
151- self.assertThat(lambda: curr_dates, Eventually(NotEquals(None)))
152 tab1_curr_date = curr_dates[0].text
153 tab2_curr_date = curr_dates[2].text
154
155@@ -67,7 +67,7 @@
156 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
157
158 # get the data from the refreshed tabs, have to be new
159+ self.assertThat(lambda: self.main_window.get_objects('Label', 'DayDateLabel'), Eventually(Not(Is(None))))
160 refreshed_dates = self.main_window.get_objects('Label','DayDateLabel')
161- self.assertThat(lambda: refreshed_dates, Eventually(NotEquals(None)))
162 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)
163 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)
164
165=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
166--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-08-08 19:55:17 +0000
167+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-08-14 21:31:47 +0000
168@@ -9,7 +9,7 @@
169
170 from __future__ import absolute_import
171
172-from testtools.matchers import Equals, NotEquals
173+from testtools.matchers import Equals, NotEquals, Is, Not
174 from autopilot.matchers import Eventually
175
176 from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin
177@@ -30,8 +30,8 @@
178
179 def _move_pointer_around(self):
180 """Helper method to move the pointer around, to assure selector is opened"""
181+ self.assertThat(lambda: self.main_window.get_object('ComposerSheet', 'SettingsSheet'), Eventually(Not(Is(None))))
182 sheet = self.main_window.get_object('ComposerSheet', 'SettingsSheet')
183- self.assertThat(lambda: sheet, Eventually(NotEquals(None)))
184 self.pointing_device.move_to_object(sheet)
185
186 def _check_units(self, units):
187@@ -51,14 +51,15 @@
188 self._open_settings_sheet()
189
190 # open the value selector
191+ self.assertThat(lambda: self.main_window.get_object('ValueSelector', 'UnitsSelector'), Eventually(Not(Is(None))))
192 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
193 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
194 self.pointing_device.click_object(units_selector)
195
196 # choose second option, fahrenheit
197 self._move_pointer_around()
198+ self.assertThat(lambda: units_selector.get_children()[3], Eventually(Not(Is(None))))
199 imperial_option = units_selector.get_children()[3]
200- self.assertThat(lambda: imperial_option, Eventually(NotEquals(None)))
201 self.pointing_device.click_object(imperial_option)
202 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
203 self._click_sheet_confirm()
204@@ -70,16 +71,16 @@
205
206 # switch back to metric values again
207 self._open_settings_sheet()
208+ self.assertThat(lambda: self.main_window.get_object('ValueSelector', 'UnitsSelector'), Eventually(Not(Is(None))))
209 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
210- self.assertThat(lambda: units_selector, Eventually(NotEquals(None)))
211 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
212 self.pointing_device.click_object(units_selector)
213 self.assertThat(units_selector.expanded, Eventually(Equals(True)))
214
215 # click celsius option
216 self._move_pointer_around()
217+ self.assertThat(lambda: units_selector.get_children()[4], Eventually(Not(Is(None))))
218 metric_option = units_selector.get_children()[4]
219- self.assertThat(lambda: metric_option, Eventually(NotEquals(None)))
220 self.pointing_device.click_object(metric_option)
221
222 # confirm
223@@ -97,15 +98,15 @@
224 self._check_units('metric')
225 self._open_settings_sheet()
226
227+ self.assertThat(lambda: self.main_window.get_object('ValueSelector', 'UnitsSelector'), Eventually(Not(Is(None))))
228 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
229- self.assertThat(lambda: units_selector, Eventually(NotEquals(None)))
230 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
231 self.pointing_device.click_object(units_selector)
232
233 # choose second option, fahrenheit
234 self._move_pointer_around()
235+ self.assertThat(lambda: units_selector.get_children()[3], Eventually(Not(Is(None))))
236 imperial_option = units_selector.get_children()[3]
237- self.assertThat(lambda: imperial_option, Eventually(NotEquals(None)))
238 self.pointing_device.click_object(imperial_option)
239 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
240

Subscribers

People subscribed via source and target branches