hass-core/tests/components/wallbox/test_sensor.py
hesselonline e56069558a
Refactor wallbox tests (#51094)
* Changed Testing, removed custom exception
Removed custom exceptions, reverted to builtin. Changed testing approach in all tests, now using the core interface to setup device and mock_requests to create test responses for all calls.

* Reintroduce InvalidAuth exception in __init__
Remove reference to internal HA exception, Reintroduce custom exception

* Removed duplicate entry in test_config_flow

* removed tests from test_init that calling methods directly

* Update tests/components/wallbox/__init__.py

Removed duplicate add_to_hass call

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2021-06-27 15:06:25 -04:00

32 lines
995 B
Python

"""Test Wallbox Switch component."""
from homeassistant.components.wallbox.const import CONF_STATION, DOMAIN
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
from tests.common import MockConfigEntry
from tests.components.wallbox import setup_integration
entry = MockConfigEntry(
domain=DOMAIN,
data={
CONF_USERNAME: "test_username",
CONF_PASSWORD: "test_password",
CONF_STATION: "12345",
},
entry_id="testEntry",
)
async def test_wallbox_sensor_class(hass):
"""Test wallbox sensor class."""
await setup_integration(hass)
state = hass.states.get("sensor.mock_title_charging_power")
assert state.attributes["unit_of_measurement"] == "kW"
assert state.attributes["icon"] == "mdi:ev-station"
assert state.name == "Mock Title Charging Power"
state = hass.states.get("sensor.mock_title_charging_speed")
assert state.attributes["icon"] == "mdi:speedometer"
assert state.name == "Mock Title Charging Speed"