mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Improve type hints in amberelectric tests (#119229)
This commit is contained in:
parent
06c1c435d1
commit
7dfaa05793
@ -28,7 +28,7 @@ MOCK_API_TOKEN = "psk_0000000000000000"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def setup_no_spike(hass) -> AsyncGenerator:
|
||||
async def setup_no_spike(hass: HomeAssistant) -> AsyncGenerator[Mock]:
|
||||
"""Set up general channel."""
|
||||
MockConfigEntry(
|
||||
domain="amberelectric",
|
||||
@ -51,7 +51,7 @@ async def setup_no_spike(hass) -> AsyncGenerator:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def setup_potential_spike(hass) -> AsyncGenerator:
|
||||
async def setup_potential_spike(hass: HomeAssistant) -> AsyncGenerator[Mock]:
|
||||
"""Set up general channel."""
|
||||
MockConfigEntry(
|
||||
domain="amberelectric",
|
||||
@ -80,7 +80,7 @@ async def setup_potential_spike(hass) -> AsyncGenerator:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def setup_spike(hass) -> AsyncGenerator:
|
||||
async def setup_spike(hass: HomeAssistant) -> AsyncGenerator[Mock]:
|
||||
"""Set up general channel."""
|
||||
MockConfigEntry(
|
||||
domain="amberelectric",
|
||||
@ -108,7 +108,8 @@ async def setup_spike(hass) -> AsyncGenerator:
|
||||
yield mock_update.return_value
|
||||
|
||||
|
||||
def test_no_spike_sensor(hass: HomeAssistant, setup_no_spike) -> None:
|
||||
@pytest.mark.usefixtures("setup_no_spike")
|
||||
def test_no_spike_sensor(hass: HomeAssistant) -> None:
|
||||
"""Testing the creation of the Amber renewables sensor."""
|
||||
assert len(hass.states.async_all()) == 5
|
||||
sensor = hass.states.get("binary_sensor.mock_title_price_spike")
|
||||
@ -118,7 +119,8 @@ def test_no_spike_sensor(hass: HomeAssistant, setup_no_spike) -> None:
|
||||
assert sensor.attributes["spike_status"] == "none"
|
||||
|
||||
|
||||
def test_potential_spike_sensor(hass: HomeAssistant, setup_potential_spike) -> None:
|
||||
@pytest.mark.usefixtures("setup_potential_spike")
|
||||
def test_potential_spike_sensor(hass: HomeAssistant) -> None:
|
||||
"""Testing the creation of the Amber renewables sensor."""
|
||||
assert len(hass.states.async_all()) == 5
|
||||
sensor = hass.states.get("binary_sensor.mock_title_price_spike")
|
||||
@ -128,7 +130,8 @@ def test_potential_spike_sensor(hass: HomeAssistant, setup_potential_spike) -> N
|
||||
assert sensor.attributes["spike_status"] == "potential"
|
||||
|
||||
|
||||
def test_spike_sensor(hass: HomeAssistant, setup_spike) -> None:
|
||||
@pytest.mark.usefixtures("setup_spike")
|
||||
def test_spike_sensor(hass: HomeAssistant) -> None:
|
||||
"""Testing the creation of the Amber renewables sensor."""
|
||||
assert len(hass.states.async_all()) == 5
|
||||
sensor = hass.states.get("binary_sensor.mock_title_price_spike")
|
||||
|
@ -31,7 +31,7 @@ MOCK_API_TOKEN = "psk_0000000000000000"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def setup_general(hass) -> AsyncGenerator:
|
||||
async def setup_general(hass: HomeAssistant) -> AsyncGenerator[Mock]:
|
||||
"""Set up general channel."""
|
||||
MockConfigEntry(
|
||||
domain="amberelectric",
|
||||
@ -54,7 +54,9 @@ async def setup_general(hass) -> AsyncGenerator:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def setup_general_and_controlled_load(hass) -> AsyncGenerator:
|
||||
async def setup_general_and_controlled_load(
|
||||
hass: HomeAssistant,
|
||||
) -> AsyncGenerator[Mock]:
|
||||
"""Set up general channel and controller load channel."""
|
||||
MockConfigEntry(
|
||||
domain="amberelectric",
|
||||
@ -78,7 +80,7 @@ async def setup_general_and_controlled_load(hass) -> AsyncGenerator:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def setup_general_and_feed_in(hass) -> AsyncGenerator:
|
||||
async def setup_general_and_feed_in(hass: HomeAssistant) -> AsyncGenerator[Mock]:
|
||||
"""Set up general channel and feed in channel."""
|
||||
MockConfigEntry(
|
||||
domain="amberelectric",
|
||||
@ -138,9 +140,8 @@ async def test_general_price_sensor(hass: HomeAssistant, setup_general: Mock) ->
|
||||
assert attributes.get("range_max") == 0.12
|
||||
|
||||
|
||||
async def test_general_and_controlled_load_price_sensor(
|
||||
hass: HomeAssistant, setup_general_and_controlled_load: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("setup_general_and_controlled_load")
|
||||
async def test_general_and_controlled_load_price_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test the Controlled Price sensor."""
|
||||
assert len(hass.states.async_all()) == 8
|
||||
price = hass.states.get("sensor.mock_title_controlled_load_price")
|
||||
@ -161,9 +162,8 @@ async def test_general_and_controlled_load_price_sensor(
|
||||
assert attributes["attribution"] == "Data provided by Amber Electric"
|
||||
|
||||
|
||||
async def test_general_and_feed_in_price_sensor(
|
||||
hass: HomeAssistant, setup_general_and_feed_in: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("setup_general_and_feed_in")
|
||||
async def test_general_and_feed_in_price_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test the Feed In sensor."""
|
||||
assert len(hass.states.async_all()) == 8
|
||||
price = hass.states.get("sensor.mock_title_feed_in_price")
|
||||
@ -227,9 +227,8 @@ async def test_general_forecast_sensor(
|
||||
assert first_forecast.get("range_max") == 0.12
|
||||
|
||||
|
||||
async def test_controlled_load_forecast_sensor(
|
||||
hass: HomeAssistant, setup_general_and_controlled_load: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("setup_general_and_controlled_load")
|
||||
async def test_controlled_load_forecast_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test the Controlled Load Forecast sensor."""
|
||||
assert len(hass.states.async_all()) == 8
|
||||
price = hass.states.get("sensor.mock_title_controlled_load_forecast")
|
||||
@ -252,9 +251,8 @@ async def test_controlled_load_forecast_sensor(
|
||||
assert first_forecast["descriptor"] == "very_low"
|
||||
|
||||
|
||||
async def test_feed_in_forecast_sensor(
|
||||
hass: HomeAssistant, setup_general_and_feed_in: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("setup_general_and_feed_in")
|
||||
async def test_feed_in_forecast_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test the Feed In Forecast sensor."""
|
||||
assert len(hass.states.async_all()) == 8
|
||||
price = hass.states.get("sensor.mock_title_feed_in_forecast")
|
||||
@ -277,7 +275,8 @@ async def test_feed_in_forecast_sensor(
|
||||
assert first_forecast["descriptor"] == "very_low"
|
||||
|
||||
|
||||
def test_renewable_sensor(hass: HomeAssistant, setup_general) -> None:
|
||||
@pytest.mark.usefixtures("setup_general")
|
||||
def test_renewable_sensor(hass: HomeAssistant) -> None:
|
||||
"""Testing the creation of the Amber renewables sensor."""
|
||||
assert len(hass.states.async_all()) == 5
|
||||
sensor = hass.states.get("sensor.mock_title_renewables")
|
||||
@ -285,9 +284,8 @@ def test_renewable_sensor(hass: HomeAssistant, setup_general) -> None:
|
||||
assert sensor.state == "51"
|
||||
|
||||
|
||||
def test_general_price_descriptor_descriptor_sensor(
|
||||
hass: HomeAssistant, setup_general: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("setup_general")
|
||||
def test_general_price_descriptor_descriptor_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test the General Price Descriptor sensor."""
|
||||
assert len(hass.states.async_all()) == 5
|
||||
price = hass.states.get("sensor.mock_title_general_price_descriptor")
|
||||
@ -295,8 +293,9 @@ def test_general_price_descriptor_descriptor_sensor(
|
||||
assert price.state == "extremely_low"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("setup_general_and_controlled_load")
|
||||
def test_general_and_controlled_load_price_descriptor_sensor(
|
||||
hass: HomeAssistant, setup_general_and_controlled_load: Mock
|
||||
hass: HomeAssistant,
|
||||
) -> None:
|
||||
"""Test the Controlled Price Descriptor sensor."""
|
||||
assert len(hass.states.async_all()) == 8
|
||||
@ -305,9 +304,8 @@ def test_general_and_controlled_load_price_descriptor_sensor(
|
||||
assert price.state == "extremely_low"
|
||||
|
||||
|
||||
def test_general_and_feed_in_price_descriptor_sensor(
|
||||
hass: HomeAssistant, setup_general_and_feed_in: Mock
|
||||
) -> None:
|
||||
@pytest.mark.usefixtures("setup_general_and_feed_in")
|
||||
def test_general_and_feed_in_price_descriptor_sensor(hass: HomeAssistant) -> None:
|
||||
"""Test the Feed In Price Descriptor sensor."""
|
||||
assert len(hass.states.async_all()) == 8
|
||||
price = hass.states.get("sensor.mock_title_feed_in_price_descriptor")
|
||||
|
Loading…
x
Reference in New Issue
Block a user