Remove device_registry fixture from zwave_js tests (#51072)

This commit is contained in:
Raman Gupta 2021-05-25 11:48:21 -04:00 committed by GitHub
parent 727ca79b93
commit c0234df136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 33 deletions

View File

@ -10,8 +10,6 @@ from zwave_js_server.model.driver import Driver
from zwave_js_server.model.node import Node from zwave_js_server.model.node import Node
from zwave_js_server.version import VersionInfo from zwave_js_server.version import VersionInfo
from homeassistant.helpers.device_registry import async_get as async_get_device_registry
from tests.common import MockConfigEntry, load_fixture from tests.common import MockConfigEntry, load_fixture
# Add-on fixtures # Add-on fixtures
@ -137,12 +135,6 @@ def create_snapshot_fixture():
yield create_shapshot yield create_shapshot
@pytest.fixture(name="device_registry")
async def device_registry_fixture(hass):
"""Return the device registry."""
return async_get_device_registry(hass)
@pytest.fixture(name="controller_state", scope="session") @pytest.fixture(name="controller_state", scope="session")
def controller_state_fixture(): def controller_state_fixture():
"""Load the controller state fixture data.""" """Load the controller state fixture data."""

View File

@ -128,10 +128,9 @@ async def test_listen_failure(hass, client, error):
assert entry.state is ConfigEntryState.SETUP_RETRY assert entry.state is ConfigEntryState.SETUP_RETRY
async def test_on_node_added_ready( async def test_on_node_added_ready(hass, multisensor_6_state, client, integration):
hass, multisensor_6_state, client, integration, device_registry
):
"""Test we handle a ready node added event.""" """Test we handle a ready node added event."""
dev_reg = dr.async_get(hass)
node = Node(client, multisensor_6_state) node = Node(client, multisensor_6_state)
event = {"node": node} event = {"node": node}
air_temperature_device_id = f"{client.driver.controller.home_id}-{node.node_id}" air_temperature_device_id = f"{client.driver.controller.home_id}-{node.node_id}"
@ -139,7 +138,7 @@ async def test_on_node_added_ready(
state = hass.states.get(AIR_TEMPERATURE_SENSOR) state = hass.states.get(AIR_TEMPERATURE_SENSOR)
assert not state # entity and device not yet added assert not state # entity and device not yet added
assert not device_registry.async_get_device( assert not dev_reg.async_get_device(
identifiers={(DOMAIN, air_temperature_device_id)} identifiers={(DOMAIN, air_temperature_device_id)}
) )
@ -150,9 +149,7 @@ async def test_on_node_added_ready(
assert state # entity and device added assert state # entity and device added
assert state.state != STATE_UNAVAILABLE assert state.state != STATE_UNAVAILABLE
assert device_registry.async_get_device( assert dev_reg.async_get_device(identifiers={(DOMAIN, air_temperature_device_id)})
identifiers={(DOMAIN, air_temperature_device_id)}
)
async def test_unique_id_migration_dupes( async def test_unique_id_migration_dupes(
@ -473,10 +470,9 @@ async def test_old_entity_migration_notification_binary_sensor(
) )
async def test_on_node_added_not_ready( async def test_on_node_added_not_ready(hass, multisensor_6_state, client, integration):
hass, multisensor_6_state, client, integration, device_registry
):
"""Test we handle a non ready node added event.""" """Test we handle a non ready node added event."""
dev_reg = dr.async_get(hass)
node_data = deepcopy(multisensor_6_state) # Copy to allow modification in tests. node_data = deepcopy(multisensor_6_state) # Copy to allow modification in tests.
node = Node(client, node_data) node = Node(client, node_data)
node.data["ready"] = False node.data["ready"] = False
@ -486,7 +482,7 @@ async def test_on_node_added_not_ready(
state = hass.states.get(AIR_TEMPERATURE_SENSOR) state = hass.states.get(AIR_TEMPERATURE_SENSOR)
assert not state # entity and device not yet added assert not state # entity and device not yet added
assert not device_registry.async_get_device( assert not dev_reg.async_get_device(
identifiers={(DOMAIN, air_temperature_device_id)} identifiers={(DOMAIN, air_temperature_device_id)}
) )
@ -496,9 +492,7 @@ async def test_on_node_added_not_ready(
state = hass.states.get(AIR_TEMPERATURE_SENSOR) state = hass.states.get(AIR_TEMPERATURE_SENSOR)
assert not state # entity not yet added but device added in registry assert not state # entity not yet added but device added in registry
assert device_registry.async_get_device( assert dev_reg.async_get_device(identifiers={(DOMAIN, air_temperature_device_id)})
identifiers={(DOMAIN, air_temperature_device_id)}
)
node.data["ready"] = True node.data["ready"] = True
node.emit("ready", event) node.emit("ready", event)
@ -510,10 +504,9 @@ async def test_on_node_added_not_ready(
assert state.state != STATE_UNAVAILABLE assert state.state != STATE_UNAVAILABLE
async def test_existing_node_ready( async def test_existing_node_ready(hass, client, multisensor_6, integration):
hass, client, multisensor_6, integration, device_registry
):
"""Test we handle a ready node that exists during integration setup.""" """Test we handle a ready node that exists during integration setup."""
dev_reg = dr.async_get(hass)
node = multisensor_6 node = multisensor_6
air_temperature_device_id = f"{client.driver.controller.home_id}-{node.node_id}" air_temperature_device_id = f"{client.driver.controller.home_id}-{node.node_id}"
@ -521,9 +514,7 @@ async def test_existing_node_ready(
assert state # entity and device added assert state # entity and device added
assert state.state != STATE_UNAVAILABLE assert state.state != STATE_UNAVAILABLE
assert device_registry.async_get_device( assert dev_reg.async_get_device(identifiers={(DOMAIN, air_temperature_device_id)})
identifiers={(DOMAIN, air_temperature_device_id)}
)
async def test_null_name(hass, client, null_name_check, integration): async def test_null_name(hass, client, null_name_check, integration):
@ -532,8 +523,9 @@ async def test_null_name(hass, client, null_name_check, integration):
assert hass.states.get(f"switch.node_{node.node_id}") assert hass.states.get(f"switch.node_{node.node_id}")
async def test_existing_node_not_ready(hass, client, multisensor_6, device_registry): async def test_existing_node_not_ready(hass, client, multisensor_6):
"""Test we handle a non ready node that exists during integration setup.""" """Test we handle a non ready node that exists during integration setup."""
dev_reg = dr.async_get(hass)
node = multisensor_6 node = multisensor_6
node.data = deepcopy(node.data) # Copy to allow modification in tests. node.data = deepcopy(node.data) # Copy to allow modification in tests.
node.data["ready"] = False node.data["ready"] = False
@ -548,7 +540,7 @@ async def test_existing_node_not_ready(hass, client, multisensor_6, device_regis
state = hass.states.get(AIR_TEMPERATURE_SENSOR) state = hass.states.get(AIR_TEMPERATURE_SENSOR)
assert not state # entity not yet added assert not state # entity not yet added
assert device_registry.async_get_device( # device should be added assert dev_reg.async_get_device( # device should be added
identifiers={(DOMAIN, air_temperature_device_id)} identifiers={(DOMAIN, air_temperature_device_id)}
) )
@ -560,9 +552,7 @@ async def test_existing_node_not_ready(hass, client, multisensor_6, device_regis
assert state # entity and device added assert state # entity and device added
assert state.state != STATE_UNAVAILABLE assert state.state != STATE_UNAVAILABLE
assert device_registry.async_get_device( assert dev_reg.async_get_device(identifiers={(DOMAIN, air_temperature_device_id)})
identifiers={(DOMAIN, air_temperature_device_id)}
)
async def test_start_addon( async def test_start_addon(