Revert changes from #70300 part 2 (#70386)

pull/70391/head
J. Nick Koston 2022-04-21 10:50:00 -10:00 committed by GitHub
parent 23de8d4156
commit f1b400feaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 19 deletions

View File

@ -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")

View File

@ -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

View File

@ -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"}}
)

View File

@ -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",

View File

@ -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

View File

@ -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))

View File

@ -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))

View File

@ -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

View File

@ -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
):