Merge lp:~jonas-drange/ubuntu-system-settings/fix-networkmanager-tests into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Ken VanDine
Approved revision: 1362
Merged at revision: 1372
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/fix-networkmanager-tests
Merge into: lp:ubuntu-system-settings
Diff against target: 132 lines (+20/-57)
3 files modified
debian/control (+1/-1)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+2/-38)
tests/autopilot/ubuntu_system_settings/tests/test_wifi.py (+17/-18)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/fix-networkmanager-tests
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Sebastien Bacher (community) Approve
Review via email: mp+254903@code.launchpad.net

Commit message

fix tests that uses the networkmanager template

Description of the change

Rationale:
The networkmanager template in python-dbusmock changed considerably from 0.13 to 0.14. E.g. Wi-Fi connections now require an access point to be added—in USS we added Wi-Fi connections without an access point.

Changed in this branch:
We now use the networkmanager template API to create access points for every Wi-Fi connection.

Also, since we're using a new API in the networkmanager template (AddAccessPoint), we need to depend on, at least, python-dbusmock 0.14.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks! (not sure why the background test failed in the CI log though)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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 'debian/control'
2--- debian/control 2015-03-04 06:42:32 +0000
3+++ debian/control 2015-04-01 12:43:07 +0000
4@@ -131,7 +131,7 @@
5 Depends: ubuntu-system-settings,
6 gir1.2-upowerglib-1.0,
7 python3-autopilot,
8- python3-dbusmock (>= 0.10.1),
9+ python3-dbusmock (>= 0.14),
10 python3-dateutil,
11 python3-evdev,
12 libautopilot-qt,
13
14=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
15--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-02-19 07:22:16 +0000
16+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-04-01 12:43:07 +0000
17@@ -27,7 +27,6 @@
18 import ubuntuuitoolkit
19 from autopilot import platform
20 from autopilot.matchers import Eventually
21-from dbusmock.templates.networkmanager import DEVICE_IFACE
22 from fixtures import EnvironmentVariable
23 from gi.repository import UPowerGlib
24 from testtools.matchers import Equals, NotEquals, GreaterThan
25@@ -869,45 +868,10 @@
26
27 def setUp(self, panel=None):
28 self.obj_nm.Reset()
29- device_path = self.obj_nm.AddWiFiDevice('test0', 'Barbaz', 1)
30+ self.device_path = self.obj_nm.AddWiFiDevice('test0', 'Barbaz', 1)
31 self.device_mock = dbus.Interface(self.dbus_con.get_object(
32- NM_SERVICE, device_path),
33+ NM_SERVICE, self.device_path),
34 dbusmock.MOCK_IFACE)
35
36- self.add_active_connection(
37- 'activecon0', self.device_mock, device_path)
38-
39 super(WifiBaseTestCase, self).setUp()
40 self.wifi_page = self.main_view.go_to_wifi_page()
41-
42- def add_previous_networks(self, networks):
43- dev_path = str(self.obj_nm.GetDevices()[0])
44- for network in networks:
45- self.obj_nm.AddWiFiConnection(
46- dev_path, network['connection_name'],
47- network['ssid'], network.get('keymng', ''))
48-
49- def add_active_connection(self, connection_name, device_mock, device_path):
50- """Add ActiveConnection object to device as well as the
51- Active.Connection object being referred to. Will add mocked
52- Connection object, active_connection_mock, to the test case."""
53-
54- # Add a new Connection object
55- con_path = self.obj_nm.AddWiFiConnection(
56- device_path, connection_name, 'fake ssid', '')
57- self.active_connection_mock = dbus.Interface(self.dbus_con.get_object(
58- NM_SERVICE, con_path),
59- dbusmock.MOCK_IFACE)
60- # Set up the ActiveConnection object, which will have a
61- # Connection property pointing to the created Connection
62- ac_path = '/org/freedesktop/NetworkManager/ActiveConnection/%s' % (
63- connection_name)
64- self.dbusmock.AddObject(ac_path, NM_AC_CON_IFACE, {}, [])
65- ac_mock = dbus.Interface(self.dbus_con.get_object(
66- NM_SERVICE, ac_path),
67- dbusmock.MOCK_IFACE)
68- ac_mock.AddProperty(
69- NM_AC_CON_IFACE, 'Connection', dbus.ObjectPath(con_path))
70-
71- device_mock.AddProperty(
72- DEVICE_IFACE, 'ActiveConnection', dbus.ObjectPath(ac_path))
73
74=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_wifi.py'
75--- tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-01-21 14:50:27 +0000
76+++ tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-04-01 12:43:07 +0000
77@@ -7,7 +7,9 @@
78
79 from __future__ import absolute_import
80 from autopilot.matchers import Eventually
81-from dbusmock.templates.networkmanager import DEVICE_IFACE
82+from dbusmock.templates.networkmanager import (DEVICE_IFACE,
83+ InfrastructureMode,
84+ NM80211ApSecurityFlags)
85 from testtools.matchers import Equals
86 from time import sleep
87 from ubuntu_system_settings.tests import WifiBaseTestCase
88@@ -168,30 +170,27 @@
89 objectName='connectToHiddenNetwork').visible),
90 Eventually(Equals(False)), 'other net dialog not hidden')
91
92- """Note: this test does not actually remove previous networks from the UI.
93- The NetworkManager dbusmock template does not currently support deletion
94- of connections."""
95 def test_remove_previous_network(self):
96 click_method = self.main_view.scroll_to_and_click
97- previous_networks = [{
98- 'ssid': 'Series of Tubes',
99- 'connection_name': 'conn_0'
100- }, {
101- 'ssid': 'Mi-Fi',
102- 'connection_name': 'conn_1'
103- }, {
104- 'ssid': 'dev/null',
105- 'connection_name': 'conn_2'
106- }]
107-
108- self.add_previous_networks(previous_networks)
109+
110+ access_points = ['Series of Tubes', 'dev/null', 'Mi-Fi',
111+ 'MonkeySphere']
112+
113+ for idx, ap in enumerate(access_points):
114+ self.dbusmock.AddAccessPoint(
115+ self.device_path, 'Mock_AP%d' % idx, ap, '00:23:F8:7E:12:BB',
116+ InfrastructureMode.NM_802_11_MODE_INFRA, 2425, 5400, 82,
117+ NM80211ApSecurityFlags.NM_802_11_AP_SEC_KEY_MGMT_PSK)
118+
119+ self.dbusmock.AddWiFiConnection(
120+ self.device_path, 'Mock_Con%d' % idx, ap, '')
121
122 self.wifi_page.remove_previous_network(
123- previous_networks[0]['ssid'], scroll_to_and_click=click_method)
124+ access_points[0], scroll_to_and_click=click_method)
125
126 self.main_view.go_back()
127
128 # wait for ui to update
129 sleep(2)
130 self.wifi_page.remove_previous_network(
131- previous_networks[2]['ssid'], scroll_to_and_click=click_method)
132+ access_points[2], scroll_to_and_click=click_method)

Subscribers

People subscribed via source and target branches