71803418e5
Shelly device management app with mDNS/subnet discovery, inventory, configuration, and mass operations for Gen1/Gen2+ devices. Includes .gitignore excluding runtime data (device DB, user config), AI conversation history, build artifacts, and common Python/OS patterns.
30 lines
780 B
Python
30 lines
780 B
Python
"""CIDR host listing for subnet discovery (incl. /32 fix)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import ipaddress
|
|
|
|
from shelly_manager.core.discovery import (
|
|
cidr_probe_host_list,
|
|
hosts_for_ip_network,
|
|
)
|
|
|
|
|
|
def test_hosts_for_ip_network_slash_32_includes_address() -> None:
|
|
net = ipaddress.ip_network("192.168.23.120/32", strict=False)
|
|
assert net.num_addresses == 1
|
|
assert hosts_for_ip_network(net) == ["192.168.23.120"]
|
|
|
|
|
|
def test_cidr_probe_host_list_slash_24() -> None:
|
|
hosts, ok = cidr_probe_host_list("192.168.23.0/24")
|
|
assert ok
|
|
assert "192.168.23.120" in hosts
|
|
assert "192.168.23.1" in hosts
|
|
|
|
|
|
def test_cidr_probe_host_list_invalid() -> None:
|
|
hosts, ok = cidr_probe_host_list("not-a-cidr")
|
|
assert not ok
|
|
assert hosts == []
|