1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Improve MQTT test coverage and remove dead code (#33584)

* Improve MQTT tests and remove dead code

* Remove useless test.

* Add more test
This commit is contained in:
Erik Montnemery
2020-04-03 18:05:58 +02:00
committed by GitHub
parent a813847f6e
commit 4e6fd19624
12 changed files with 761 additions and 125 deletions

View File

@@ -534,6 +534,22 @@ async def test_set_hold(hass, mqtt_mock):
assert state.attributes.get("preset_mode") is None
async def test_set_preset_mode_twice(hass, mqtt_mock):
"""Test setting of the same mode twice only publishes once."""
assert await async_setup_component(hass, CLIMATE_DOMAIN, DEFAULT_CONFIG)
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get("preset_mode") is None
await common.async_set_preset_mode(hass, "hold-on", ENTITY_CLIMATE)
mqtt_mock.async_publish.assert_called_once_with("hold-topic", "hold-on", 0, False)
mqtt_mock.async_publish.reset_mock()
state = hass.states.get(ENTITY_CLIMATE)
assert state.attributes.get("preset_mode") == "hold-on"
await common.async_set_preset_mode(hass, "hold-on", ENTITY_CLIMATE)
mqtt_mock.async_publish.assert_not_called()
async def test_set_aux_pessimistic(hass, mqtt_mock):
"""Test setting of the aux heating in pessimistic mode."""
config = copy.deepcopy(DEFAULT_CONFIG)