mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Cleanup SourceType in tests (#78809)
This commit is contained in:
parent
25b1dfb53a
commit
4f31f28e67
@ -11,7 +11,7 @@ from homeassistant.components.device_tracker.const import (
|
||||
ATTR_MAC,
|
||||
ATTR_SOURCE_TYPE,
|
||||
DOMAIN,
|
||||
SOURCE_TYPE_ROUTER,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.const import ATTR_BATTERY_LEVEL, STATE_HOME, STATE_NOT_HOME
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
@ -37,7 +37,7 @@ async def test_scanner_entity_device_tracker(hass, enable_custom_integrations):
|
||||
entity_id = "device_tracker.test_ad_de_ef_be_ed_fe"
|
||||
entity_state = hass.states.get(entity_id)
|
||||
assert entity_state.attributes == {
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER,
|
||||
ATTR_SOURCE_TYPE: SourceType.ROUTER,
|
||||
ATTR_BATTERY_LEVEL: 100,
|
||||
ATTR_IP: "0.0.0.0",
|
||||
ATTR_MAC: "ad:de:ef:be:ed:fe",
|
||||
|
@ -9,7 +9,7 @@ import pytest
|
||||
|
||||
from homeassistant.components import zone
|
||||
import homeassistant.components.device_tracker as device_tracker
|
||||
from homeassistant.components.device_tracker import const, legacy
|
||||
from homeassistant.components.device_tracker import SourceType, const, legacy
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_PICTURE,
|
||||
ATTR_FRIENDLY_NAME,
|
||||
@ -495,7 +495,7 @@ async def test_see_passive_zone_state(
|
||||
assert attrs.get("latitude") == 1
|
||||
assert attrs.get("longitude") == 2
|
||||
assert attrs.get("gps_accuracy") == 0
|
||||
assert attrs.get("source_type") == device_tracker.SOURCE_TYPE_ROUTER
|
||||
assert attrs.get("source_type") == SourceType.ROUTER
|
||||
|
||||
scanner.leave_home("dev1")
|
||||
|
||||
@ -515,7 +515,7 @@ async def test_see_passive_zone_state(
|
||||
assert attrs.get("latitude") is None
|
||||
assert attrs.get("longitude") is None
|
||||
assert attrs.get("gps_accuracy") is None
|
||||
assert attrs.get("source_type") == device_tracker.SOURCE_TYPE_ROUTER
|
||||
assert attrs.get("source_type") == SourceType.ROUTER
|
||||
|
||||
|
||||
@patch("homeassistant.components.device_tracker.const.LOGGER.warning")
|
||||
|
@ -16,7 +16,7 @@ from homeassistant.components.device_tracker import (
|
||||
ATTR_MAC,
|
||||
ATTR_SOURCE_TYPE,
|
||||
CONNECTED_DEVICE_REGISTERED,
|
||||
SOURCE_TYPE_ROUTER,
|
||||
SourceType,
|
||||
)
|
||||
from homeassistant.components.dhcp.const import DOMAIN
|
||||
from homeassistant.const import (
|
||||
@ -603,7 +603,7 @@ async def test_device_tracker_hostname_and_macaddress_exists_before_start(hass):
|
||||
{
|
||||
ATTR_HOST_NAME: "Connect",
|
||||
ATTR_IP: "192.168.210.56",
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER,
|
||||
ATTR_SOURCE_TYPE: SourceType.ROUTER,
|
||||
ATTR_MAC: "B8:B7:F1:6D:B5:33",
|
||||
},
|
||||
)
|
||||
@ -701,7 +701,7 @@ async def test_device_tracker_hostname_and_macaddress_after_start(hass):
|
||||
{
|
||||
ATTR_HOST_NAME: "Connect",
|
||||
ATTR_IP: "192.168.210.56",
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER,
|
||||
ATTR_SOURCE_TYPE: SourceType.ROUTER,
|
||||
ATTR_MAC: "B8:B7:F1:6D:B5:33",
|
||||
},
|
||||
)
|
||||
@ -738,7 +738,7 @@ async def test_device_tracker_hostname_and_macaddress_after_start_not_home(hass)
|
||||
{
|
||||
ATTR_HOST_NAME: "connect",
|
||||
ATTR_IP: "192.168.210.56",
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER,
|
||||
ATTR_SOURCE_TYPE: SourceType.ROUTER,
|
||||
ATTR_MAC: "B8:B7:F1:6D:B5:33",
|
||||
},
|
||||
)
|
||||
@ -795,7 +795,7 @@ async def test_device_tracker_hostname_and_macaddress_after_start_hostname_missi
|
||||
STATE_HOME,
|
||||
{
|
||||
ATTR_IP: "192.168.210.56",
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER,
|
||||
ATTR_SOURCE_TYPE: SourceType.ROUTER,
|
||||
ATTR_MAC: "B8:B7:F1:6D:B5:33",
|
||||
},
|
||||
)
|
||||
@ -814,7 +814,7 @@ async def test_device_tracker_ignore_self_assigned_ips_before_start(hass):
|
||||
{
|
||||
ATTR_HOST_NAME: "connect",
|
||||
ATTR_IP: "169.254.210.56",
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER,
|
||||
ATTR_SOURCE_TYPE: SourceType.ROUTER,
|
||||
ATTR_MAC: "B8:B7:F1:6D:B5:33",
|
||||
},
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
"""The device tracker tests for the Mazda Connected Services integration."""
|
||||
from homeassistant.components.device_tracker import ATTR_SOURCE_TYPE, SOURCE_TYPE_GPS
|
||||
from homeassistant.components.device_tracker import ATTR_SOURCE_TYPE, SourceType
|
||||
from homeassistant.const import (
|
||||
ATTR_FRIENDLY_NAME,
|
||||
ATTR_ICON,
|
||||
@ -23,7 +23,7 @@ async def test_device_tracker(hass):
|
||||
assert state.attributes.get(ATTR_ICON) == "mdi:car"
|
||||
assert state.attributes.get(ATTR_LATITUDE) == 1.234567
|
||||
assert state.attributes.get(ATTR_LONGITUDE) == -2.345678
|
||||
assert state.attributes.get(ATTR_SOURCE_TYPE) == SOURCE_TYPE_GPS
|
||||
assert state.attributes.get(ATTR_SOURCE_TYPE) == SourceType.GPS
|
||||
entry = entity_registry.async_get("device_tracker.my_mazda3_device_tracker")
|
||||
assert entry
|
||||
assert entry.unique_id == "JM000000000000000"
|
||||
|
@ -5,11 +5,7 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from homeassistant.components import person
|
||||
from homeassistant.components.device_tracker import (
|
||||
ATTR_SOURCE_TYPE,
|
||||
SOURCE_TYPE_GPS,
|
||||
SOURCE_TYPE_ROUTER,
|
||||
)
|
||||
from homeassistant.components.device_tracker import ATTR_SOURCE_TYPE, SourceType
|
||||
from homeassistant.components.person import ATTR_SOURCE, ATTR_USER_ID, DOMAIN
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_PICTURE,
|
||||
@ -208,9 +204,7 @@ async def test_setup_two_trackers(hass, hass_admin_user):
|
||||
|
||||
hass.bus.async_fire(EVENT_HOMEASSISTANT_START)
|
||||
await hass.async_block_till_done()
|
||||
hass.states.async_set(
|
||||
DEVICE_TRACKER, "home", {ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER}
|
||||
)
|
||||
hass.states.async_set(DEVICE_TRACKER, "home", {ATTR_SOURCE_TYPE: SourceType.ROUTER})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("person.tracked_person")
|
||||
@ -229,12 +223,12 @@ async def test_setup_two_trackers(hass, hass_admin_user):
|
||||
ATTR_LATITUDE: 12.123456,
|
||||
ATTR_LONGITUDE: 13.123456,
|
||||
ATTR_GPS_ACCURACY: 12,
|
||||
ATTR_SOURCE_TYPE: SOURCE_TYPE_GPS,
|
||||
ATTR_SOURCE_TYPE: SourceType.GPS,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
hass.states.async_set(
|
||||
DEVICE_TRACKER, "not_home", {ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER}
|
||||
DEVICE_TRACKER, "not_home", {ATTR_SOURCE_TYPE: SourceType.ROUTER}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@ -247,22 +241,16 @@ async def test_setup_two_trackers(hass, hass_admin_user):
|
||||
assert state.attributes.get(ATTR_SOURCE) == DEVICE_TRACKER_2
|
||||
assert state.attributes.get(ATTR_USER_ID) == user_id
|
||||
|
||||
hass.states.async_set(
|
||||
DEVICE_TRACKER_2, "zone1", {ATTR_SOURCE_TYPE: SOURCE_TYPE_GPS}
|
||||
)
|
||||
hass.states.async_set(DEVICE_TRACKER_2, "zone1", {ATTR_SOURCE_TYPE: SourceType.GPS})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("person.tracked_person")
|
||||
assert state.state == "zone1"
|
||||
assert state.attributes.get(ATTR_SOURCE) == DEVICE_TRACKER_2
|
||||
|
||||
hass.states.async_set(
|
||||
DEVICE_TRACKER, "home", {ATTR_SOURCE_TYPE: SOURCE_TYPE_ROUTER}
|
||||
)
|
||||
hass.states.async_set(DEVICE_TRACKER, "home", {ATTR_SOURCE_TYPE: SourceType.ROUTER})
|
||||
await hass.async_block_till_done()
|
||||
hass.states.async_set(
|
||||
DEVICE_TRACKER_2, "zone2", {ATTR_SOURCE_TYPE: SOURCE_TYPE_GPS}
|
||||
)
|
||||
hass.states.async_set(DEVICE_TRACKER_2, "zone2", {ATTR_SOURCE_TYPE: SourceType.GPS})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("person.tracked_person")
|
||||
|
@ -7,7 +7,7 @@ import pytest
|
||||
import zigpy.profiles.zha
|
||||
import zigpy.zcl.clusters.general as general
|
||||
|
||||
from homeassistant.components.device_tracker import SOURCE_TYPE_ROUTER
|
||||
from homeassistant.components.device_tracker import SourceType
|
||||
from homeassistant.components.zha.core.registries import (
|
||||
SMARTTHINGS_ARRIVAL_SENSOR_DEVICE_TYPE,
|
||||
)
|
||||
@ -101,7 +101,7 @@ async def test_device_tracker(hass, zha_device_joined_restored, zigpy_device_dt)
|
||||
entity = hass.data[Platform.DEVICE_TRACKER].get_entity(entity_id)
|
||||
|
||||
assert entity.is_connected is True
|
||||
assert entity.source_type == SOURCE_TYPE_ROUTER
|
||||
assert entity.source_type == SourceType.ROUTER
|
||||
assert entity.battery_level == 100
|
||||
|
||||
# test adding device tracker to the network and HA
|
||||
|
Loading…
x
Reference in New Issue
Block a user