From 3fa6c97801c2d2985490166d84c600e27db7a33a Mon Sep 17 00:00:00 2001 From: Nick Whyte Date: Tue, 8 Jun 2021 22:26:43 +1000 Subject: [PATCH] Address late review of nsw fuel station (#51619) --- homeassistant/components/nsw_fuel_station/__init__.py | 7 ++++--- tests/components/nsw_fuel_station/test_sensor.py | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/nsw_fuel_station/__init__.py b/homeassistant/components/nsw_fuel_station/__init__.py index a79f164ba0f..f64365461f4 100644 --- a/homeassistant/components/nsw_fuel_station/__init__.py +++ b/homeassistant/components/nsw_fuel_station/__init__.py @@ -7,7 +7,7 @@ import logging from nsw_fuel import FuelCheckClient, FuelCheckError, Station -from homeassistant.helpers.update_coordinator import DataUpdateCoordinator +from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from .const import DATA_NSW_FUEL_STATION @@ -60,5 +60,6 @@ def fetch_station_price_data(client: FuelCheckClient) -> StationPriceData | None ) except FuelCheckError as exc: - _LOGGER.error("Failed to fetch NSW Fuel station price data. %s", exc) - return None + raise UpdateFailed( + f"Failed to fetch NSW Fuel station price data: {exc}" + ) from exc diff --git a/tests/components/nsw_fuel_station/test_sensor.py b/tests/components/nsw_fuel_station/test_sensor.py index a9704256655..c348c7adb9c 100644 --- a/tests/components/nsw_fuel_station/test_sensor.py +++ b/tests/components/nsw_fuel_station/test_sensor.py @@ -75,7 +75,6 @@ MOCK_FUEL_PRICES_RESPONSE = MockGetFuelPricesResponse( ) async def test_setup(get_fuel_prices, hass): """Test the setup with custom settings.""" - assert await async_setup_component(hass, DOMAIN, {}) with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, {"sensor": VALID_CONFIG} @@ -98,7 +97,6 @@ def raise_fuel_check_error(): ) async def test_setup_error(get_fuel_prices, hass): """Test the setup with client throwing error.""" - assert await async_setup_component(hass, DOMAIN, {}) with assert_setup_component(1, sensor.DOMAIN): assert await async_setup_component( hass, sensor.DOMAIN, {"sensor": VALID_CONFIG} @@ -116,7 +114,6 @@ async def test_setup_error(get_fuel_prices, hass): ) async def test_setup_error_no_station(get_fuel_prices, hass): """Test the setup with specified station not existing.""" - assert await async_setup_component(hass, DOMAIN, {}) with assert_setup_component(2, sensor.DOMAIN): assert await async_setup_component( hass,