@@ -924,6 +924,30 @@ async def test_invalid_unit_of_measurement(
924924 "device_class" : None ,
925925 "unit_of_measurement" : None ,
926926 },
927+ {
928+ "name" : "Test 4" ,
929+ "state_topic" : "test-topic" ,
930+ "device_class" : "ph" ,
931+ "unit_of_measurement" : "" ,
932+ },
933+ {
934+ "name" : "Test 5" ,
935+ "state_topic" : "test-topic" ,
936+ "device_class" : "ph" ,
937+ "unit_of_measurement" : " " ,
938+ },
939+ {
940+ "name" : "Test 6" ,
941+ "state_topic" : "test-topic" ,
942+ "device_class" : None ,
943+ "unit_of_measurement" : "" ,
944+ },
945+ {
946+ "name" : "Test 7" ,
947+ "state_topic" : "test-topic" ,
948+ "device_class" : None ,
949+ "unit_of_measurement" : " " ,
950+ },
927951 ]
928952 }
929953 }
@@ -936,10 +960,25 @@ async def test_valid_device_class_and_uom(
936960 await mqtt_mock_entry ()
937961
938962 state = hass .states .get ("sensor.test_1" )
963+ assert state is not None
939964 assert state .attributes ["device_class" ] == "temperature"
940965 state = hass .states .get ("sensor.test_2" )
966+ assert state is not None
941967 assert "device_class" not in state .attributes
942968 state = hass .states .get ("sensor.test_3" )
969+ assert state is not None
970+ assert "device_class" not in state .attributes
971+ state = hass .states .get ("sensor.test_4" )
972+ assert state is not None
973+ assert state .attributes ["device_class" ] == "ph"
974+ state = hass .states .get ("sensor.test_5" )
975+ assert state is not None
976+ assert state .attributes ["device_class" ] == "ph"
977+ state = hass .states .get ("sensor.test_6" )
978+ assert state is not None
979+ assert "device_class" not in state .attributes
980+ state = hass .states .get ("sensor.test_7" )
981+ assert state is not None
943982 assert "device_class" not in state .attributes
944983
945984
0 commit comments