Add Bridge module to AsusWRT (#84152)
* Add Bridge module to AsusWRT * Requested changes * Requested changes * Requested changes * Add check on router attributes value
This commit is contained in:
parent
c81b6255c2
commit
8108a0f947
7 changed files with 332 additions and 214 deletions
|
@ -62,7 +62,7 @@ def mock_unique_id_fixture():
|
|||
@pytest.fixture(name="connect")
|
||||
def mock_controller_connect(mock_unique_id):
|
||||
"""Mock a successful connection."""
|
||||
with patch("homeassistant.components.asuswrt.router.AsusWrt") as service_mock:
|
||||
with patch("homeassistant.components.asuswrt.bridge.AsusWrtLegacy") as service_mock:
|
||||
service_mock.return_value.connection.async_connect = AsyncMock()
|
||||
service_mock.return_value.is_connected = True
|
||||
service_mock.return_value.connection.disconnect = Mock()
|
||||
|
@ -236,11 +236,12 @@ async def test_on_connect_failed(hass: HomeAssistant, side_effect, error) -> Non
|
|||
)
|
||||
|
||||
with PATCH_GET_HOST, patch(
|
||||
"homeassistant.components.asuswrt.router.AsusWrt"
|
||||
"homeassistant.components.asuswrt.bridge.AsusWrtLegacy"
|
||||
) as asus_wrt:
|
||||
asus_wrt.return_value.connection.async_connect = AsyncMock(
|
||||
side_effect=side_effect
|
||||
)
|
||||
asus_wrt.return_value.async_get_nvram = AsyncMock(return_value={})
|
||||
asus_wrt.return_value.is_connected = False
|
||||
|
||||
result = await hass.config_entries.flow.async_configure(
|
||||
|
|
|
@ -32,7 +32,7 @@ from homeassistant.util.dt import utcnow
|
|||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
ASUSWRT_LIB = "homeassistant.components.asuswrt.router.AsusWrt"
|
||||
ASUSWRT_LIB = "homeassistant.components.asuswrt.bridge.AsusWrtLegacy"
|
||||
|
||||
HOST = "myrouter.asuswrt.com"
|
||||
IP_ADDRESS = "192.168.1.1"
|
||||
|
@ -311,28 +311,6 @@ async def test_loadavg_sensors(
|
|||
assert hass.states.get(f"{sensor_prefix}_load_avg_15m").state == "1.3"
|
||||
|
||||
|
||||
async def test_temperature_sensors_fail(
|
||||
hass: HomeAssistant,
|
||||
connect,
|
||||
mock_available_temps,
|
||||
) -> None:
|
||||
"""Test fail creating AsusWRT temperature sensors."""
|
||||
config_entry, sensor_prefix = _setup_entry(hass, CONFIG_DATA, SENSORS_TEMP)
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
# Only length of 3 booleans is valid. Checking the exception handling.
|
||||
mock_available_temps.pop(2)
|
||||
|
||||
# initial devices setup
|
||||
assert await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
# assert temperature availability exception is handled correctly
|
||||
assert not hass.states.get(f"{sensor_prefix}_2_4ghz_temperature")
|
||||
assert not hass.states.get(f"{sensor_prefix}_5ghz_temperature")
|
||||
assert not hass.states.get(f"{sensor_prefix}_cpu_temperature")
|
||||
|
||||
|
||||
async def test_temperature_sensors(
|
||||
hass: HomeAssistant,
|
||||
connect,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue