Merge lp:~martin-borho/ubuntu-weather-app/fix-1320193-optionselector-helper into lp:ubuntu-weather-app/obsolete.trunk

Proposed by Martin Borho
Status: Merged
Approved by: Alan Pope 🍺🐧🐱 πŸ¦„
Approved revision: 259
Merged at revision: 266
Proposed branch: lp:~martin-borho/ubuntu-weather-app/fix-1320193-optionselector-helper
Merge into: lp:ubuntu-weather-app/obsolete.trunk
Diff against target: 456 lines (+49/-284)
1 file modified
tests/autopilot/ubuntu_weather_app/tests/test_settings.py (+49/-284)
To merge this branch: bzr merge lp:~martin-borho/ubuntu-weather-app/fix-1320193-optionselector-helper
Reviewer Review Type Date Requested Status
Nicholas Skaggs (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+219941@code.launchpad.net

Commit message

Using new optionselector helper in autopilot tests, fixes Bug #1320193

Description of the change

Using new optionselector helper in autopilot tests, fixes Bug #1320193

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)
Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Martin, can you ensure this is pep8/pyflakes compatible? This merge fixes the entire testsuite to be compatible;

https://code.launchpad.net/~nik90/ubuntu-weather-app/fix-pep8-errors/+merge/220098

Revision history for this message
Nicholas Skaggs (nskaggs) wrote :

Martin, the code inside _get_selector is no longer needed.

In general you don't need to assert to ensure the object exists anymore. The sdk helper should take care of this for you. If you need to ensure the object exists (so your select doesn't fail), autopilot has a wait_select_single function. http://unity.ubuntu.com/autopilot/porting/porting.html?highlight=wait_select_single#id5
http://unity.ubuntu.com/autopilot/api/introspection.html?highlight=wait_select_single#autopilot.introspection.dbus.DBusIntrospectionObject.wait_select_single

This assert is also redundant; self.assertThat(units_selector.get_selected_index(), Eventually(Equals(0))). The sdk helper should always return properly.

I also don't think I would assert on the index returned. The test shouldn't be worrying about the index (it might change), but rather the point of the test (test a setting change, etc).

Overall, this should clean-up a lot of the extra testcode.

review: Needs Fixing
Revision history for this message
Martin Borho (martin-borho) wrote :

Thanks Nicholas, good to know!

Will clean it up, and will have a look where wait_select_single would be handy too!

253. By Martin Borho

merged from trunk

254. By Martin Borho

making use of wait_select_single in test_settings

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

small change to retrigger jenkins

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
Nicholas Skaggs (nskaggs) wrote :

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ubuntu_weather_app/tests/test_locationmanager.py", line 203, in test_search_city
    "Label", objectName="searchResult0")
  File "/usr/lib/python2.7/dist-packages/autopilot/introspection/dbus.py", line 375, in wait_select_single
    return self.select_single(type_name, **kwargs)
  File "/usr/lib/python2.7/dist-packages/autopilot/introspection/dbus.py", line 324, in select_single
    raise StateNotFoundError(type_name, **kwargs)
StateNotFoundError: Object not found with name 'Label' and properties {'objectName': 'searchResult0'}.

^^ Need help with this Martin or ?

Revision history for this message
Martin Borho (martin-borho) wrote :

Hmm, haven't touched that test, thought it looks like a network issue.

https://code.launchpad.net/~martin-borho/ubuntu-weather-app/fix-1324578-optionselectors-xlated should be merged first, so the pep8 errors on amd64 will be fixed.

256. By Martin Borho

rebased on trunk

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

pep8

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

pleasing pyflakes too

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

retrigger

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
Nicholas Skaggs (nskaggs) wrote :

Consider the inline comments, but overall excellent work. This is both more readable and more maintainable. Helpers are wonderful things!

review: Approve

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_settings.py'
2--- tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2014-05-19 16:05:56 +0000
3+++ tests/autopilot/ubuntu_weather_app/tests/test_settings.py 2014-06-05 17:54:38 +0000
4@@ -1,5 +1,5 @@
5 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6-# Copyright 2013 Canonical
7+# Copyright 2013, 2014 Canonical
8 #
9 # This program is free software: you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License version 3, as published
11@@ -8,8 +8,6 @@
12 """Tests for managing locations in Weather app"""
13
14 from __future__ import absolute_import
15-
16-from unittest import skip
17 from testtools.matchers import Equals, Is, Not
18 from autopilot.matchers import Eventually
19 import logging
20@@ -38,11 +36,8 @@
21 """
22 Helper method to move the pointer around, to assure selector is opened
23 """
24- self.assertThat(lambda: self.main_view.select_single(
25- 'ComposerSheet', objectName='SettingsSheet'),
26- Eventually(Not(Is(None))))
27- sheet = self.main_view.select_single('ComposerSheet',
28- objectName='SettingsSheet')
29+ sheet = self.main_view.wait_select_single('ComposerSheet',
30+ objectName='SettingsSheet')
31 self.pointing_device.move_to_object(sheet)
32
33 def _check_units(self, units):
34@@ -80,21 +75,15 @@
35 self.assertThat(lambda: self.main_view.select_many(
36 'WeatherDetailComponent', objectName='WindSpeedValue')[0],
37 Eventually(Not(Is(None))))
38- current_location_tab = self.main_view.select_single(
39+ current_location_tab = self.main_view.wait_select_single(
40 'LocationTab', visible=True)
41- focused_item = current_location_tab.select_single(
42+ focused_item = current_location_tab.wait_select_single(
43 'QQuickItem', focus=True)
44- wind_component = focused_item.select_single(
45+ wind_component = focused_item.wait_select_single(
46 'WeatherDetailComponent', objectName='WindSpeedValue')
47- self.assertThat(lambda: wind_component.select_single(
48- 'Label', objectName='WeatherDetailUnit'),
49- Eventually(Not(Is(None))))
50- wind_unit = wind_component.select_single(
51+ wind_unit = wind_component.wait_select_single(
52 'Label', objectName='WeatherDetailUnit')
53- self.assertThat(lambda: wind_component.select_single(
54- 'QQuickText', objectName='WeatherDetailValue'),
55- Eventually(Not(Is(None))))
56- wind_value = wind_component.select_single(
57+ wind_value = wind_component.wait_select_single(
58 'QQuickText', objectName='WeatherDetailValue')
59 if wind_units == "mph":
60 self.assertThat(wind_unit.text, Eventually(Equals(u'mph W')))
61@@ -110,22 +99,16 @@
62 self.assertThat(lambda: self.main_view.select_many(
63 'WeatherDetailComponent', objectName='PrecipitationValue')[0],
64 Eventually(Not(Is(None))))
65- current_location_tab = self.main_view.select_single(
66+ current_location_tab = self.main_view.wait_select_single(
67 'LocationTab', visible=True)
68- focused_item = current_location_tab.select_single(
69+ focused_item = current_location_tab.wait_select_single(
70 'QQuickItem', focus=True)
71- component = focused_item.select_single(
72+ component = focused_item.wait_select_single(
73 'WeatherDetailComponent', objectName='PrecipitationValue')
74- self.assertThat(lambda: component.select_many(
75- 'QQuickText', objectName='WeatherDetailUnit'),
76- Eventually(Not(Is(None))))
77- unit = component.select_single('QQuickText',
78- objectName='WeatherDetailUnit')
79- self.assertThat(lambda: component.select_single(
80- 'QQuickText', objectName='WeatherDetailValue'),
81- Eventually(Not(Is(None))))
82- value = component.select_single('QQuickText',
83- objectName='WeatherDetailValue')
84+ unit = component.wait_select_single(
85+ 'QQuickText', objectName='WeatherDetailUnit')
86+ value = component.wait_select_single(
87+ 'QQuickText', objectName='WeatherDetailValue')
88 if pre_units == "in":
89 self.assertThat(unit.text, Eventually(Equals(u'in')))
90 self.assertThat(value.text, Eventually(Equals(u'0.18')))
91@@ -142,18 +125,11 @@
92 self.assertThat(lambda: self.main_view.select_many(
93 'TabFooter', objectName='TabFooter')[0],
94 Eventually(Not(Is(None))))
95- current_location_tab = self.main_view.select_single('LocationTab',
96- visible=True)
97- self.assertThat(lambda: current_location_tab.select_single(
98- 'TabFooter', objectName='TabFooter'),
99- Eventually(Not(Is(None))))
100- self.assertThat(lambda: current_location_tab.select_single(
101- 'QQuickImage', objectName='DataProviderLogo'),
102- Eventually(Not(Is(None))))
103-
104- tab_footer = current_location_tab.select_single('TabFooter',
105- objectName='TabFooter')
106- provider_logo = current_location_tab.select_single(
107+ current_location_tab = self.main_view.wait_select_single(
108+ 'LocationTab', visible=True)
109+ tab_footer = current_location_tab.wait_select_single(
110+ 'TabFooter', objectName='TabFooter')
111+ provider_logo = current_location_tab.wait_select_single(
112 'QQuickImage', objectName='DataProviderLogo')
113 if service == "weatherchannel":
114 self.assertThat(tab_footer.visible, Eventually(Equals(True)))
115@@ -162,33 +138,21 @@
116 self.assertThat(tab_footer.visible, Eventually(Equals(False)))
117 self.assertThat(provider_logo.visible, Eventually(Equals(True)))
118
119+ def _get_selector(self, object_name):
120+ return self.main_view.wait_select_single('OptionSelector',
121+ objectName=object_name)
122+
123 def test_switch_scale(self):
124 """Tests switching the scale in the settings"""
125 # first check metric values and open the settings sheet
126 self._check_units('metric')
127 self._open_settings_sheet()
128
129- # open the value selector
130- self.assertThat(lambda: self.main_view.select_single(
131- 'OptionSelector', objectName='TemperatureUnitsSelector'),
132- Eventually(Not(Is(None))))
133- units_selector = self.main_view.select_single(
134- 'OptionSelector', objectName="TemperatureUnitsSelector")
135- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
136- self.assertThat(lambda: units_selector.select_many(
137- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
138- current_option = units_selector.select_many(
139- 'OptionSelectorDelegate')[1]
140- self.pointing_device.click_object(current_option)
141+ # get temp selector
142+ units_selector = self._get_selector("TemperatureUnitsSelector")
143
144 # choose second option, fahrenheit
145- self._move_pointer_around()
146- self.assertThat(lambda: units_selector.select_many(
147- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
148- imperial_option = units_selector.select_many(
149- 'OptionSelectorDelegate')[0]
150- self.pointing_device.click_object(imperial_option)
151- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
152+ units_selector.select_option(objectName="fahrenheitOption")
153 self._click_sheet_confirm()
154
155 # wait for reload and check the imperial values
156@@ -197,30 +161,10 @@
157
158 # switch back to metric values again
159 self._open_settings_sheet()
160- self.assertThat(lambda: self.main_view.select_single(
161- 'OptionSelector', objectName='TemperatureUnitsSelector'),
162- Eventually(Not(Is(None))))
163- units_selector = self.main_view.select_single(
164- 'OptionSelector', objectName="TemperatureUnitsSelector")
165- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
166- self.assertThat(lambda: units_selector.select_many(
167- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
168- current_option = units_selector.select_many(
169- 'OptionSelectorDelegate')[0]
170- self.pointing_device.click_object(current_option)
171- # while it's opened, units_selector returns false
172- # self.assertThat(units_selector.expanded, Eventually(Equals(True)))
173+ units_selector = self._get_selector("TemperatureUnitsSelector")
174
175 # click celsius option
176- self._move_pointer_around()
177- self.assertThat(lambda: units_selector.select_many(
178- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
179- metric_option = units_selector.select_single(
180- 'OptionSelectorDelegate', objectName='celsiusOption')
181- self.pointing_device.click_object(metric_option)
182-
183- # confirm
184- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
185+ units_selector.select_option(objectName="celsiusOption")
186 self._click_sheet_confirm()
187
188 # wait for reload and check the metric values again
189@@ -235,43 +179,14 @@
190 self._open_settings_sheet()
191
192 # open the temp value selector
193- self.assertThat(lambda: self.main_view.select_single(
194- 'OptionSelector', objectName='TemperatureUnitsSelector'),
195- Eventually(Not(Is(None))))
196- units_selector = self.main_view.select_single(
197- 'OptionSelector', objectName="TemperatureUnitsSelector")
198- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
199- self.assertThat(lambda: units_selector.select_many(
200- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
201- current_option = units_selector.select_many(
202- 'OptionSelectorDelegate')[1]
203- self.pointing_device.click_object(current_option)
204+ units_selector = self._get_selector("TemperatureUnitsSelector")
205
206 # choose second option, fahrenheit
207- self._move_pointer_around()
208- self.assertThat(lambda: units_selector.select_many(
209- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
210- imperial_option = units_selector.select_many(
211- 'OptionSelectorDelegate')[0]
212- self.pointing_device.click_object(imperial_option)
213- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
214+ units_selector.select_option(objectName="fahrenheitOption")
215
216 # open the wind value selector
217- self.assertThat(lambda: self.main_view.select_single(
218- 'OptionSelector', objectName='WindUnitsSelector'),
219- Eventually(Not(Is(None))))
220- units_selector = self.main_view.select_single(
221- 'OptionSelector', objectName="WindUnitsSelector")
222- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
223- self.pointing_device.click_object(units_selector)
224-
225- # choose second option, mph
226- self._move_pointer_around()
227- self.assertThat(lambda: units_selector.select_many(
228- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
229- mph_option = units_selector.select_many('OptionSelectorDelegate')[1]
230- self.pointing_device.click_object(mph_option)
231- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
232+ wind_selector = self._get_selector("WindUnitsSelector")
233+ wind_selector.select_option(objectName="mphOption")
234
235 # cancel and check
236 self._click_sheet_cancel()
237@@ -284,26 +199,9 @@
238 self._check_wind_units('kmh')
239 self._open_settings_sheet()
240
241- # open the wind value selector
242- self.assertThat(lambda: self.main_view.select_single(
243- 'OptionSelector', objectName='WindUnitsSelector'),
244- Eventually(Not(Is(None))))
245- units_selector = self.main_view.select_single(
246- 'OptionSelector', objectName="WindUnitsSelector")
247- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
248- self.assertThat(lambda: units_selector.select_many(
249- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
250- current_option = units_selector.select_many(
251- 'OptionSelectorDelegate')[1]
252- self.pointing_device.click_object(current_option)
253-
254- # choose second option, mph
255- self._move_pointer_around()
256- self.assertThat(lambda: units_selector.select_many(
257- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
258- mph_option = units_selector.select_many('OptionSelectorDelegate')[0]
259- self.pointing_device.click_object(mph_option)
260- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
261+ # choose mph and confirm
262+ wind_selector = self._get_selector("WindUnitsSelector")
263+ wind_selector.select_option(objectName="mphOption")
264 self._click_sheet_confirm()
265
266 # wait for reload and check the mph values
267@@ -312,176 +210,43 @@
268
269 # switch back to kmh values again
270 self._open_settings_sheet()
271- self.assertThat(lambda: self.main_view.select_single(
272- 'OptionSelector', objectName='WindUnitsSelector'),
273- Eventually(Not(Is(None))))
274- units_selector = self.main_view.select_single(
275- 'OptionSelector', objectName="WindUnitsSelector")
276- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
277- self.assertThat(lambda: units_selector.select_many(
278- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
279- current_option = units_selector.select_many(
280- 'OptionSelectorDelegate')[0]
281- self.pointing_device.click_object(current_option)
282- # while it's opened, units_selector returns false
283- # self.assertThat(units_selector.expanded, Eventually(Equals(True)))
284-
285- # click kmh option
286- self._move_pointer_around()
287- self.assertThat(lambda: units_selector.select_many(
288- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
289- kmh_option = units_selector.select_single(
290- 'OptionSelectorDelegate', objectName='kmhOption')
291- self.pointing_device.click_object(kmh_option)
292-
293- # confirm
294- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
295+ wind_selector = self._get_selector("WindUnitsSelector")
296+ wind_selector.select_option(objectName="kmhOption")
297 self._click_sheet_confirm()
298
299 # wait for reload and check the metric values again
300 self.main_view.wait_for_activity_to_finish()
301 self._check_wind_units('kmh')
302
303- @skip("data not available")
304- def test_switch_precipitation_scale(self):
305- """Tests switching the precipition scale in the settings"""
306- # first check metric values and open the settings sheet
307- self._check_precipitation_units('mm')
308- self._open_settings_sheet()
309-
310- # open the precipitation value selector
311- self.assertThat(lambda: self.main_view.select_single(
312- 'OptionSelector', objectName='PrecipitationUnitsSelector'),
313- Eventually(Not(Is(None))))
314- units_selector = self.main_view.select_single(
315- 'OptionSelector', objectName="PrecipitationUnitsSelector")
316- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
317- self.assertThat(lambda: units_selector.select_many(
318- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
319- current_option = units_selector.select_many(
320- 'OptionSelectorDelegate')[1]
321- self.pointing_device.click_object(current_option)
322-
323- # choose second option, inch
324- self._move_pointer_around()
325- self.assertThat(lambda: units_selector.select_many(
326- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
327- in_option = units_selector.select_many('OptionSelectorDelegate')[0]
328- self.pointing_device.click_object(in_option)
329- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
330- self._click_sheet_confirm()
331-
332- # wait for reload and check the inch values
333- self.main_view.wait_for_activity_to_finish()
334- self._check_wind_units('in')
335-
336- # switch back to mm values again
337- self._open_settings_sheet()
338- self.assertThat(lambda: self.main_view.select_single(
339- 'OptionSelector', objectName='PrecipitationUnitsSelector'),
340- Eventually(Not(Is(None))))
341- units_selector = self.main_view.select_single(
342- 'OptionSelector', objectName="PrecipitationUnitsSelector")
343- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
344- self.assertThat(lambda: units_selector.select_many(
345- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
346- current_option = units_selector.select_many(
347- 'OptionSelectorDelegate')[0]
348- self.pointing_device.click_object(current_option)
349- # while it's opened, units_selector returns false
350- # self.assertThat(units_selector.expanded, Eventually(Equals(True)))
351-
352- # click mm option
353- self._move_pointer_around()
354- self.assertThat(lambda: units_selector.select_many(
355- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
356- # XXX select the option by it's object name or index, using the
357- # emulator from the ubuntu-ui-toolkit.
358- mm_option = units_selector.select_single(
359- 'OptionSelectorDelegate', objectName='millimetersOption')
360- self.pointing_device.click_object(mm_option)
361-
362- # confirm
363- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
364- self._click_sheet_confirm()
365-
366- # wait for reload and check the metric values again
367- self.main_view.wait_for_activity_to_finish()
368- self._check_precipitation_units('mm')
369-
370 def test_switch_service(self):
371 """Tests switching the scale in the settings"""
372 # first check metric values and open the settings sheet
373 self._check_service('weatherchannel')
374 self._open_settings_sheet()
375
376- # open the value selector
377- self.assertThat(lambda: self.main_view.select_single(
378- 'OptionSelector', objectName='ServiceSelector'),
379- Eventually(Not(Is(None))))
380- units_selector = self.main_view.select_single(
381- 'OptionSelector', objectName="ServiceSelector")
382- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
383- self.assertThat(lambda: units_selector.select_many(
384- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
385- current_option = units_selector.select_many(
386- 'OptionSelectorDelegate')[1]
387- self.pointing_device.click_object(current_option)
388-
389 # choose second option, openweathermap
390- self._move_pointer_around()
391- self.assertThat(lambda: units_selector.select_many(
392- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
393- second_option = units_selector.select_many(
394- 'OptionSelectorDelegate')[0]
395- self.pointing_device.click_object(second_option)
396- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
397+ selector = self._get_selector("ServiceSelector")
398+ selector.select_option(objectName="owmOption")
399
400 # check if precipitation units selector appears
401- self.assertThat(lambda: self.main_view.select_single(
402- 'OptionSelector', objectName='PrecipitationUnitsSelector'),
403- Eventually(Not(Is(None))))
404- units_selector = self.main_view.select_single(
405- 'OptionSelector', objectName="PrecipitationUnitsSelector")
406- self.assertThat(units_selector.visible, Eventually(Equals(1)))
407+ self.assertThat(lambda: self.main_view.select_single('OptionSelector',
408+ objectName='PrecipitationUnitsSelector'),
409+ Eventually(Not(Is(None))))
410 self._click_sheet_confirm()
411
412 # wait for reload and check the used service
413 self.main_view.wait_for_activity_to_finish()
414 self._check_service('openweathermap')
415
416- # switch back to metric values again
417+ # switch back to twc values again
418 self._open_settings_sheet()
419- self.assertThat(lambda: self.main_view.select_single(
420- 'OptionSelector', objectName='ServiceSelector'),
421- Eventually(Not(Is(None))))
422- units_selector = self.main_view.select_single(
423- 'OptionSelector', objectName="ServiceSelector")
424- self.assertThat(units_selector.selectedIndex, Eventually(Equals(1)))
425- self.assertThat(lambda: units_selector.select_many(
426- 'OptionSelectorDelegate')[0], Eventually(Not(Is(None))))
427- current_option = units_selector.select_many(
428- 'OptionSelectorDelegate')[0]
429- self.pointing_device.click_object(current_option)
430- # while it's opened, units_selector returns false
431- # self.assertThat(units_selector.expanded, Eventually(Equals(True)))
432-
433- # click twc option
434- self._move_pointer_around()
435- self.assertThat(lambda: units_selector.select_many(
436- 'OptionSelectorDelegate')[1], Eventually(Not(Is(None))))
437- first_option = units_selector.select_single(
438- 'OptionSelectorDelegate', objectName='twcOption')
439- self.pointing_device.click_object(first_option)
440- self.assertThat(units_selector.selectedIndex, Eventually(Equals(0)))
441+ selector = self._get_selector("ServiceSelector")
442+ selector.select_option(objectName="twcOption")
443
444 # check if precipitation units selector disappears and confirm
445- self.assertThat(lambda: self.main_view.select_single(
446- 'OptionSelector', objectName='PrecipitationUnitsSelector'),
447- Eventually(Not(Is(None))))
448- units_selector = self.main_view.select_single(
449- 'OptionSelector', objectName="PrecipitationUnitsSelector")
450- self.assertThat(units_selector.visible, Eventually(Equals(0)))
451+ self.assertThat(lambda: self.main_view.select_single('OptionSelector',
452+ objectName='PrecipitationUnitsSelector'),
453+ Eventually(Not(Is(None))))
454 self._click_sheet_confirm()
455
456 # wait for reload and check the metric values again

Subscribers

People subscribed via source and target branches