Merge lp:~ken-vandine/ubuntu-system-settings/tz_tests into lp:ubuntu-system-settings

Proposed by Ken VanDine on 2015-04-17
Status: Merged
Approved by: Ken VanDine on 2015-04-22
Approved revision: 1395
Merged at revision: 1394
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/tz_tests
Merge into: lp:ubuntu-system-settings
Diff against target: 107 lines (+23/-34)
1 file modified
tests/autopilot/ubuntu_system_settings/tests/test_datetime.py (+23/-34)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/tz_tests
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-04-22
Federico Gimenez (community) Approve on 2015-04-21
Sebastien Bacher (community) 2015-04-17 Approve on 2015-04-21
Leo Arias 2015-04-21 Pending
Review via email: mp+256700@code.launchpad.net

Commit Message

Don't call a test from inside another test

Description of the Change

Don't call a test from inside another test and added some more waits

To post a comment you must log in.
1389. By Ken VanDine on 2015-04-20

More wait_select_single

1390. By Ken VanDine on 2015-04-20

Removed unused import, fixes pep8 failure

1391. By Ken VanDine on 2015-04-20

Revert changes to tests for nothingLabel

1392. By Ken VanDine on 2015-04-20

Use wait_select_single for selecting nothingLabel

Sebastien Bacher (seb128) wrote :

looks fine to me, thanks

review: Approve
Federico Gimenez (fgimenez) wrote :

Looks good in general, some inline comments but not blockers

review: Approve
1393. By Ken VanDine on 2015-04-22

Improved asserts based on review feedback

1394. By Ken VanDine on 2015-04-22

Reduced redundant code based on review feedback

Ken VanDine (ken-vandine) wrote :

> Looks good in general, some inline comments but not blockers

Thanks for the feedback, I've made those improvements!

1395. By Ken VanDine on 2015-04-22

merged trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_datetime.py'
2--- tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 2015-01-23 14:02:09 +0000
3+++ tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 2015-04-22 13:26:00 +0000
4@@ -10,7 +10,7 @@
5 from time import sleep
6
7 from autopilot.matchers import Eventually
8-from testtools.matchers import Equals, NotEquals, GreaterThan
9+from testtools.matchers import Equals, GreaterThan
10
11 from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
12 from ubuntu_system_settings.utils.i18n import ugettext as _
13@@ -69,72 +69,61 @@
14 self.main_view.pointing_device.move_to_object(
15 text_field)
16
17+ def search_kb_type(self, kb_type):
18+ self.click_tz_search_field()
19+ self.keyboard.type(kb_type)
20+ return self.main_view.wait_select_single(
21+ objectName='locationsListView'
22+ )
23+
24 def test_time_date_page(self):
25 """ Checks whether Time & Date page is available """
26- self.assertThat(self.page, NotEquals(None))
27- self.assertThat(self.page.title, Equals(_('Time & Date')))
28+ self.assertEqual(self.page.title, _('Time & Date'))
29
30 def test_tz_list_initially_empty(self):
31 """ Checks that no list is displayed initially """
32 self.main_view.scroll_to_and_click(self.tz_page)
33 labelVisible = self.main_view.wait_select_single(
34 objectName='nothingLabel').visible
35- self.assertThat(labelVisible, Equals(True))
36+ self.assertEqual(labelVisible, True)
37
38 def test_searching_tz(self):
39 """ Check that searching for a valid location shows something """
40- self.click_tz_search_field()
41- self.keyboard.type('London, United Kingdom')
42- listview = self.main_view.select_single(
43- objectName='locationsListView'
44- )
45+ listview = self.search_kb_type('London, United Kingdom')
46 self.assertThat(listview.count, Eventually(GreaterThan(0)))
47
48 def test_searching_tz_not_found(self):
49 """ Check that searching for an invalid location shows nothing """
50- self.click_tz_search_field()
51- self.keyboard.type('Oh no you don\'t!')
52- listview = self.main_view.select_single(
53- objectName='locationsListView'
54- )
55- self.assertThat(listview.count, Equals(0))
56+ listview = self.search_kb_type('Oh no you don\'t!')
57+ self.assertEqual(listview.count, 0)
58 labelVisible = self.main_view.select_single(
59 objectName='nothingLabel').visible
60- self.assertThat(labelVisible, Equals(True))
61+ self.assertEqual(labelVisible, True)
62
63 def test_manual_tz_selection(self):
64 """ Check that manually selecting a timezone sets it properly """
65- self.click_tz_search_field()
66- self.keyboard.type('London, United Kingdom')
67- listview = self.main_view.select_single(
68- objectName='locationsListView'
69- )
70+ listview = self.search_kb_type('London, United Kingdom')
71 london = TimeDateTestCase.wait_select_listview_first(listview)
72 self.main_view.pointing_device.click_object(london)
73- header = self.main_view.select_single(
74- objectName='MainView_Header'
75- )
76- self.assertThat(header.title, Eventually(Equals(_('Time & Date'))))
77- self.assertThat(self.tz_page.text, Equals('Europe/London'))
78+ self.assertThat(self.tz_page.text, Eventually(Equals('Europe/London')))
79
80 def test_same_tz_selection(self):
81 """Check that manually setting a timezone then setting the same one
82 doesn't take you back to the index.
83 """
84- self.test_manual_tz_selection()
85- self.click_tz_search_field()
86+ # Set tz to London
87+ listview = self.search_kb_type('London, United Kingdom')
88+ london = TimeDateTestCase.wait_select_listview_first(listview)
89+ self.main_view.pointing_device.click_object(london)
90+ sleep(2)
91 # This is also in Europe/London
92- self.keyboard.type('Preston, United Kingdom')
93- listview = self.main_view.select_single(
94- objectName='locationsListView'
95- )
96-
97+ listview = self.search_kb_type('Preston, United Kingdom')
98 preston = TimeDateTestCase.wait_select_listview_first(listview)
99 self.main_view.pointing_device.click_object(preston)
100
101 # The timer is 1 second, wait and see that we haven't moved pages
102 sleep(2)
103- header = self.main_view.select_single(
104+ header = self.main_view.wait_select_single(
105 objectName='MainView_Header'
106 )
107 self.assertThat(header.title, Eventually(Equals(_('Time zone'))))

Subscribers

People subscribed via source and target branches