mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Drop Windows compatibility code from systemmonitor integration (#152545)
This commit is contained in:
@@ -21,12 +21,6 @@ def get_all_disk_mounts(
|
||||
"""Return all disk mount points on system."""
|
||||
disks: set[str] = set()
|
||||
for part in psutil_wrapper.psutil.disk_partitions(all=True):
|
||||
if os.name == "nt":
|
||||
if "cdrom" in part.opts or part.fstype == "":
|
||||
# skip cd-rom drives with no disk in it; they may raise
|
||||
# ENOENT, pop-up a Windows GUI error for a non-ready
|
||||
# partition or just hang.
|
||||
continue
|
||||
if part.fstype in SKIP_DISK_TYPES:
|
||||
# Ignore disks which are memory
|
||||
continue
|
||||
|
||||
@@ -176,7 +176,6 @@ def mock_psutil(mock_process: list[MockProcess]) -> Generator:
|
||||
mock_psutil.disk_partitions.return_value = [
|
||||
sdiskpart("test", "/", "ext4", ""),
|
||||
sdiskpart("test2", "/media/share", "ext4", ""),
|
||||
sdiskpart("test3", "/incorrect", "", ""),
|
||||
sdiskpart("hosts", "/etc/hosts", "bind", ""),
|
||||
sdiskpart("proc", "/proc/run", "proc", ""),
|
||||
]
|
||||
@@ -197,7 +196,6 @@ def mock_os() -> Generator:
|
||||
patch("homeassistant.components.systemmonitor.coordinator.os") as mock_os,
|
||||
patch("homeassistant.components.systemmonitor.util.os") as mock_os_util,
|
||||
):
|
||||
mock_os_util.name = "nt"
|
||||
mock_os.getloadavg.return_value = (1, 2, 3)
|
||||
mock_os_util.path.isdir = isdir
|
||||
yield mock_os
|
||||
|
||||
@@ -313,19 +313,6 @@ async def test_processor_temperature(
|
||||
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
with patch("sys.platform", "nt"):
|
||||
mock_psutil.sensors_temperatures.return_value = None
|
||||
mock_psutil.sensors_temperatures.side_effect = AttributeError(
|
||||
"sensors_temperatures not exist"
|
||||
)
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
temp_entity = hass.states.get("sensor.system_monitor_processor_temperature")
|
||||
assert temp_entity.state == STATE_UNAVAILABLE
|
||||
assert await hass.config_entries.async_unload(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
with patch("sys.platform", "darwin"):
|
||||
mock_psutil.sensors_temperatures.return_value = {
|
||||
"cpu0-thermal": [shwtemp("cpu0-thermal", 50.0, 60.0, 70.0)]
|
||||
|
||||
@@ -52,7 +52,6 @@ async def test_disk_util(
|
||||
mock_psutil.psutil.disk_partitions.return_value = [
|
||||
sdiskpart("test", "/", "ext4", ""), # Should be ok
|
||||
sdiskpart("test2", "/media/share", "ext4", ""), # Should be ok
|
||||
sdiskpart("test3", "/incorrect", "", ""), # Should be skipped as no type
|
||||
sdiskpart(
|
||||
"proc", "/proc/run", "proc", ""
|
||||
), # Should be skipped as in skipped disk types
|
||||
@@ -62,7 +61,6 @@ async def test_disk_util(
|
||||
"tmpfs",
|
||||
"",
|
||||
), # Should be skipped as in skipped disk types
|
||||
sdiskpart("test5", "E:", "cd", "cdrom"), # Should be skipped as cdrom
|
||||
]
|
||||
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
@@ -71,13 +69,9 @@ async def test_disk_util(
|
||||
|
||||
disk_sensor1 = hass.states.get("sensor.system_monitor_disk_free")
|
||||
disk_sensor2 = hass.states.get("sensor.system_monitor_disk_free_media_share")
|
||||
disk_sensor3 = hass.states.get("sensor.system_monitor_disk_free_incorrect")
|
||||
disk_sensor4 = hass.states.get("sensor.system_monitor_disk_free_proc_run")
|
||||
disk_sensor5 = hass.states.get("sensor.system_monitor_disk_free_tmpfs")
|
||||
disk_sensor6 = hass.states.get("sensor.system_monitor_disk_free_e")
|
||||
disk_sensor3 = hass.states.get("sensor.system_monitor_disk_free_proc_run")
|
||||
disk_sensor4 = hass.states.get("sensor.system_monitor_disk_free_tmpfs")
|
||||
assert disk_sensor1 is not None
|
||||
assert disk_sensor2 is not None
|
||||
assert disk_sensor3 is None
|
||||
assert disk_sensor4 is None
|
||||
assert disk_sensor5 is None
|
||||
assert disk_sensor6 is None
|
||||
|
||||
Reference in New Issue
Block a user