parent
23de8d4156
commit
f1b400feaf
|
@ -30,6 +30,7 @@ from homeassistant.const import (
|
|||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import utcnow
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from tests.common import async_fire_time_changed, load_fixture
|
||||
from tests.components.accuweather import init_integration
|
||||
|
@ -693,8 +694,9 @@ async def test_manual_update_entity(hass):
|
|||
assert mock_forecast.call_count == 1
|
||||
|
||||
|
||||
async def test_sensor_imperial_units(hass, units_imperial):
|
||||
async def test_sensor_imperial_units(hass):
|
||||
"""Test states of the sensor without forecast."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
await init_integration(hass)
|
||||
|
||||
state = hass.states.get("sensor.home_cloud_ceiling")
|
||||
|
|
|
@ -4,9 +4,6 @@ from unittest.mock import AsyncMock, patch
|
|||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def patch_zeroconf_multiple_catcher():
|
||||
|
@ -36,10 +33,3 @@ def entity_registry_enabled_by_default() -> Generator[AsyncMock, None, None]:
|
|||
return_value=True,
|
||||
) as mock_entity_registry_enabled_by_default:
|
||||
yield mock_entity_registry_enabled_by_default
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def units_imperial(hass: HomeAssistant) -> Generator[None, None, None]:
|
||||
"""Fixture to temporary change units to imperial."""
|
||||
with patch.object(hass.config, "units", IMPERIAL_SYSTEM):
|
||||
yield
|
||||
|
|
|
@ -4,6 +4,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components import water_heater
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from tests.components.water_heater import common
|
||||
|
||||
|
@ -12,8 +13,9 @@ ENTITY_WATER_HEATER_CELSIUS = "water_heater.demo_water_heater_celsius"
|
|||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def setup_comp(hass, units_imperial):
|
||||
async def setup_comp(hass):
|
||||
"""Set up demo component."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
assert await async_setup_component(
|
||||
hass, water_heater.DOMAIN, {"water_heater": {"platform": "demo"}}
|
||||
)
|
||||
|
|
|
@ -34,6 +34,7 @@ from homeassistant.const import (
|
|||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.components.gdacs import _generate_mock_feed_entry
|
||||
|
@ -204,8 +205,9 @@ async def test_setup(hass):
|
|||
assert len(entity_registry.entities) == 1
|
||||
|
||||
|
||||
async def test_setup_imperial(hass, units_imperial):
|
||||
async def test_setup_imperial(hass):
|
||||
"""Test the setup of the integration using imperial unit system."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
# Set up some mock feed entries for this test.
|
||||
mock_entry_1 = _generate_mock_feed_entry(
|
||||
"1234",
|
||||
|
|
|
@ -39,7 +39,7 @@ from homeassistant.core import DOMAIN as HASS_DOMAIN, CoreState, State, callback
|
|||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.unit_system import METRIC_SYSTEM
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM
|
||||
|
||||
from tests.common import (
|
||||
assert_setup_component,
|
||||
|
@ -1201,8 +1201,9 @@ async def setup_comp_9(hass):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def test_precision(hass, units_imperial, setup_comp_9):
|
||||
async def test_precision(hass, setup_comp_9):
|
||||
"""Test that setting precision to tenths works as intended."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
await common.async_set_temperature(hass, 23.27)
|
||||
state = hass.states.get(ENTITY)
|
||||
assert state.attributes.get("temperature") == 23.3
|
||||
|
|
|
@ -28,6 +28,7 @@ from homeassistant.const import (
|
|||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.components.geonetnz_quakes import _generate_mock_feed_entry
|
||||
|
@ -167,8 +168,9 @@ async def test_setup(hass):
|
|||
assert len(entity_registry.entities) == 1
|
||||
|
||||
|
||||
async def test_setup_imperial(hass, units_imperial):
|
||||
async def test_setup_imperial(hass):
|
||||
"""Test the setup of the integration using imperial unit system."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
# Set up some mock feed entries for this test.
|
||||
mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 15.5, (38.0, -3.0))
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ from homeassistant.const import (
|
|||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from tests.common import async_fire_time_changed
|
||||
from tests.components.geonetnz_volcano import _generate_mock_feed_entry
|
||||
|
@ -146,8 +147,9 @@ async def test_setup(hass):
|
|||
)
|
||||
|
||||
|
||||
async def test_setup_imperial(hass, units_imperial):
|
||||
async def test_setup_imperial(hass):
|
||||
"""Test the setup of the integration using imperial unit system."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
# Set up some mock feed entries for this test.
|
||||
mock_entry_1 = _generate_mock_feed_entry("1234", "Title 1", 1, 15.5, (38.0, -3.0))
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
PRESSURE_PSI,
|
||||
)
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from . import init_integration
|
||||
|
||||
|
@ -125,8 +126,10 @@ async def test_sensors(hass):
|
|||
assert entry.unique_id == "JM000000000000000_rear_right_tire_pressure"
|
||||
|
||||
|
||||
async def test_sensors_imperial_units(hass, units_imperial):
|
||||
async def test_sensors_imperial_units(hass):
|
||||
"""Test that the sensors work properly with imperial units."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
|
||||
await init_integration(hass)
|
||||
|
||||
# Fuel Distance Remaining
|
||||
|
|
|
@ -10,6 +10,7 @@ from homeassistant.components.subaru.sensor import (
|
|||
SENSOR_TYPE,
|
||||
)
|
||||
from homeassistant.util import slugify
|
||||
from homeassistant.util.unit_system import IMPERIAL_SYSTEM
|
||||
|
||||
from .api_responses import (
|
||||
EXPECTED_STATE_EV_IMPERIAL,
|
||||
|
@ -29,8 +30,10 @@ from tests.components.subaru.conftest import (
|
|||
VEHICLE_NAME = VEHICLE_DATA[TEST_VIN_2_EV][VEHICLE_NAME]
|
||||
|
||||
|
||||
async def test_sensors_ev_imperial(hass, ev_entry, units_imperial):
|
||||
async def test_sensors_ev_imperial(hass, ev_entry):
|
||||
"""Test sensors supporting imperial units."""
|
||||
hass.config.units = IMPERIAL_SYSTEM
|
||||
|
||||
with patch(MOCK_API_FETCH), patch(
|
||||
MOCK_API_GET_DATA, return_value=VEHICLE_STATUS_EV
|
||||
):
|
||||
|
|
Loading…
Reference in New Issue