mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-13 04:06:33 +00:00
Empty string in gateway returns none (#3873)
This commit is contained in:
parent
50c277137d
commit
cd10b597dd
@ -39,9 +39,13 @@ class IpConfiguration(DBusInterfaceProxy):
|
||||
|
||||
@property
|
||||
@dbus_property
|
||||
def gateway(self) -> IPv4Address | IPv6Address:
|
||||
def gateway(self) -> IPv4Address | IPv6Address | None:
|
||||
"""Get gateway."""
|
||||
return ip_address(self.properties[DBUS_ATTR_GATEWAY])
|
||||
return (
|
||||
ip_address(self.properties[DBUS_ATTR_GATEWAY])
|
||||
if self.properties.get(DBUS_ATTR_GATEWAY)
|
||||
else None
|
||||
)
|
||||
|
||||
@property
|
||||
@dbus_property
|
||||
|
@ -40,3 +40,11 @@ async def test_ipv6_configuration(network_manager: NetworkManager):
|
||||
fire_property_change_signal(ipv6, {}, ["Gateway"])
|
||||
await asyncio.sleep(0)
|
||||
assert ipv6.gateway == IPv6Address("fe80::da58:d7ff:fe00:9c69")
|
||||
|
||||
|
||||
async def test_gateway_empty_string(network_manager: NetworkManager):
|
||||
"""Test empty string in gateway returns None."""
|
||||
ipv4 = network_manager.interfaces[TEST_INTERFACE].connection.ipv4
|
||||
fire_property_change_signal(ipv4, {"Gateway": ""})
|
||||
await asyncio.sleep(0)
|
||||
assert ipv4.gateway is None
|
||||
|
Loading…
x
Reference in New Issue
Block a user