mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Move enable_bluetooth fixture to decorator (#118803)
This commit is contained in:
parent
3d31af3eb4
commit
f120f55d86
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
from unittest.mock import ANY
|
from unittest.mock import ANY
|
||||||
|
|
||||||
|
import pytest
|
||||||
from syrupy import SnapshotAssertion
|
from syrupy import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.components import bluetooth
|
from homeassistant.components import bluetooth
|
||||||
@ -14,11 +15,11 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
|
|||||||
from tests.typing import ClientSessionGenerator
|
from tests.typing import ClientSessionGenerator
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
async def test_diagnostics(
|
async def test_diagnostics(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
hass_client: ClientSessionGenerator,
|
hass_client: ClientSessionGenerator,
|
||||||
init_integration: MockConfigEntry,
|
init_integration: MockConfigEntry,
|
||||||
enable_bluetooth: None,
|
|
||||||
mock_dashboard,
|
mock_dashboard,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.ibeacon.const import CONF_ALLOW_NAMELESS_UUIDS, DOMAIN
|
from homeassistant.components.ibeacon.const import CONF_ALLOW_NAMELESS_UUIDS, DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -22,7 +24,8 @@ async def test_setup_user_no_bluetooth(
|
|||||||
assert result["reason"] == "bluetooth_not_available"
|
assert result["reason"] == "bluetooth_not_available"
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_user(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
|
async def test_setup_user(hass: HomeAssistant) -> None:
|
||||||
"""Test setting up via user interaction with bluetooth enabled."""
|
"""Test setting up via user interaction with bluetooth enabled."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
@ -39,9 +42,8 @@ async def test_setup_user(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
|||||||
assert result2["data"] == {}
|
assert result2["data"] == {}
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_user_already_setup(
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
hass: HomeAssistant, enable_bluetooth: None
|
async def test_setup_user_already_setup(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test setting up via user when already setup ."""
|
"""Test setting up via user when already setup ."""
|
||||||
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
|
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
@ -52,7 +54,8 @@ async def test_setup_user_already_setup(
|
|||||||
assert result["reason"] == "single_instance_allowed"
|
assert result["reason"] == "single_instance_allowed"
|
||||||
|
|
||||||
|
|
||||||
async def test_options_flow(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
|
async def test_options_flow(hass: HomeAssistant) -> None:
|
||||||
"""Test config flow options."""
|
"""Test config flow options."""
|
||||||
config_entry = MockConfigEntry(domain=DOMAIN)
|
config_entry = MockConfigEntry(domain=DOMAIN)
|
||||||
config_entry.add_to_hass(hass)
|
config_entry.add_to_hass(hass)
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.components.private_ble_device import const
|
from homeassistant.components.private_ble_device import const
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -30,7 +32,8 @@ async def test_setup_user_no_bluetooth(
|
|||||||
assert result["reason"] == "bluetooth_not_available"
|
assert result["reason"] == "bluetooth_not_available"
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_irk(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
|
async def test_invalid_irk(hass: HomeAssistant) -> None:
|
||||||
"""Test invalid irk."""
|
"""Test invalid irk."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
@ -43,7 +46,8 @@ async def test_invalid_irk(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
|||||||
assert_form_error(result, "irk", "irk_not_valid")
|
assert_form_error(result, "irk", "irk_not_valid")
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_irk_base64(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
|
async def test_invalid_irk_base64(hass: HomeAssistant) -> None:
|
||||||
"""Test invalid irk."""
|
"""Test invalid irk."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
@ -56,7 +60,8 @@ async def test_invalid_irk_base64(hass: HomeAssistant, enable_bluetooth: None) -
|
|||||||
assert_form_error(result, "irk", "irk_not_valid")
|
assert_form_error(result, "irk", "irk_not_valid")
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_irk_hex(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
|
async def test_invalid_irk_hex(hass: HomeAssistant) -> None:
|
||||||
"""Test invalid irk."""
|
"""Test invalid irk."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
@ -69,7 +74,8 @@ async def test_invalid_irk_hex(hass: HomeAssistant, enable_bluetooth: None) -> N
|
|||||||
assert_form_error(result, "irk", "irk_not_valid")
|
assert_form_error(result, "irk", "irk_not_valid")
|
||||||
|
|
||||||
|
|
||||||
async def test_irk_not_found(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
|
async def test_irk_not_found(hass: HomeAssistant) -> None:
|
||||||
"""Test irk not found."""
|
"""Test irk not found."""
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
const.DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
@ -83,7 +89,8 @@ async def test_irk_not_found(hass: HomeAssistant, enable_bluetooth: None) -> Non
|
|||||||
assert_form_error(result, "irk", "irk_not_found")
|
assert_form_error(result, "irk", "irk_not_found")
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_works(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
|
async def test_flow_works(hass: HomeAssistant) -> None:
|
||||||
"""Test config flow works."""
|
"""Test config flow works."""
|
||||||
|
|
||||||
inject_bluetooth_service_info(
|
inject_bluetooth_service_info(
|
||||||
@ -120,9 +127,8 @@ async def test_flow_works(hass: HomeAssistant, enable_bluetooth: None) -> None:
|
|||||||
assert result["result"].unique_id == "00000000000000000000000000000000"
|
assert result["result"].unique_id == "00000000000000000000000000000000"
|
||||||
|
|
||||||
|
|
||||||
async def test_flow_works_by_base64(
|
@pytest.mark.usefixtures("enable_bluetooth")
|
||||||
hass: HomeAssistant, enable_bluetooth: None
|
async def test_flow_works_by_base64(hass: HomeAssistant) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test config flow works."""
|
"""Test config flow works."""
|
||||||
|
|
||||||
inject_bluetooth_service_info(
|
inject_bluetooth_service_info(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user