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
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-12 18:34:13 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_locationmanager.py 2013-08-14 21:31:47 +0000
@@ -9,7 +9,7 @@
99
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12from testtools.matchers import Equals, NotEquals12from testtools.matchers import Equals, NotEquals, Is, Not
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1414
15from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin15from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin
@@ -26,8 +26,8 @@
26 self.get_qml_view().visible, Eventually(Equals(True)))26 self.get_qml_view().visible, Eventually(Equals(True)))
2727
28 def search_for_city(self, city):28 def search_for_city(self, city):
29 self.assertThat(lambda: self.main_window.get_object('TextField', 'SearchField'), Eventually(Not(Is(None))))
29 searchField = self.main_window.get_object("TextField", "SearchField")30 searchField = self.main_window.get_object("TextField", "SearchField")
30 self.assertThat(lambda: searchField.visible, Eventually(Equals(True)))
31 #poll clicking for focus for lack of better method, due to screen switching animation31 #poll clicking for focus for lack of better method, due to screen switching animation
32 #is there a property we can use instead?32 #is there a property we can use instead?
33 timeout = 033 timeout = 0
@@ -43,8 +43,8 @@
43 def _open_add_location_page(self):43 def _open_add_location_page(self):
44 """Opens the AddLocationPage"""44 """Opens the AddLocationPage"""
45 # click on listitem to open AddLocationPage45 # click on listitem to open AddLocationPage
46 self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
46 locationList = self.main_window.get_object('QQuickListView', 'LocationList')47 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
47 self.assertThat(lambda: locationList.visible, Eventually(Equals(True)))
48 addCityItem = locationList.get_children()[0]48 addCityItem = locationList.get_children()[0]
49 self.assertThat(lambda: addCityItem.visible, Eventually(Equals(True)))49 self.assertThat(lambda: addCityItem.visible, Eventually(Equals(True)))
50 self.pointing_device.move_to_object(addCityItem)50 self.pointing_device.move_to_object(addCityItem)
@@ -73,22 +73,22 @@
73 self.search_for_city("London")73 self.search_for_city("London")
7474
75 # wait for results and click on the first item75 # wait for results and click on the first item
76 http_failed = self.main_window.get_object('Dialog', 'HTTPFailedDialog')76 http_failed = lambda: self.main_window.get_object('Dialog', 'HTTPFailedDialog').visible
77 self.assertThat(lambda: http_failed.visible, Eventually(NotEquals(True)))77 self.assertThat(http_failed, Eventually(NotEquals(True)))
78 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')78 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
79 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))79 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
80 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')80 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
81 self.assertThat(resultsList.visible, Eventually(Equals(True)))81 self.assertThat(resultsList.visible, Eventually(Equals(True)))
82 self.assertThat(lambda: self.main_window.get_object('Standard', 'searchResult0'), Eventually(Not(Is(None))))
82 firstResult = self.main_window.get_object('Standard', 'searchResult0')83 firstResult = self.main_window.get_object('Standard', 'searchResult0')
83 self.assertThat(lambda: firstResult, Eventually(NotEquals(None)))
84 self.pointing_device.move_to_object(firstResult)84 self.pointing_device.move_to_object(firstResult)
85 self.pointing_device.click()85 self.pointing_device.click()
8686
87 # LocationManagerPage should be visible and "London" added87 # LocationManagerPage should be visible and "London" added
88 self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
88 locationList = self.main_window.get_object('QQuickListView', 'LocationList')89 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
89 self.assertThat(lambda: locationList, Eventually(NotEquals(None)))90 self.assertThat(lambda: self.main_window.get_object('Standard', 'existingLocation0'), Eventually(Not(Is(None))))
90 addedItem = self.main_window.get_object('Standard', "existingLocation0")91 addedItem = self.main_window.get_object('Standard', "existingLocation0")
91 self.assertThat(lambda: addedItem, Eventually(NotEquals(None)))
92 self.assertThat(addedItem.text, Eventually(Equals("London")))92 self.assertThat(addedItem.text, Eventually(Equals("London")))
93 self._click_sheet_confirm()93 self._click_sheet_confirm()
9494
@@ -110,19 +110,19 @@
110 searchField = self.search_for_city("London")110 searchField = self.search_for_city("London")
111111
112 # wait for results and click on the first item112 # wait for results and click on the first item
113 http_failed = self.main_window.get_object('Dialog', 'HTTPFailedDialog')113 http_failed = lambda: self.main_window.get_object('Dialog', 'HTTPFailedDialog').visible
114 self.assertThat(lambda: http_failed.visible, Eventually(NotEquals(True)))114 self.assertThat(http_failed, Eventually(NotEquals(True)))
115 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')115 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
116 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))116 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
117 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')117 resultsList = self.main_window.get_object('QQuickListView', 'SearchResultList')
118 self.assertThat(resultsList.visible, Eventually(Equals(True)))118 self.assertThat(resultsList.visible, Eventually(Equals(True)))
119 self.assertThat(lambda: self.main_window.get_object('Standard', 'searchResult0'), Eventually(Not(Is(None))))
119 firstResult = self.select_single_retry("Standard", objectName="searchResult0")120 firstResult = self.select_single_retry("Standard", objectName="searchResult0")
120 self.assertThat(lambda: firstResult, Eventually(NotEquals(None)))121 self.assertThat(firstResult.text, Eventually(Equals("London, United Kingdom")))
121 self.assertThat(firstResult.text, Eventually(Equals("London, GB")))
122122
123 # clear search field and do another search123 # clear search field and do another search
124 self.assertThat(lambda: self.main_window.select_single('AbstractButton'), Eventually(Not(Is(None))))
124 clear_button = searchField.select_single("AbstractButton")125 clear_button = searchField.select_single("AbstractButton")
125 self.assertThat(lambda: clear_button, Eventually(NotEquals(None)))
126 self.pointing_device.click_object(clear_button)126 self.pointing_device.click_object(clear_button)
127 self.assertThat(searchField.text, Eventually(Equals("")))127 self.assertThat(searchField.text, Eventually(Equals("")))
128128
@@ -132,14 +132,15 @@
132 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')132 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
133 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))133 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
134 self.assertThat(resultsList.visible, Eventually(Equals(True)))134 self.assertThat(resultsList.visible, Eventually(Equals(True)))
135 self.assertThat(lambda: self.main_window.get_object('Standard', 'searchResult0'), Eventually(Not(Is(None))))
135 firstResult = self.select_single_retry("Standard", objectName="searchResult0")136 firstResult = self.select_single_retry("Standard", objectName="searchResult0")
136 self.assertThat(lambda: firstResult, Eventually(NotEquals(None)))137 self.assertThat(firstResult.text, Eventually(Equals("Hamburg, Germany")))
137 self.assertThat(firstResult.text, Eventually(Equals("Hamburg, DE")))
138138
139 def test_cancel_adding_location(self):139 def test_cancel_adding_location(self):
140 """Cancel the cities search"""140 """Cancel the cities search"""
141 self._open_add_location_page()141 self._open_add_location_page()
142 self._click_sheet_cancel()142 self._click_sheet_cancel()
143 self.assertThat(lambda: self.main_window.get_object('QQuickListView', 'LocationList'), Eventually(Not(Is(None))))
143 locationList = self.main_window.get_object('QQuickListView', 'LocationList')144 locationList = self.main_window.get_object('QQuickListView', 'LocationList')
144 self.assertThat(locationList.visible, Eventually(Equals(True)))145 self.assertThat(locationList.visible, Eventually(Equals(True)))
145146
@@ -151,8 +152,8 @@
151 self.search_for_city("UbuntuCity")152 self.search_for_city("UbuntuCity")
152153
153 # wait for result and look if label is shown154 # wait for result and look if label is shown
154 http_failed = self.main_window.get_object('Dialog', 'HTTPFailedDialog')155 http_failed = lambda: self.main_window.get_object('Dialog', 'HTTPFailedDialog').visible
155 self.assertThat(lambda: http_failed.visible, Eventually(NotEquals(True)))156 self.assertThat(http_failed, Eventually(NotEquals(True)))
156 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')157 load_indicator = self.main_window.get_object('ActivityIndicator', 'SearchingSpinner')
157 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))158 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
158 errorLabel = self.main_window.get_object('Label', 'noCityError')159 errorLabel = self.main_window.get_object('Label', 'noCityError')
@@ -176,14 +177,13 @@
176 def _swipe_location_to_remove(self):177 def _swipe_location_to_remove(self):
177 """Swipe right to delete the first location"""178 """Swipe right to delete the first location"""
178 number_of_locations = self._get_number_of_locations()179 number_of_locations = self._get_number_of_locations()
180 self.assertThat(lambda: self.app.select_single('Standard', objectName='existingLocation0'), Eventually(Not(Is(None))))
179 firstLocation = self.app.select_single("Standard", objectName="existingLocation0")181 firstLocation = self.app.select_single("Standard", objectName="existingLocation0")
180 self.assertThat(lambda: firstLocation, Eventually(NotEquals(None)))
181182
182 x, y, w, h = firstLocation.globalRect183 x, y, w, h = firstLocation.globalRect
183 tx = x + (w / 8)184 tx = x + (w / 8)
184 ty = y + (h / 2)185 ty = y + (h / 2)
185186 self.pointing_device.drag(tx, ty, tx + (w - w / 8), ty)
186 self.pointing_device.drag(tx, ty, w - (w / 8), ty)
187 self.assertThat(187 self.assertThat(
188 self._get_number_of_locations(),188 self._get_number_of_locations(),
189 Eventually(Equals(number_of_locations-1)))189 Eventually(Equals(number_of_locations-1)))
190190
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_mainview.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-13 04:56:41 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_mainview.py 2013-08-14 21:31:47 +0000
@@ -11,7 +11,7 @@
1111
12from __future__ import absolute_import12from __future__ import absolute_import
1313
14from testtools.matchers import NotEquals, Equals14from testtools.matchers import NotEquals, Equals, Is, Not
15from autopilot.matchers import Eventually15from autopilot.matchers import Eventually
1616
17import unittest17import unittest
@@ -56,8 +56,8 @@
5656
57 def test_refresh_tabs(self):57 def test_refresh_tabs(self):
58 # get the dates from the test data58 # get the dates from the test data
59 self.assertThat(lambda: self.main_window.get_objects('Label', 'DayDateLabel'), Eventually(Not(Is(None))))
59 curr_dates = self.main_window.get_objects('Label','DayDateLabel')60 curr_dates = self.main_window.get_objects('Label','DayDateLabel')
60 self.assertThat(lambda: curr_dates, Eventually(NotEquals(None)))
61 tab1_curr_date = curr_dates[0].text61 tab1_curr_date = curr_dates[0].text
62 tab2_curr_date = curr_dates[2].text62 tab2_curr_date = curr_dates[2].text
6363
@@ -67,7 +67,7 @@
67 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))67 self.assertThat(load_indicator.running, Eventually(Equals(False), timeout=120))
6868
69 # get the data from the refreshed tabs, have to be new69 # get the data from the refreshed tabs, have to be new
70 self.assertThat(lambda: self.main_window.get_objects('Label', 'DayDateLabel'), Eventually(Not(Is(None))))
70 refreshed_dates = self.main_window.get_objects('Label','DayDateLabel')71 refreshed_dates = self.main_window.get_objects('Label','DayDateLabel')
71 self.assertThat(lambda: refreshed_dates, Eventually(NotEquals(None)))
72 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)72 self.assertNotEqual(tab1_curr_date, refreshed_dates[0].text)
73 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)73 self.assertNotEqual(tab2_curr_date, refreshed_dates[2].text)
7474
=== modified file 'tests/autopilot/ubuntu_weather_app/tests/test_settings.py'
--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-08-08 19:55:17 +0000
+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2013-08-14 21:31:47 +0000
@@ -9,7 +9,7 @@
99
10from __future__ import absolute_import10from __future__ import absolute_import
1111
12from testtools.matchers import Equals, NotEquals12from testtools.matchers import Equals, NotEquals, Is, Not
13from autopilot.matchers import Eventually13from autopilot.matchers import Eventually
1414
15from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin15from ubuntu_weather_app.tests import WeatherTestCase, DatabaseMixin, SheetMixin
@@ -30,8 +30,8 @@
3030
31 def _move_pointer_around(self):31 def _move_pointer_around(self):
32 """Helper method to move the pointer around, to assure selector is opened"""32 """Helper method to move the pointer around, to assure selector is opened"""
33 self.assertThat(lambda: self.main_window.get_object('ComposerSheet', 'SettingsSheet'), Eventually(Not(Is(None))))
33 sheet = self.main_window.get_object('ComposerSheet', 'SettingsSheet')34 sheet = self.main_window.get_object('ComposerSheet', 'SettingsSheet')
34 self.assertThat(lambda: sheet, Eventually(NotEquals(None)))
35 self.pointing_device.move_to_object(sheet)35 self.pointing_device.move_to_object(sheet)
3636
37 def _check_units(self, units):37 def _check_units(self, units):
@@ -51,14 +51,15 @@
51 self._open_settings_sheet()51 self._open_settings_sheet()
5252
53 # open the value selector53 # open the value selector
54 self.assertThat(lambda: self.main_window.get_object('ValueSelector', 'UnitsSelector'), Eventually(Not(Is(None))))
54 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")55 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
55 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))56 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
56 self.pointing_device.click_object(units_selector)57 self.pointing_device.click_object(units_selector)
5758
58 # choose second option, fahrenheit59 # choose second option, fahrenheit
59 self._move_pointer_around()60 self._move_pointer_around()
61 self.assertThat(lambda: units_selector.get_children()[3], Eventually(Not(Is(None))))
60 imperial_option = units_selector.get_children()[3]62 imperial_option = units_selector.get_children()[3]
61 self.assertThat(lambda: imperial_option, Eventually(NotEquals(None)))
62 self.pointing_device.click_object(imperial_option)63 self.pointing_device.click_object(imperial_option)
63 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))64 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
64 self._click_sheet_confirm()65 self._click_sheet_confirm()
@@ -70,16 +71,16 @@
7071
71 # switch back to metric values again72 # switch back to metric values again
72 self._open_settings_sheet()73 self._open_settings_sheet()
74 self.assertThat(lambda: self.main_window.get_object('ValueSelector', 'UnitsSelector'), Eventually(Not(Is(None))))
73 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")75 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
74 self.assertThat(lambda: units_selector, Eventually(NotEquals(None)))
75 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))76 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
76 self.pointing_device.click_object(units_selector)77 self.pointing_device.click_object(units_selector)
77 self.assertThat(units_selector.expanded, Eventually(Equals(True)))78 self.assertThat(units_selector.expanded, Eventually(Equals(True)))
7879
79 # click celsius option80 # click celsius option
80 self._move_pointer_around()81 self._move_pointer_around()
82 self.assertThat(lambda: units_selector.get_children()[4], Eventually(Not(Is(None))))
81 metric_option = units_selector.get_children()[4]83 metric_option = units_selector.get_children()[4]
82 self.assertThat(lambda: metric_option, Eventually(NotEquals(None)))
83 self.pointing_device.click_object(metric_option)84 self.pointing_device.click_object(metric_option)
8485
85 # confirm86 # confirm
@@ -97,15 +98,15 @@
97 self._check_units('metric')98 self._check_units('metric')
98 self._open_settings_sheet()99 self._open_settings_sheet()
99100
101 self.assertThat(lambda: self.main_window.get_object('ValueSelector', 'UnitsSelector'), Eventually(Not(Is(None))))
100 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")102 units_selector = self.main_window.get_object('ValueSelector', "UnitsSelector")
101 self.assertThat(lambda: units_selector, Eventually(NotEquals(None)))
102 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))103 self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
103 self.pointing_device.click_object(units_selector)104 self.pointing_device.click_object(units_selector)
104105
105 # choose second option, fahrenheit106 # choose second option, fahrenheit
106 self._move_pointer_around()107 self._move_pointer_around()
108 self.assertThat(lambda: units_selector.get_children()[3], Eventually(Not(Is(None))))
107 imperial_option = units_selector.get_children()[3]109 imperial_option = units_selector.get_children()[3]
108 self.assertThat(lambda: imperial_option, Eventually(NotEquals(None)))
109 self.pointing_device.click_object(imperial_option)110 self.pointing_device.click_object(imperial_option)
110 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))111 self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
111112

Subscribers

People subscribed via source and target branches