mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
parent
3d580259e1
commit
0fdf037ba0
@ -85,11 +85,11 @@ def get_schema(prop, name, groups):
|
|||||||
if name == LOAD_BUTTON:
|
if name == LOAD_BUTTON:
|
||||||
button_list = {group: groups[group].name for group in groups}
|
button_list = {group: groups[group].name for group in groups}
|
||||||
return _list_schema(name, button_list)
|
return _list_schema(name, button_list)
|
||||||
if prop.value_type == bool:
|
if prop.value_type is bool:
|
||||||
return _bool_schema(name)
|
return _bool_schema(name)
|
||||||
if prop.value_type == int:
|
if prop.value_type is int:
|
||||||
return _byte_schema(name)
|
return _byte_schema(name)
|
||||||
if prop.value_type == float:
|
if prop.value_type is float:
|
||||||
return _float_schema(name)
|
return _float_schema(name)
|
||||||
if prop.value_type == ToggleMode:
|
if prop.value_type == ToggleMode:
|
||||||
return _list_schema(name, TOGGLE_MODES)
|
return _list_schema(name, TOGGLE_MODES)
|
||||||
|
@ -121,7 +121,7 @@ async def test_login(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
assert result["step_id"] == "mfa"
|
assert result["step_id"] == "mfa"
|
||||||
assert result["data_schema"].schema.get("pin") == str
|
assert result["data_schema"].schema.get("pin") is str
|
||||||
|
|
||||||
result = await hass.auth.login_flow.async_configure(
|
result = await hass.auth.login_flow.async_configure(
|
||||||
result["flow_id"], {"pin": "invalid-code"}
|
result["flow_id"], {"pin": "invalid-code"}
|
||||||
|
@ -155,7 +155,7 @@ async def test_login_flow_validates_mfa(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
assert result["step_id"] == "mfa"
|
assert result["step_id"] == "mfa"
|
||||||
assert result["data_schema"].schema.get("code") == str
|
assert result["data_schema"].schema.get("code") is str
|
||||||
|
|
||||||
# wait service call finished
|
# wait service call finished
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
@ -214,7 +214,7 @@ async def test_login_flow_validates_mfa(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
assert result["step_id"] == "mfa"
|
assert result["step_id"] == "mfa"
|
||||||
assert result["data_schema"].schema.get("code") == str
|
assert result["data_schema"].schema.get("code") is str
|
||||||
|
|
||||||
# wait service call finished
|
# wait service call finished
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
@ -114,7 +114,7 @@ async def test_login_flow_validates_mfa(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
assert result["type"] == data_entry_flow.FlowResultType.FORM
|
||||||
assert result["step_id"] == "mfa"
|
assert result["step_id"] == "mfa"
|
||||||
assert result["data_schema"].schema.get("code") == str
|
assert result["data_schema"].schema.get("code") is str
|
||||||
|
|
||||||
with patch("pyotp.TOTP.verify", return_value=False):
|
with patch("pyotp.TOTP.verify", return_value=False):
|
||||||
result = await hass.auth.login_flow.async_configure(
|
result = await hass.auth.login_flow.async_configure(
|
||||||
|
@ -646,7 +646,7 @@ async def test_restore_number_restore_state(
|
|||||||
assert entity0.native_min_value == native_min_value
|
assert entity0.native_min_value == native_min_value
|
||||||
assert entity0.native_step == native_step
|
assert entity0.native_step == native_step
|
||||||
assert entity0.native_value == native_value
|
assert entity0.native_value == native_value
|
||||||
assert type(entity0.native_value) == native_value_type
|
assert type(entity0.native_value) is native_value_type
|
||||||
assert entity0.native_unit_of_measurement == uom
|
assert entity0.native_unit_of_measurement == uom
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ async def test_show_config_form_device_type_airlock(hass: HomeAssistant) -> None
|
|||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "api_method"
|
assert result["step_id"] == "api_method"
|
||||||
assert result["data_schema"].schema.get(CONF_TOKEN) == str
|
assert result["data_schema"].schema.get(CONF_TOKEN) is str
|
||||||
assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) == bool
|
assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) is bool
|
||||||
|
|
||||||
|
|
||||||
async def test_show_config_form_device_type_keg(hass: HomeAssistant) -> None:
|
async def test_show_config_form_device_type_keg(hass: HomeAssistant) -> None:
|
||||||
@ -78,7 +78,7 @@ async def test_show_config_form_device_type_keg(hass: HomeAssistant) -> None:
|
|||||||
|
|
||||||
assert result["type"] is FlowResultType.FORM
|
assert result["type"] is FlowResultType.FORM
|
||||||
assert result["step_id"] == "api_method"
|
assert result["step_id"] == "api_method"
|
||||||
assert result["data_schema"].schema.get(CONF_TOKEN) == str
|
assert result["data_schema"].schema.get(CONF_TOKEN) is str
|
||||||
assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) is None
|
assert result["data_schema"].schema.get(CONF_USE_WEBHOOK) is None
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ raise Exception('boom')
|
|||||||
task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True)
|
task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True)
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
|
|
||||||
assert type(task.exception()) == HomeAssistantError
|
assert type(task.exception()) is HomeAssistantError
|
||||||
assert "Error executing script (Exception): boom" in str(task.exception())
|
assert "Error executing script (Exception): boom" in str(task.exception())
|
||||||
|
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ hass.async_stop()
|
|||||||
task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True)
|
task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True)
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
|
|
||||||
assert type(task.exception()) == ServiceValidationError
|
assert type(task.exception()) is ServiceValidationError
|
||||||
assert "Not allowed to access async methods" in str(task.exception())
|
assert "Not allowed to access async methods" in str(task.exception())
|
||||||
|
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ async def test_accessing_forbidden_methods_with_response(hass: HomeAssistant) ->
|
|||||||
task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True)
|
task = hass.async_add_executor_job(execute, hass, "test.py", source, {}, True)
|
||||||
await hass.async_block_till_done(wait_background_tasks=True)
|
await hass.async_block_till_done(wait_background_tasks=True)
|
||||||
|
|
||||||
assert type(task.exception()) == ServiceValidationError
|
assert type(task.exception()) is ServiceValidationError
|
||||||
assert f"Not allowed to access {name}" in str(task.exception())
|
assert f"Not allowed to access {name}" in str(task.exception())
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ async def test_web_full_flow(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
assert result.get("data_schema").schema.get("server_url") == str
|
assert result.get("data_schema").schema.get("server_url") is str
|
||||||
assert not result.get("errors")
|
assert not result.get("errors")
|
||||||
with (
|
with (
|
||||||
patch("rtsp_to_webrtc.client.Client.heartbeat"),
|
patch("rtsp_to_webrtc.client.Client.heartbeat"),
|
||||||
@ -64,7 +64,7 @@ async def test_invalid_url(hass: HomeAssistant) -> None:
|
|||||||
)
|
)
|
||||||
assert result.get("type") is FlowResultType.FORM
|
assert result.get("type") is FlowResultType.FORM
|
||||||
assert result.get("step_id") == "user"
|
assert result.get("step_id") == "user"
|
||||||
assert result.get("data_schema").schema.get("server_url") == str
|
assert result.get("data_schema").schema.get("server_url") is str
|
||||||
assert not result.get("errors")
|
assert not result.get("errors")
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"], {"server_url": "not-a-url"}
|
result["flow_id"], {"server_url": "not-a-url"}
|
||||||
|
@ -418,7 +418,7 @@ async def test_restore_sensor_save_state(
|
|||||||
assert state["entity_id"] == entity0.entity_id
|
assert state["entity_id"] == entity0.entity_id
|
||||||
extra_data = hass_storage[RESTORE_STATE_KEY]["data"][0]["extra_data"]
|
extra_data = hass_storage[RESTORE_STATE_KEY]["data"][0]["extra_data"]
|
||||||
assert extra_data == expected_extra_data
|
assert extra_data == expected_extra_data
|
||||||
assert type(extra_data["native_value"]) == native_value_type
|
assert type(extra_data["native_value"]) is native_value_type
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@ -479,7 +479,7 @@ async def test_restore_sensor_restore_state(
|
|||||||
assert hass.states.get(entity0.entity_id)
|
assert hass.states.get(entity0.entity_id)
|
||||||
|
|
||||||
assert entity0.native_value == native_value
|
assert entity0.native_value == native_value
|
||||||
assert type(entity0.native_value) == native_value_type
|
assert type(entity0.native_value) is native_value_type
|
||||||
assert entity0.native_unit_of_measurement == uom
|
assert entity0.native_unit_of_measurement == uom
|
||||||
|
|
||||||
|
|
||||||
|
@ -42,4 +42,4 @@ async def test_get_value_state_schema_boolean_config_value(
|
|||||||
aeon_smart_switch_6.values["102-112-0-255"]
|
aeon_smart_switch_6.values["102-112-0-255"]
|
||||||
)
|
)
|
||||||
assert isinstance(schema_validator, vol.Coerce)
|
assert isinstance(schema_validator, vol.Coerce)
|
||||||
assert schema_validator.type == bool
|
assert schema_validator.type is bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user