mirror of
				https://github.com/home-assistant/supervisor.git
				synced 2025-11-04 08:29:40 +00:00 
			
		
		
		
	* Use the correct interface name to get properties of systemd It seems that gdbus (or systemd) automatically pick the correct interface and return the properties. However, dbussy requires the correct interface name to get all properties. * Don't expect array from Strength property The property returns a type "y" which equates to "guchar": https://developer-old.gnome.org/NetworkManager/stable/gdbus-org.freedesktop.NetworkManager.AccessPoint.html#gdbus-property-org-freedesktop-NetworkManager-AccessPoint.Strength It seems that the old D-Bus implementation returned an array. With dbus-next a integer is returned, so no list indexing required. * Support signals and remove no longer used tests and code * Pass rauc update file path as string That is what the interface is expecting, otherwise the new lib chocks on the Pathlib type. * Support Network configuration with dbus-next Assemble Python native objects and pass them to dbus-next. Use dbus-next specific Variant class where necessary. * Use org.freedesktop.NetworkManager.Connection.Active.StateChanged org.freedesktop.NetworkManager.Connection.Active.PropertyChanged is depricated. Also it seems that StateChanged leads to fewer and more accurate signals. * Pass correct data type to RequestScan. RequestScan expects an option dictionary. Pass an empty option dictionary to it. * Update unit tests Replace gdbus specific fixtures with json files representing the return values. Those can be easily converted into native Python objects. * Rename D-Bus utils module gdbus to dbus
		
			
				
	
	
		
			37 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
"""Test NetwrokInterface."""
 | 
						|
import pytest
 | 
						|
 | 
						|
from supervisor.dbus.const import DeviceType
 | 
						|
from supervisor.dbus.network import NetworkManager
 | 
						|
from supervisor.dbus.network.setting.generate import get_connection_from_interface
 | 
						|
from supervisor.host.network import Interface
 | 
						|
 | 
						|
from tests.const import TEST_INTERFACE, TEST_INTERFACE_WLAN
 | 
						|
 | 
						|
 | 
						|
@pytest.mark.asyncio
 | 
						|
async def test_get_connection_from_interface(network_manager: NetworkManager):
 | 
						|
    """Test network interface."""
 | 
						|
    dbus_interface = network_manager.interfaces[TEST_INTERFACE]
 | 
						|
    interface = Interface.from_dbus_interface(dbus_interface)
 | 
						|
    connection_payload = get_connection_from_interface(interface)
 | 
						|
 | 
						|
    assert "connection" in connection_payload
 | 
						|
 | 
						|
    assert connection_payload["connection"]["interface-name"].value == TEST_INTERFACE
 | 
						|
    assert connection_payload["connection"]["type"].value == "802-3-ethernet"
 | 
						|
 | 
						|
    assert connection_payload["ipv4"]["method"].value == "auto"
 | 
						|
    assert "address-data" not in connection_payload["ipv4"]
 | 
						|
 | 
						|
    assert connection_payload["ipv6"]["method"].value == "auto"
 | 
						|
    assert "address-data" not in connection_payload["ipv6"]
 | 
						|
 | 
						|
 | 
						|
@pytest.mark.asyncio
 | 
						|
async def test_network_interface_wlan(network_manager: NetworkManager):
 | 
						|
    """Test network interface."""
 | 
						|
    interface = network_manager.interfaces[TEST_INTERFACE_WLAN]
 | 
						|
    assert interface.name == TEST_INTERFACE_WLAN
 | 
						|
    assert interface.type == DeviceType.WIRELESS
 |