Mark entity abc (#28869)

* Mark entity abc

* Use abstractmethod in climate

* Lint
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-11-19 13:42:09 -06:00
1 parent 21157f9dac
commit 94675ca5a7
5 files changed
+60 -10

No files matched your search

+31 -5
View File
@@ -1,10 +1,16 @@
"""The tests for the climate component."""
from unittest.mock import MagicMock
from typing import List
import pytest
import voluptuous as vol
from homeassistant.components.climate import SET_TEMPERATURE_SCHEMA, ClimateDevice
from homeassistant.components.climate import (
SET_TEMPERATURE_SCHEMA,
ClimateDevice,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
)
from tests.common import async_mock_service
@@ -38,9 +44,29 @@ async def test_set_temp_schema(hass, caplog):
assert calls[-1].data == data
class MockClimateDevice(ClimateDevice):
"""Mock Climate device to use in tests."""
@property
def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode.
Need to be one of HVAC_MODE_*.
"""
return HVAC_MODE_HEAT
@property
def hvac_modes(self) -> List[str]:
"""Return the list of available hvac operation modes.
Need to be a subset of HVAC_MODES.
"""
return [HVAC_MODE_OFF, HVAC_MODE_HEAT]
async def test_sync_turn_on(hass):
"""Test if adding turn_on work."""
climate = ClimateDevice()
"""Test if async turn_on calls sync turn_on."""
climate = MockClimateDevice()
climate.hass = hass
climate.turn_on = MagicMock()
@@ -50,8 +76,8 @@ async def test_sync_turn_on(hass):
async def test_sync_turn_off(hass):
"""Test if adding turn_on work."""
climate = ClimateDevice()
"""Test if async turn_off calls sync turn_off."""
climate = MockClimateDevice()
climate.hass = hass
climate.turn_off = MagicMock()