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

Proposed by Ken VanDine on 2015-05-12
Status: Merged
Approved by: Ken VanDine on 2015-05-13
Approved revision: 1410
Merged at revision: 1414
Proposed branch: lp:~ken-vandine/ubuntu-system-settings/ap_sanity_helpers
Merge into: lp:ubuntu-system-settings
Diff against target: 142 lines (+32/-40)
2 files modified
tests/autopilot/ubuntu_system_settings/__init__.py (+6/-4)
tests/autopilot/ubuntu_system_settings/tests/test_security.py (+26/-36)
To merge this branch: bzr merge lp:~ken-vandine/ubuntu-system-settings/ap_sanity_helpers
Reviewer Review Type Date Requested Status
Brendan Donegan (community) Approve on 2015-05-13
PS Jenkins bot continuous-integration Approve on 2015-05-12
Ubuntu Touch System Settings 2015-05-12 Pending
Review via email: mp+258901@code.launchpad.net

Commit Message

incorporate SimPin helper from ubuntu-sanity-tests and refactor a few tests to utilize them

Description of the Change

incorporate SimPin helper from ubuntu-sanity-tests and refactor a few tests to utilize them

To post a comment you must log in.
1410. By Ken VanDine on 2015-05-12

Fixed pyflakes failure

Brendan Donegan (brendan-donegan) wrote :

LGTM +1

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_system_settings/__init__.py'
2--- tests/autopilot/ubuntu_system_settings/__init__.py 2015-04-07 14:27:37 +0000
3+++ tests/autopilot/ubuntu_system_settings/__init__.py 2015-05-12 16:32:47 +0000
4@@ -421,14 +421,16 @@
5
6 """Autopilot helper for the SimPin Page."""
7
8- def get_sim_pin_switch(self):
9+ def get_sim_pin_switch(self, sim_number):
10 """Return the SIM PIN switch."""
11- return self.select_single(objectName='simPinSwitch')
12+ switches = self.select_many(objectName='simPinSwitch')
13+ switches = sorted(switches, key=lambda switch: (switch.globalRect.y))
14+ return switches[sim_number]
15
16 @autopilot.logging.log_action(logger.debug)
17- def click_sim_pin_switch(self):
18+ def click_sim_pin_switch(self, sim_number):
19 """Click on the SIM PIN switch, return the SIM PIN dialog."""
20- sim_pin_switch = self.get_sim_pin_switch()
21+ sim_pin_switch = self.get_sim_pin_switch(sim_number)
22 self.pointing_device.click_object(sim_pin_switch)
23 return self.get_root_instance().wait_select_single(
24 objectName='lockDialogComponent'
25
26=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_security.py'
27--- tests/autopilot/ubuntu_system_settings/tests/test_security.py 2015-02-19 15:18:09 +0000
28+++ tests/autopilot/ubuntu_system_settings/tests/test_security.py 2015-05-12 16:32:47 +0000
29@@ -199,22 +199,19 @@
30 )
31
32 def test_sim_pin_lock_control(self):
33- self._go_to_sim_lock()
34- sim_lock_control = self.main_view.select_single(
35- objectName='simPinSwitch'
36- )
37+ sim_pin_page = self.security_page.go_to_sim_lock()
38+
39+ switch = sim_pin_page.get_sim_pin_switch(0)
40 locked = len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
41- self.assertEquals(locked, sim_lock_control.checked)
42+ self.assertEquals(locked, switch.checked)
43
44 def test_sim_pin_lock_control_unlock(self):
45- self._go_to_sim_lock()
46- sim_lock_control = self.main_view.select_single(
47- objectName='simPinSwitch'
48- )
49-
50- self.assertTrue(sim_lock_control.checked)
51-
52- self.main_view.scroll_to_and_click(sim_lock_control)
53+ sim_pin_page = self.security_page.go_to_sim_lock()
54+ switch = sim_pin_page.get_sim_pin_switch(0)
55+
56+ self.assertTrue(switch.checked)
57+
58+ sim_pin_page.click_sim_pin_switch(0)
59
60 lock_dialog = self.main_view.select_single(
61 objectName='lockDialogComponent'
62@@ -252,22 +249,20 @@
63
64 self.main_view.scroll_to_and_click(submit_button)
65
66- self.assertFalse(sim_lock_control.checked)
67+ self.assertFalse(switch.checked)
68
69 locked = len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
70- self.assertEquals(locked, sim_lock_control.checked)
71+ self.assertEquals(locked, switch.checked)
72
73 @unittest.skip('skipped because the simPinSwitch state fails to update')
74 def test_sim_pin_lock_control_lock(self):
75 self.modem_0.Set(SIM_IFACE, 'LockedPins', "")
76- self._go_to_sim_lock()
77- sim_lock_control = self.main_view.select_single(
78- objectName='simPinSwitch'
79- )
80-
81- self.assertFalse(sim_lock_control.checked)
82-
83- self.main_view.scroll_to_and_click(sim_lock_control)
84+ sim_pin_page = self.security_page.go_to_sim_lock()
85+ switch = sim_pin_page.get_sim_pin_switch(0)
86+
87+ self.assertFalse(switch.checked)
88+
89+ sim_pin_page.click_sim_pin_switch(0)
90
91 lock_dialog = self.main_view.select_single(
92 objectName='lockDialogComponent'
93@@ -305,24 +300,22 @@
94
95 self.main_view.scroll_to_and_click(submit_button)
96
97- self.assertTrue(sim_lock_control.checked)
98+ self.assertTrue(switch.checked)
99
100 self.assertEqual(['pin'], self.modem_0.Get(SIM_IFACE, 'LockedPins'))
101 locked = len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
102- self.assertEquals(locked, sim_lock_control.checked)
103+ self.assertEquals(locked, switch.checked)
104
105 def test_sim_pin_lock_control_unlock_fail(self):
106- self._go_to_sim_lock()
107- sim_lock_control = self.main_view.select_single(
108- objectName='simPinSwitch'
109- )
110+ sim_pin_page = self.security_page.go_to_sim_lock()
111+ switch = sim_pin_page.get_sim_pin_switch(0)
112
113 self.assertTrue(
114 len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
115 )
116- self.assertTrue(sim_lock_control.checked)
117+ self.assertTrue(switch.checked)
118
119- self.main_view.scroll_to_and_click(sim_lock_control)
120+ sim_pin_page.click_sim_pin_switch(0)
121
122 lock_dialog = self.main_view.select_single(
123 objectName='lockDialogComponent'
124@@ -363,16 +356,13 @@
125 @unittest.skip('skipped because the simPinSwitch state fails to update')
126 def test_sim_pin_lock_control_lock_fail(self):
127 self.modem_0.Set(SIM_IFACE, 'LockedPins', "")
128- self._go_to_sim_lock()
129- sim_lock_control = self.main_view.select_single(
130- objectName='simPinSwitch'
131- )
132+ sim_pin_page = self.security_page.go_to_sim_lock()
133
134 self.assertFalse(
135 len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
136 )
137
138- self.main_view.scroll_to_and_click(sim_lock_control)
139+ sim_pin_page.click_sim_pin_switch(0)
140
141 lock_dialog = self.main_view.select_single(
142 objectName='lockDialogComponent'

Subscribers

People subscribed via source and target branches