Update MQTT sensor test (#28449)

pull/28201/head
Fabian Affolter 2019-11-02 01:30:37 +01:00 committed by Paulus Schoutsen
parent ad4a960ed2
commit 15900094a1
1 changed files with 6 additions and 6 deletions

View File

@ -268,12 +268,12 @@ async def test_setting_sensor_attribute_via_legacy_mqtt_json_message(hass, mqtt_
"name": "test",
"state_topic": "test-topic",
"unit_of_measurement": "fav unit",
"json_attributes": "val",
"json_attributes_topic": "test-attributes-topic",
}
},
)
async_fire_mqtt_message(hass, "test-topic", '{ "val": "100" }')
async_fire_mqtt_message(hass, "test-attributes-topic", '{ "val": "100" }')
state = hass.states.get("sensor.test")
assert state.attributes.get("val") == "100"
@ -290,12 +290,12 @@ async def test_update_with_legacy_json_attrs_not_dict(hass, mqtt_mock, caplog):
"name": "test",
"state_topic": "test-topic",
"unit_of_measurement": "fav unit",
"json_attributes": "val",
"json_attributes_topic": "test-attributes-topic",
}
},
)
async_fire_mqtt_message(hass, "test-topic", '[ "list", "of", "things"]')
async_fire_mqtt_message(hass, "test-attributes-topic", '[ "list", "of", "things"]')
state = hass.states.get("sensor.test")
assert state.attributes.get("val") is None
@ -313,12 +313,12 @@ async def test_update_with_legacy_json_attrs_bad_JSON(hass, mqtt_mock, caplog):
"name": "test",
"state_topic": "test-topic",
"unit_of_measurement": "fav unit",
"json_attributes": "val",
"json_attributes_topic": "test-attributes-topic",
}
},
)
async_fire_mqtt_message(hass, "test-topic", "This is not JSON")
async_fire_mqtt_message(hass, "test-attributes-topic", "This is not JSON")
state = hass.states.get("sensor.test")
assert state.attributes.get("val") is None