Move enable_bluetooth fixture to decorator (#118803)

This commit is contained in:
epenet 2024-06-04 16:20:11 +02:00 committed by GitHub
parent 3d31af3eb4
commit f120f55d86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 14 deletions

View File

@ -2,6 +2,7 @@
from unittest.mock import ANY
import pytest
from syrupy import SnapshotAssertion
from homeassistant.components import bluetooth
@ -14,11 +15,11 @@ from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
@pytest.mark.usefixtures("enable_bluetooth")
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
init_integration: MockConfigEntry,
enable_bluetooth: None,
mock_dashboard,
snapshot: SnapshotAssertion,
) -> None:

View File

@ -2,6 +2,8 @@
from unittest.mock import patch
import pytest
from homeassistant import config_entries
from homeassistant.components.ibeacon.const import CONF_ALLOW_NAMELESS_UUIDS, DOMAIN
from homeassistant.core import HomeAssistant
@ -22,7 +24,8 @@ async def test_setup_user_no_bluetooth(
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."""
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -39,9 +42,8 @@ async def test_setup_user(hass: HomeAssistant, enable_bluetooth: None) -> None:
assert result2["data"] == {}
async def test_setup_user_already_setup(
hass: HomeAssistant, enable_bluetooth: None
) -> None:
@pytest.mark.usefixtures("enable_bluetooth")
async def test_setup_user_already_setup(hass: HomeAssistant) -> None:
"""Test setting up via user when already setup ."""
MockConfigEntry(domain=DOMAIN).add_to_hass(hass)
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"
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."""
config_entry = MockConfigEntry(domain=DOMAIN)
config_entry.add_to_hass(hass)

View File

@ -2,6 +2,8 @@
from unittest.mock import patch
import pytest
from homeassistant import config_entries
from homeassistant.components.private_ble_device import const
from homeassistant.core import HomeAssistant
@ -30,7 +32,8 @@ async def test_setup_user_no_bluetooth(
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."""
result = await hass.config_entries.flow.async_init(
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")
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."""
result = await hass.config_entries.flow.async_init(
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")
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."""
result = await hass.config_entries.flow.async_init(
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")
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."""
result = await hass.config_entries.flow.async_init(
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")
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."""
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"
async def test_flow_works_by_base64(
hass: HomeAssistant, enable_bluetooth: None
) -> None:
@pytest.mark.usefixtures("enable_bluetooth")
async def test_flow_works_by_base64(hass: HomeAssistant) -> None:
"""Test config flow works."""
inject_bluetooth_service_info(