summary refs log tree commit diff
path: root/libnm-glib/tests/test-remote-settings-service.py
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-glib/tests/test-remote-settings-service.py')
-rwxr-xr-xlibnm-glib/tests/test-remote-settings-service.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/libnm-glib/tests/test-remote-settings-service.py b/libnm-glib/tests/test-remote-settings-service.py
index 86542005..439073ad 100755
--- a/libnm-glib/tests/test-remote-settings-service.py
+++ b/libnm-glib/tests/test-remote-settings-service.py
@@ -1,8 +1,9 @@
 #!/usr/bin/env python
 # -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 
-import glib
-import gobject
+from __future__ import print_function
+
+from gi.repository import GLib, GObject
 import sys
 import dbus
 import dbus.service
@@ -21,7 +22,7 @@ class UnknownPropertyException(dbus.DBusException):
 class PermissionDeniedException(dbus.DBusException):
     _dbus_error_name = IFACE_SETTINGS + '.PermissionDenied'
 
-mainloop = gobject.MainLoop()
+mainloop = GObject.MainLoop()
 
 class Connection(dbus.service.Object):
     def __init__(self, bus, object_path, settings, remove_func):
@@ -30,7 +31,25 @@ class Connection(dbus.service.Object):
         self.settings = settings
         self.remove_func = remove_func
         self.visible = True
+        self.props = {}
+        self.props['Unsaved'] = False
+
+    # Properties interface
+    @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}')
+    def GetAll(self, iface):
+        if iface != IFACE_CONNECTION:
+            raise UnknownInterfaceException()
+        return self.props
+
+    @dbus.service.method(dbus_interface=dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v')
+    def Get(self, iface, name):
+        if iface != IFACE_CONNECTION:
+            raise UnknownInterfaceException()
+        if not name in self.props.keys():
+            raise UnknownPropertyException()
+        return self.props[name]
 
+    # Connection methods
     @dbus.service.method(dbus_interface=IFACE_CONNECTION, in_signature='', out_signature='a{sa{sv}}')
     def GetSettings(self):
         if not self.visible:
@@ -72,10 +91,10 @@ class Settings(dbus.service.Object):
 
     @dbus.service.method(dbus_interface=IFACE_SETTINGS, in_signature='a{sa{sv}}', out_signature='o')
     def AddConnection(self, settings):
-        path = "/org/freedesktop/NetworkManager/Settings/Connection/%d" % self.counter
+        path = "/org/freedesktop/NetworkManager/Settings/Connection/{0}".format(self.counter)
         self.counter = self.counter + 1
         self.connections[path] = Connection(self.bus, path, settings, self.delete_connection)
-        print "Added connection %s" % path
+        print("Added connection {0}".format(path))
         return path
 
     def delete_connection(self, connection):
@@ -114,16 +133,16 @@ def main():
     if not bus.request_name("org.freedesktop.NetworkManager"):
         sys.exit(1)
 
-    print "Service started"
+    print("Service started")
 
-    gobject.timeout_add_seconds(20, quit_cb, None)
+    GLib.timeout_add_seconds(20, quit_cb, None)
 
     try:
         mainloop.run()
-    except Exception, e:
+    except Exception as e:
         pass
 
-    print "Service stopped"
+    print("Service stopped")
     sys.exit(0)
 
 if __name__ == '__main__':