Merge lp:~jonas-drange/ubuntu-system-settings/fix-notification-test into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 1507
Merged at revision: 1512
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/fix-notification-test
Merge into: lp:ubuntu-system-settings
Diff against target: 61 lines (+16/-13)
2 files modified
tests/autopilot/ubuntu_system_settings/__init__.py (+5/-0)
tests/autopilot/ubuntu_system_settings/tests/test_notifications.py (+11/-13)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/fix-notification-test
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Sebastien Bacher (community) Approve
Review via email: mp+269039@code.launchpad.net

Commit message

Use wait_select_single instead of select_single to make the test less flaky

Description of the change

Use wait_select_single instead of select_single to make the test less flaky

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1508. By Jonas G. Drange

drop the sleep, replace with Eventually. Use the proper go_to pattern

Revision history for this message
PS Jenkins bot (ps-jenkins) 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_system_settings/__init__.py'
2--- tests/autopilot/ubuntu_system_settings/__init__.py 2015-08-18 13:20:10 +0000
3+++ tests/autopilot/ubuntu_system_settings/__init__.py 2015-08-25 14:09:30 +0000
4@@ -112,6 +112,11 @@
5 'securityPrivacyPage')
6
7 @autopilot.logging.log_action(logger.debug)
8+ def go_to_notification_page(self):
9+ return self._go_to_page('entryComponent-notifications',
10+ 'systemNotificationsPage')
11+
12+ @autopilot.logging.log_action(logger.debug)
13 def go_to_datetime_page(self):
14 return self._go_to_page('entryComponent-time-date', 'timeDatePage')
15
16
17=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_notifications.py'
18--- tests/autopilot/ubuntu_system_settings/tests/test_notifications.py 2015-03-31 19:38:11 +0000
19+++ tests/autopilot/ubuntu_system_settings/tests/test_notifications.py 2015-08-25 14:09:30 +0000
20@@ -8,9 +8,10 @@
21 import json
22 import os
23 import subprocess
24-import time
25-
26-from testtools.matchers import Equals, NotEquals
27+
28+from autopilot.matchers import Eventually
29+
30+from testtools.matchers import Equals
31
32 from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
33
34@@ -31,6 +32,7 @@
35 def setUp(self):
36 # Check legacy items: one for each file in legacy-helpers
37 super(NotificationsTestCases, self).setUp()
38+ self.notification_page = self.main_view.go_to_notification_page()
39
40 def test_item_counts(self):
41 """ Checks whether the Notificatins category is available """
42@@ -45,13 +47,9 @@
43 ['click', 'list', '--manifest']).decode('utf8'))
44 click_count = len([x for x in packages if has_helper(x)])
45
46- notif = self.main_view.select_single(
47- objectName='entryComponent-notifications')
48- self.assertThat(notif, NotEquals(None))
49- self.main_view.pointing_device.click_object(notif)
50- # Have to wait until the model loads
51- time.sleep(1)
52- notif_page = self.main_view.select_single(
53- objectName='systemNotificationsPage')
54- items = notif_page.select_many(toolkit_emulators.Standard)
55- self.assertThat(len(items), Equals(click_count + legacy_count))
56+ self.assertThat(
57+ lambda: len(
58+ self.notification_page.select_many(toolkit_emulators.Standard)
59+ ),
60+ Eventually(Equals(click_count + legacy_count))
61+ )

Subscribers

People subscribed via source and target branches