Modify the relevant tests to comply with the new signal.
Note: argument matching in connect_to_signal method is
only usable with string and thus had to be refactored.
Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 2 +-
src/events.c | 14 +-------------
tests/libvirttest.py | 7 +++++++
tests/test_connect.py | 12 ++++++++----
tests/test_network.py | 18 ++++++++++++------
5 files changed, 29 insertions(+), 24 deletions(-)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 386a7bb..8272da6 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -176,7 +176,7 @@
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-network.html#virConnectNetworkEv...
<arg name="network" type="o"/>
- <arg name="event" type="s"/>
+ <arg name="event" type="u"/>
</signal>
</interface>
</node>
diff --git a/src/events.c b/src/events.c
index 601d898..1b584f7 100644
--- a/src/events.c
+++ b/src/events.c
@@ -146,14 +146,6 @@ virtDBusEventsDomainDiskChange(virConnectPtr connection
G_GNUC_UNUSED,
return 0;
}
-VIRT_DBUS_ENUM_DECL(virtDBusEventsNetworkEvent)
-VIRT_DBUS_ENUM_IMPL(virtDBusEventsNetworkEvent,
- VIR_NETWORK_EVENT_LAST,
- "Defined",
- "Undefined",
- "Started",
- "Stopped")
-
static gint
virtDBusEventsNetworkLifecycle(virConnectPtr connection G_GNUC_UNUSED,
virNetworkPtr network,
@@ -163,10 +155,6 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connection
G_GNUC_UNUSED,
{
virtDBusConnect *connect = opaque;
g_autofree gchar *path = NULL;
- const gchar *eventStr = virtDBusEventsNetworkEventTypeToString(event);
-
- if (!eventStr)
- return 0;
path = virtDBusUtilBusPathForVirNetwork(network, connect->networkPath);
@@ -175,7 +163,7 @@ virtDBusEventsNetworkLifecycle(virConnectPtr connection
G_GNUC_UNUSED,
connect->connectPath,
VIRT_DBUS_CONNECT_INTERFACE,
"NetworkEvent",
- g_variant_new("(os)", path, eventStr),
+ g_variant_new("(ou)", path, event),
NULL);
return 0;
diff --git a/tests/libvirttest.py b/tests/libvirttest.py
index 73d51e6..fc3ed5e 100644
--- a/tests/libvirttest.py
+++ b/tests/libvirttest.py
@@ -31,6 +31,13 @@ class DomainEvent(IntEnum):
CRASHED = 8
+class NetworkEvent(IntEnum):
+ DEFINED = 0
+ UNDEFINED = 1
+ STARTED = 2
+ STOPPED = 3
+
+
class BaseTestClass():
""" Base test class for whole test suite
"""
diff --git a/tests/test_connect.py b/tests/test_connect.py
index 41cc134..7748822 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -125,11 +125,13 @@ class TestConnect(libvirttest.BaseTestClass):
assert isinstance(self.connect.GetCPUModelNames(arch, 0), dbus.Array)
def test_connect_network_create_xml(self):
- def network_started(path, _event):
+ def network_started(path, event):
+ if event != libvirttest.NetworkEvent.STARTED:
+ return
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
- self.connect.connect_to_signal('NetworkEvent', network_started,
arg1='Started')
+ self.connect.connect_to_signal('NetworkEvent', network_started)
path = self.connect.NetworkCreateXML(self.minimal_network_xml)
assert isinstance(path, dbus.ObjectPath)
@@ -137,11 +139,13 @@ class TestConnect(libvirttest.BaseTestClass):
self.main_loop()
def test_connect_network_define_xml(self):
- def network_defined(path, _event):
+ def network_defined(path, event):
+ if event != libvirttest.NetworkEvent.DEFINED:
+ return
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
- self.connect.connect_to_signal('NetworkEvent', network_defined,
arg1='Defined')
+ self.connect.connect_to_signal('NetworkEvent', network_defined)
path = self.connect.NetworkDefineXML(self.minimal_network_xml)
assert isinstance(path, dbus.ObjectPath)
diff --git a/tests/test_network.py b/tests/test_network.py
index 1340d95..f34c081 100755
--- a/tests/test_network.py
+++ b/tests/test_network.py
@@ -34,11 +34,13 @@ class TestNetwork(libvirttest.BaseTestClass):
assert autostart_current == dbus.Boolean(autostart_expected)
def test_network_create(self):
- def domain_started(path, _event):
+ def domain_started(path, event):
+ if event != libvirttest.NetworkEvent.STARTED:
+ return
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
- self.connect.connect_to_signal('NetworkEvent', domain_started,
arg1='Started')
+ self.connect.connect_to_signal('NetworkEvent', domain_started)
_,test_network = self.test_network()
interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
@@ -48,11 +50,13 @@ class TestNetwork(libvirttest.BaseTestClass):
self.main_loop()
def test_network_destroy(self):
- def network_stopped(path, _event):
+ def network_stopped(path, event):
+ if event != libvirttest.NetworkEvent.STOPPED:
+ return
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
- self.connect.connect_to_signal('NetworkEvent', network_stopped,
arg1='Stopped')
+ self.connect.connect_to_signal('NetworkEvent', network_stopped)
_, test_network = self.test_network()
interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
@@ -66,11 +70,13 @@ class TestNetwork(libvirttest.BaseTestClass):
assert isinstance(interface_obj.GetXMLDesc(0), dbus.String)
def test_network_undefine(self):
- def domain_undefined(path, _event):
+ def domain_undefined(path, event):
+ if event != libvirttest.NetworkEvent.UNDEFINED:
+ return
assert isinstance(path, dbus.ObjectPath)
self.loop.quit()
- self.connect.connect_to_signal('NetworkEvent', domain_undefined,
arg1='Undefined')
+ self.connect.connect_to_signal('NetworkEvent', domain_undefined)
_,test_network = self.test_network()
interface_obj = dbus.Interface(test_network, 'org.libvirt.Network')
--
2.15.0