async def test_temperature_sensor_f(mock_function): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor( client, mhz19.SENSOR_TEMPERATURE, TEMP_FAHRENHEIT, "name" ) sensor.update() assert sensor.state == 75.2
async def test_temperature_sensor(mock_function): """Test temperature sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_TEMPERATURE, None, "name") sensor.update() assert sensor.name == "name: Temperature" assert sensor.state == 24 assert sensor.unit_of_measurement == TEMP_CELSIUS assert sensor.should_poll assert sensor.extra_state_attributes == {"co2_concentration": 1000}
async def test_co2_sensor(mock_function): """Test CO2 sensor.""" client = mhz19.MHZClient(co2sensor, "test.serial") sensor = mhz19.MHZ19Sensor(client, mhz19.SENSOR_CO2, None, "name") sensor.update() assert sensor.name == "name: CO2" assert sensor.state == 1000 assert sensor.unit_of_measurement == CONCENTRATION_PARTS_PER_MILLION assert sensor.should_poll assert sensor.extra_state_attributes == {"temperature": 24}
async def aiohttp_client_update_good_read(mock_function): """Test MHZClient when ppm is too high.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert {"temperature": 24, "co2": 1000} == client.data
async def aiohttp_client_update_ppm_overflow(mock_function): """Test MHZClient when ppm is too high.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert client.data.get("co2") is None
async def aiohttp_client_update_oserror(mock_function): """Test MHZClient when library throws OSError.""" client = mhz19.MHZClient(co2sensor, "test.serial") client.update() assert {} == client.data