diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-09-20 14:40:08 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2016-11-10 16:48:48 +0100 |
commit | 3f451a23947e19c431ab2ab968cfabc58b2f769a (patch) | |
tree | dc2a142ecaa720a066b54740b05e2ab159d1a68a /tools | |
parent | 24afcb502ea30cc9a82bcc964cf363aff1ba7ef8 (diff) | |
download | NetworkManager-3f451a23947e19c431ab2ab968cfabc58b2f769a.tar.gz |
libnm/tests: only init the exported obj when the interfaces are in place
When we have the ObjectManager mock, this allows it to emit correct
InterfacesAdded signal when the ExportedObj is initialized.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/test-networkmanager-service.py | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/tools/test-networkmanager-service.py b/tools/test-networkmanager-service.py index 38b7acd5e8..85a888a4e3 100755 --- a/tools/test-networkmanager-service.py +++ b/tools/test-networkmanager-service.py @@ -153,8 +153,6 @@ class Device(ExportedObj): def __init__(self, bus, iface, devtype): object_path = "/org/freedesktop/NetworkManager/Devices/%d" % Device.counter Device.counter = Device.counter + 1 - ExportedObj.__init__(self, bus, object_path) - self.add_dbus_interface(IFACE_DEVICE, self.__get_props, Device.PropertiesChanged) self.iface = iface self.udi = "/sys/devices/virtual/%s" % iface @@ -167,6 +165,9 @@ class Device(ExportedObj): self.dhcp6_config = None self.available_connections = [] + self.add_dbus_interface(IFACE_DEVICE, self.__get_props, Device.PropertiesChanged) + ExportedObj.__init__(self, bus, object_path) + # Properties interface def __get_props(self): props = {} @@ -226,8 +227,6 @@ PE_S390_SUBCHANNELS = "S390Subchannels" class WiredDevice(Device): def __init__(self, bus, iface, mac, subchannels): - Device.__init__(self, bus, iface, NM_DEVICE_TYPE_ETHERNET) - self.add_dbus_interface(IFACE_WIRED, self.__get_props, WiredDevice.PropertiesChanged) if mac is None: self.mac = random_mac() @@ -236,6 +235,9 @@ class WiredDevice(Device): self.carrier = False self.s390_subchannels = subchannels + self.add_dbus_interface(IFACE_WIRED, self.__get_props, WiredDevice.PropertiesChanged) + Device.__init__(self, bus, iface, NM_DEVICE_TYPE_ETHERNET) + # Properties interface def __get_props(self): props = {} @@ -262,13 +264,13 @@ PV_VLAN_ID = "VlanId" class VlanDevice(Device): def __init__(self, bus, iface): - Device.__init__(self, bus, iface, NM_DEVICE_TYPE_VLAN) - self.add_dbus_interface(IFACE_VLAN, self.__get_props, VlanDevice.PropertiesChanged) - self.mac = random_mac() self.carrier = False self.vlan_id = 1 + self.add_dbus_interface(IFACE_VLAN, self.__get_props, VlanDevice.PropertiesChanged) + Device.__init__(self, bus, iface, NM_DEVICE_TYPE_VLAN) + # Properties interface def __get_props(self): props = {} @@ -300,8 +302,6 @@ class WifiAp(ExportedObj): def __init__(self, bus, ssid, mac, flags, wpaf, rsnf, freq): path = "/org/freedesktop/NetworkManager/AccessPoint/%d" % WifiAp.counter WifiAp.counter = WifiAp.counter + 1 - ExportedObj.__init__(self, bus, path) - self.add_dbus_interface(IFACE_WIFI_AP, self.__get_props, WifiAp.PropertiesChanged) self.ssid = ssid if mac: @@ -315,6 +315,9 @@ class WifiAp(ExportedObj): self.strength = random.randint(0, 100) self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None) + self.add_dbus_interface(IFACE_WIFI_AP, self.__get_props, WifiAp.PropertiesChanged) + ExportedObj.__init__(self, bus, path) + def __del__(self): if self.strength_id > 0: GLib.source_remove(self.strength_id) @@ -362,13 +365,13 @@ PW_WIRELESS_CAPABILITIES = "WirelessCapabilities" class WifiDevice(Device): def __init__(self, bus, iface): - Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIFI) - self.add_dbus_interface(IFACE_WIFI, self.__get_props, WifiDevice.PropertiesChanged) - self.mac = random_mac() self.aps = [] self.active_ap = None + self.add_dbus_interface(IFACE_WIFI, self.__get_props, WifiDevice.PropertiesChanged) + Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIFI) + # methods @dbus.service.method(dbus_interface=IFACE_WIFI, in_signature='', out_signature='ao') def GetAccessPoints(self): @@ -448,13 +451,14 @@ class WimaxNsp(ExportedObj): def __init__(self, bus, name): path = "/org/freedesktop/NetworkManager/Nsp/%d" % WimaxNsp.counter WimaxNsp.counter = WimaxNsp.counter + 1 - ExportedObj.__init__(self, bus, path) - self.add_dbus_interface(IFACE_WIMAX_NSP, self.__get_props, WimaxNsp.PropertiesChanged) self.name = name self.strength = random.randint(0, 100) self.strength_id = GLib.timeout_add_seconds(10, self.strength_cb, None) + self.add_dbus_interface(IFACE_WIMAX_NSP, self.__get_props, WimaxNsp.PropertiesChanged) + ExportedObj.__init__(self, bus, path) + def __del__(self): if self.strength_id > 0: GLib.source_remove(self.strength_id) @@ -497,14 +501,14 @@ PX_ACTIVE_NSP = "ActiveNsp" class WimaxDevice(Device): def __init__(self, bus, iface): - Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIMAX) - self.add_dbus_interface(IFACE_WIMAX, self.__get_props, WimaxDevice.PropertiesChanged) - self.mac = random_mac() self.bsid = random_mac() self.nsps = [] self.active_nsp = None + self.add_dbus_interface(IFACE_WIMAX, self.__get_props, WimaxDevice.PropertiesChanged) + Device.__init__(self, bus, iface, NM_DEVICE_TYPE_WIMAX) + # methods @dbus.service.method(dbus_interface=IFACE_WIMAX, in_signature='', out_signature='ao') def GetNspList(self): @@ -587,8 +591,6 @@ class ActiveConnection(ExportedObj): def __init__(self, bus, device, connection, specific_object): object_path = "/org/freedesktop/NetworkManager/ActiveConnection/%d" % ActiveConnection.counter ActiveConnection.counter = ActiveConnection.counter + 1 - ExportedObj.__init__(self, bus, object_path) - self.add_dbus_interface(IFACE_ACTIVE_CONNECTION, self.__get_props, ActiveConnection.PropertiesChanged) self.device = device self.conn = connection @@ -603,6 +605,9 @@ class ActiveConnection(ExportedObj): self.vpn = False self.master = None + self.add_dbus_interface(IFACE_ACTIVE_CONNECTION, self.__get_props, ActiveConnection.PropertiesChanged) + ExportedObj.__init__(self, bus, object_path) + # Properties interface def __get_props(self): props = {} @@ -664,9 +669,6 @@ def set_device_ac_cb(device, ac): class NetworkManager(ExportedObj): def __init__(self, bus, object_path): - ExportedObj.__init__(self, bus, object_path) - self.add_dbus_interface(IFACE_NM, self.__get_props, NetworkManager.PropertiesChanged) - self._bus = bus; self.devices = [] self.active_connections = [] @@ -675,6 +677,9 @@ class NetworkManager(ExportedObj): self.state = NM_STATE_DISCONNECTED self.connectivity = 1 + self.add_dbus_interface(IFACE_NM, self.__get_props, NetworkManager.PropertiesChanged) + ExportedObj.__init__(self, bus, object_path) + @dbus.service.signal(IFACE_NM, signature='u') def StateChanged(self, new_state): pass |