Use new enums in knx tests (#62513)

* Use new enums in knx tests

* Code review: Swap == for is
This commit is contained in:
Dave T 2021-12-22 08:31:23 +00:00 committed by GitHub
parent f135d77a27
commit c7b910ca33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 16 deletions

View File

@ -4,14 +4,9 @@ from unittest.mock import patch
from homeassistant.components.knx.const import CONF_STATE_ADDRESS, CONF_SYNC_STATE from homeassistant.components.knx.const import CONF_STATE_ADDRESS, CONF_SYNC_STATE
from homeassistant.components.knx.schema import BinarySensorSchema from homeassistant.components.knx.schema import BinarySensorSchema
from homeassistant.const import ( from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME, STATE_OFF, STATE_ON
CONF_ENTITY_CATEGORY,
CONF_NAME,
ENTITY_CATEGORY_DIAGNOSTIC,
STATE_OFF,
STATE_ON,
)
from homeassistant.core import HomeAssistant, State from homeassistant.core import HomeAssistant, State
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_registry import ( from homeassistant.helpers.entity_registry import (
async_get_registry as async_get_entity_registry, async_get_registry as async_get_entity_registry,
) )
@ -30,7 +25,7 @@ async def test_binary_sensor_entity_category(hass: HomeAssistant, knx: KNXTestKi
{ {
CONF_NAME: "test_normal", CONF_NAME: "test_normal",
CONF_STATE_ADDRESS: "1/1/1", CONF_STATE_ADDRESS: "1/1/1",
CONF_ENTITY_CATEGORY: ENTITY_CATEGORY_DIAGNOSTIC, CONF_ENTITY_CATEGORY: EntityCategory.DIAGNOSTIC,
}, },
] ]
} }
@ -42,7 +37,7 @@ async def test_binary_sensor_entity_category(hass: HomeAssistant, knx: KNXTestKi
registry = await async_get_entity_registry(hass) registry = await async_get_entity_registry(hass)
entity = registry.async_get("binary_sensor.test_normal") entity = registry.async_get("binary_sensor.test_normal")
assert entity.entity_category == ENTITY_CATEGORY_DIAGNOSTIC assert entity.entity_category is EntityCategory.DIAGNOSTIC
async def test_binary_sensor(hass: HomeAssistant, knx: KNXTestKit): async def test_binary_sensor(hass: HomeAssistant, knx: KNXTestKit):

View File

@ -2,12 +2,9 @@
from homeassistant.components.knx.const import KNX_ADDRESS from homeassistant.components.knx.const import KNX_ADDRESS
from homeassistant.components.knx.schema import SceneSchema from homeassistant.components.knx.schema import SceneSchema
from homeassistant.const import ( from homeassistant.const import CONF_ENTITY_CATEGORY, CONF_NAME
CONF_ENTITY_CATEGORY,
CONF_NAME,
ENTITY_CATEGORY_DIAGNOSTIC,
)
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_registry import ( from homeassistant.helpers.entity_registry import (
async_get_registry as async_get_entity_registry, async_get_registry as async_get_entity_registry,
) )
@ -24,7 +21,7 @@ async def test_activate_knx_scene(hass: HomeAssistant, knx: KNXTestKit):
CONF_NAME: "test", CONF_NAME: "test",
SceneSchema.CONF_SCENE_NUMBER: 24, SceneSchema.CONF_SCENE_NUMBER: 24,
KNX_ADDRESS: "1/1/1", KNX_ADDRESS: "1/1/1",
CONF_ENTITY_CATEGORY: ENTITY_CATEGORY_DIAGNOSTIC, CONF_ENTITY_CATEGORY: EntityCategory.DIAGNOSTIC,
}, },
] ]
} }
@ -33,7 +30,7 @@ async def test_activate_knx_scene(hass: HomeAssistant, knx: KNXTestKit):
registry = await async_get_entity_registry(hass) registry = await async_get_entity_registry(hass)
entity = registry.async_get("scene.test") entity = registry.async_get("scene.test")
assert entity.entity_category == ENTITY_CATEGORY_DIAGNOSTIC assert entity.entity_category is EntityCategory.DIAGNOSTIC
assert entity.unique_id == "1/1/1_24" assert entity.unique_id == "1/1/1_24"
await hass.services.async_call( await hass.services.async_call(