From 8af5c0a44eeb9e1c2feca7b130090267e26d0a78 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Mon, 15 Aug 2016 11:37:24 +0300 Subject: [PATCH] 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, -- 2.7.4