[telepathy-mission-control-5.16] telepathy-mission-control: tests: make tests work again when NM support is enabled

George Kiagiadakis gkiagia at kemper.freedesktop.org
Thu Sep 1 18:53:43 UTC 2016


Module: telepathy-mission-control
Branch: telepathy-mission-control-5.16
Commit: 78d8c53b930323455bb7c4031903f46717b8a174
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=78d8c53b930323455bb7c4031903f46717b8a174

Author: George Kiagiadakis <gkiagia at tolabaki.gr>
Date:   Mon Aug 15 11:37:24 2016 +0300

tests: make tests work again when NM support is enabled

Apparently the nm library also tries to access the /.../Settings
object of NM, which was not available in our fake NM implementation.
This commit implements the basic properties of the Settings object,
which allows the tests to continue past this point.

https://bugs.freedesktop.org/show_bug.cgi?id=96917

---

 tests/twisted/fakeconnectivity.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/twisted/fakeconnectivity.py b/tests/twisted/fakeconnectivity.py
index 02d577f..846dd76 100644
--- a/tests/twisted/fakeconnectivity.py
+++ b/tests/twisted/fakeconnectivity.py
@@ -6,7 +6,9 @@ import sys
 class FakeConnectivity(object):
     NM_BUS_NAME = 'org.freedesktop.NetworkManager'
     NM_PATH = '/org/freedesktop/NetworkManager'
+    NM_PATH_SETTINGS = NM_PATH + '/Settings'
     NM_INTERFACE = NM_BUS_NAME
+    NM_INTERFACE_SETTINGS = NM_INTERFACE + '.Settings'
 
     NM_STATE_UNKNOWN          = 0
     NM_STATE_ASLEEP           = 10
@@ -47,6 +49,13 @@ class FakeConnectivity(object):
         q.add_dbus_method_impl(self.NM_GetDevices,
             path=self.NM_PATH, interface=self.NM_INTERFACE, method='GetDevices')
 
+        q.add_dbus_method_impl(self.NM_Settings_Get,
+            path=self.NM_PATH_SETTINGS, interface=dbus.PROPERTIES_IFACE, method='Get',
+            predicate=lambda e: e.args[0] == self.NM_INTERFACE_SETTINGS)
+        q.add_dbus_method_impl(self.NM_Settings_GetAll,
+            path=self.NM_PATH_SETTINGS, interface=dbus.PROPERTIES_IFACE, method='GetAll',
+            predicate=lambda e: e.args[0] == self.NM_INTERFACE_SETTINGS)
+
         q.add_dbus_method_impl(self.ConnMan_GetProperties,
             path=self.CONNMAN_PATH, interface=self.CONNMAN_INTERFACE,
             method='GetProperties')
@@ -92,6 +101,19 @@ class FakeConnectivity(object):
     def NM_GetDevices(self, e):
         self.q.dbus_return(e.message, [], signature='ao')
 
+    def nm_settings_props(self):
+        return {
+            'CanModify': False,
+            'Hostname': 'localhost',
+            'Connections': dbus.Array([], signature='o'),
+        }
+
+    def NM_Settings_Get(self, e):
+        self.q.dbus_return(e.message, self.nm_settings_props()[e.args[1]], signature='v')
+
+    def NM_Settings_GetAll(self, e):
+        self.q.dbus_return(e.message, self.nm_settings_props(), signature='a{sv}')
+
     def Connman_props(self):
         return {
             'OfflineMode': False,



More information about the telepathy-commits mailing list