diff mbox series

[4/4] support/testing: add new test for python-sdbus-networkmanager

Message ID 20240701145708.2886402-4-raphael.melotte@mind.be
State Superseded
Headers show
Series [1/4] package/python-sdbus: new package | expand

Commit Message

Raphaël Mélotte July 1, 2024, 2:57 p.m. UTC
Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be>
---
 DEVELOPERS                                    |  2 ++
 .../sample_python_sdbus_networkmanager.py     | 20 +++++++++++++++++++
 .../test_python_sdbus_networkmanager.py       | 15 ++++++++++++++
 3 files changed, 37 insertions(+)
 create mode 100644 support/testing/tests/package/sample_python_sdbus_networkmanager.py
 create mode 100644 support/testing/tests/package/test_python_sdbus_networkmanager.py
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 9abf2d490b..0b17e46dca 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2674,10 +2674,12 @@  F:	support/testing/tests/package/sample_python_jmespath.py
 F:	support/testing/tests/package/sample_python_rsa.py
 F:	support/testing/tests/package/sample_python_s3transfer.py
 F:	support/testing/tests/package/sample_python_sdbus.py
+F:	support/testing/tests/package/sample_python_sdbus_networkmanager.py
 F:	support/testing/tests/package/test_python_jmespath.py
 F:	support/testing/tests/package/test_python_rsa.py
 F:	support/testing/tests/package/test_python_s3transfer.py
 F:	support/testing/tests/package/test_python_sdbus.py
+F:	support/testing/tests/package/test_python_sdbus_networkmanager.py
 
 N:	Raphael Pavlidis <raphael.pavlidis@gmail.com>
 F:	package/nvidia-persistenced/
diff --git a/support/testing/tests/package/sample_python_sdbus_networkmanager.py b/support/testing/tests/package/sample_python_sdbus_networkmanager.py
new file mode 100644
index 0000000000..e15b63ce70
--- /dev/null
+++ b/support/testing/tests/package/sample_python_sdbus_networkmanager.py
@@ -0,0 +1,20 @@ 
+#!/usr/bin/env python3
+
+import sdbus
+
+from sdbus_block.networkmanager import (
+    DeviceType,
+    NetworkManager,
+    NetworkDeviceGeneric
+)
+
+sdbus.set_default_bus(sdbus.sd_bus_open_system())
+
+nm = NetworkManager()
+devices = [NetworkDeviceGeneric(d) for d in nm.get_devices()]
+
+print([d.interface for d in devices])
+
+assert devices
+# Check that we found at least the loopback interface:
+assert [dev for dev in devices if dev.device_type == DeviceType.LOOPBACK]
diff --git a/support/testing/tests/package/test_python_sdbus_networkmanager.py b/support/testing/tests/package/test_python_sdbus_networkmanager.py
new file mode 100644
index 0000000000..a3961ec54f
--- /dev/null
+++ b/support/testing/tests/package/test_python_sdbus_networkmanager.py
@@ -0,0 +1,15 @@ 
+from tests.package.test_python import TestPythonPackageBase
+
+
+class TestPythonPy3SdbusNetworkmanager(TestPythonPackageBase):
+    __test__ = True
+    config = TestPythonPackageBase.config + \
+        """
+        BR2_PACKAGE_PYTHON3=y
+        BR2_INIT_SYSTEMD=y
+        BR2_PACKAGE_NETWORK_MANAGER=y
+        BR2_PACKAGE_PYTHON_SDBUS_NETWORKMANAGER=y
+        """
+    sample_scripts = ["tests/package/sample_python_sdbus_networkmanager.py"]
+
+    timeout = 30